评分和徽章要点 scoring-and-badges-essentials
AEM Communities评分和徽章功能可识别并奖励社区成员。
有关设置该功能的详细信息,请参阅
此页面包含其他技术详细信息:
显示徽章 displaying-badges
在HBS模板的客户端上,将控制徽章显示为文本还是图像。
例如,搜索 this.isAssigned
在 /libs/social/forum/components/hbs/topic/list-item.hbs
:
{{#each author.badges}}
{{#if this.isAssigned}}
<div class="scf-badge-text">
{{this.title}}
</div>
{{/if}}
{{/each}}
{{#each author.badges}}
{{#unless this.isAssigned}}
<img class="scf-badge-image" alt="{{this.title}}" title="{{this.title}}" src="{{this.imageUrl}}" />
{{/unless}}
{{/each}}
如果为真, isAssigned
指示徽章已分配给角色,并且该徽章应显示为文本。
如果为false isAssigned
表示该徽章已获得挣得的分数,并且该徽章应显示为图像。
对此行为的任何更改都应在自定义脚本中进行(覆盖或叠加)。 请参阅 客户端自定义.
评分和徽章的调试日志 debug-log-for-scoring-and-badging
为了帮助调试评分和徽章,可以设置自定义日志文件。 如果功能出现问题,可以将该日志文件的内容提供给客户支持。
有关详细说明,请访问 创建自定义日志文件.
要快速设置slinglog文件:
-
访问 Adobe Experience Manager Web控制台日志支持 例如
- https://localhost:4502/system/console/slinglog
-
选择 添加新记录器
-
选择
DEBUG
对象 日志级别 -
输入名称 日志文件 例如
- logs/scoring-debug.log
-
输入两个 Logger (类)条目(使用
+
图标)com.adobe.cq.social.scoring
com.adobe.cq.social.badging
-
选择 保存
-
要查看日志条目,请执行以下操作:
-
从Web控制台
- 在 状态 菜单
- 选择 日志文件
- 搜索您的日志文件名,例如
scoring-debug
-
在服务器的本地磁盘上
-
日志文件位于<server-install-dir>/crx-quickstart/logs/<log-file-name>.log
-
例如,
.../crx-quickstart/logs/scoring-debug.log
-
评分和徽章的UGC ugc-for-scoring-and-badging
当所选的SRP是JSRP或MSRP,而不是ASRP时,可以查看与评分和徽章相关的UGC。 (如果不熟悉这些术语,请参阅 社区内容存储 和 存储资源提供程序概述.)
用于访问评分和徽章数据的描述使用JSRP,因为可通过以下方式轻松访问UGC CRXDE Lite.
创作实例上的JSRP:在创作环境中试验会导致生成仅从创作环境中可见的UGC。
发布时JSRP:同样,如果在发布环境中进行测试,则必须在发布实例上使用管理权限访问CRXDE Lite。 如果发布实例在中运行 生产模式 (nosamplecontent run mode),则需要 启用CRXDE Lite.
JSRP上UGC的基本位置为 /content/usergenerated/asi/jcr/
.
评分和徽章API scoring-and-badging-apis
以下API可供使用:
开发人员可以从Adobe存储库中找到已安装功能包的最新Javadoc。 请参阅 使用Maven for Communities :Javadocs.
UGC在存储库中的位置和格式可能会发生更改,恕不发出警告.
示例设置 example-setup
存储库数据的屏幕截图来自为两个不同AEM站点上的论坛设置评分和徽章:
-
AEM站点 替换为 唯一id(使用向导创建的社区站点):
-
使用在中创建的快速入门教程(engage)网站 快速入门教程
-
找到论坛页面节点
/content/sites/engage/en/forum/jcr:content
-
添加评分和徽章属性
code language-none scoringRules = [/libs/settings/community/scoring/rules/comments-scoring, /libs/settings/community/scoring/rules/forums-scoring]
code language-none badgingRules =[/libs/settings/community/badging/rules/comments-scoring, /libs/settings/community/badging/rules/forums-scoring]
-
找到论坛组件节点
/content/sites/engage/en/forum/jcr:content/content/primary/forum
(sling:resourceType = social/forum/components/hbs/forum
) -
要显示徽章,请添加属性
allowBadges = true
-
用户登录、创建论坛主题并获得“铜牌”
-
-
AEM站点 不含 唯一ID :
-
使用 社区组件指南
-
找到论坛页面节点
/content/community-components/en/forum/jcr:content
-
添加评分和徽章属性
code language-none scoringRules = [/libs/settings/community/scoring/rules/comments-scoring, /libs/settings/community/scoring/rules/forums-scoring]
code language-none badgingRules =[/libs/settings/community/badging/rules/comments-badging, /libs/settings/community/badging/rules/forums-badging]
-
找到论坛组件节点
/content/community-components/en/forum/jcr:content/content/forum
(sling:resourceType = social/forum/components/hbs/forum
) -
要显示徽章,请添加属性
allowBadges = true
-
用户登录、创建论坛主题并获得“铜牌”
-
-
已使用cURL为用户分配了审查方徽章:
code language-shell curl -i -X POST -H "Accept:application/json" -u admin:admin -F ":operation=social:assignBadge" -F "badgeContentPath=/libs/settings/community/badging/images/moderator/jcr:content/moderator.png" https://localhost:4503/home/users/community/w271OOup2Z4DjnOQrviv/profile.social.json
由于用户已获得两个铜牌徽章并获得了版主徽章,因此该用户将以下列方式显示其论坛条目:
-
评分规则名称应具有全局唯一性;它们不应以相同的名称结尾。
示例 非 待办事项:
/libs/settings/community/scoring/rules/site1/forums-scoring
/libs/settings/community/scoring/rules/site2/forums-scoring -
为不同的AEM站点创建唯一的徽章图像
访问得分UGC access-scoring-ugc
使用 API 是首选。
出于调查目的,以JSRP为例,包含分数的基本文件夹为
/content/usergenerated/asi/jcr/scoring
的子节点 scoring
是评分规则名称。 因此,最佳做法是服务器上的评分规则名称具有全局唯一性。
对于Geometrixx参与站点,用户及其得分位于使用评分规则名称、社区站点的站点ID ( engage-ba81p
)、唯一id和用户的id :
.../scoring/forums-scoring/engage-ba81p/6d179715c0e93cb2b20886aa0434ca9b5a540401/riley
对于社区组件指南站点,用户及其分数位于使用评分规则名称(默认ID ( default-site
)、唯一id和用户的id :
.../scoring/forums-scoring/default-site/b27a17cb4910a9b69fe81fb1b492ba672d2c086e/riley
分数存储在属性中 scoreValue_tl
只能包含值,或者间接引用atomicCounter。
访问徽章UGC access-badging-ugc
使用 API 是首选。
出于调查目的,以JSRP为例,包含有关已分配或已授予徽章的信息的基本文件夹为
/content/usergenerated/asi/jcr
后跟用户配置文件的路径,以徽章文件夹结尾,例如:
/home/users/community/w271OOup2Z4DjnOQrviv/profile/badges
已授予的徽章 awarded-badge
已分配的徽章 assigned-badge
附加信息 additional-information
要根据点显示已排序的成员列表,请执行以下操作: