FastComments.com

为 LearnWorlds 课程和页面添加评论

FastComments 可以添加到 LearnWorlds 的两个位置:

  • 课程内容,在课程大纲中使用 Embed 学习活动。LearnWorlds 列出 Embed 学习活动适用于 Trial、Starter、Pro Trainer、Learning Center 以及 High Volume & Corporate 套餐。
  • 使用 LearnWorlds Site Builder 构建的站点页面,通过 Embed 区块。

本教程需要一个 FastComments 账户。在复制代码片段之前请先登录,这样代码片段才会包含您账户的租户 ID。您可以在此处创建账户。

步骤 1:创建嵌入学习活动 Internal Link

课程中的每个评论区都是一个独立的 Embed 学习活动。在需要学员能够评论的地方添加一个:

  1. 打开 Course Manager,找到该课程,然后进入 Course outline。
  2. 点击 Add activity 并选择 Embed。
  3. 输入该活动的标题。
  4. 点击 Save and Edit。

如果你点击的是 Save,请将鼠标悬停在新建的活动上,点击 Settings 以打开代码字段。

步骤 2:粘贴 FastComments 课程代码 Internal Link

复制以下代码片段。如果 tenantId 为 demo,请登录您的 FastComments 账户并重新加载此页面,以便代码片段包含您的租户 ID。

FastComments LearnWorlds 课程代码片段
Copy Copy
1
2<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script>
3<div id="fastcomments-widget"></div>
4<script>
5 (function fcLoad() {
6 // 为每个嵌入活动更改此值。每个值都是一个独立的评论线程。
7 var threadId = 'my-course-activity-1';
8
9 function getPageWindow() {
10 try {
11 if (window.top.location.href) {
12 return window.top;
13 }
14 } catch (e) {}
15 return window;
16 }
17
18 function tryLoad() {
19 var container = document.getElementById('fastcomments-widget');
20 if (!container || !window.FastCommentsUI) {
21 return setTimeout(tryLoad, 500);
22 }
23 if (container.fastCommentsSetup) {
24 return;
25 }
26 var pageWindow = getPageWindow();
27 window.FastCommentsUI(container, {
28 tenantId: 'demo',
29 urlId: threadId,
30 url: pageWindow.location.href,
31 pageTitle: pageWindow.document.title
32 });
33 container.fastCommentsSetup = true;
34 }
35
36 tryLoad();
37 })();
38</script>
39

在粘贴之前,请更改 threadId 的值。threadId 的值会作为 urlId 传递给组件,用于标识评论线程。请为每个嵌入活动使用不同的值,例如 intro-course-lesson-1。两个使用相同值的活动将显示相同的评论。详情请参阅 URL ID。

将代码片段粘贴到嵌入学习活动的代码字段中,然后点击 Save。

该代码片段在可能的情况下会从顶层浏览器窗口读取页面地址和标题,否则从其自身窗口读取。这些值会与每条评论一起存储,并用于通知和审核仪表板中的链接。

步骤 3:隐藏原生课程讨论标签页 Internal Link

LearnWorlds 课程可以在课程播放器中显示原生的“讨论”标签页。若要在某个课程中仅显示 FastComments,请为该课程关闭“讨论”标签页:

  1. 前往 Courses & Programs,然后进入 Courses。
  2. 选择该课程。
  3. 前往 Course settings 并打开 Course Player。
  4. 关闭 Show the course Discussion tab 设置。

课程播放器设置仅适用于单个课程。全校范围的课程讨论设置位于 Settings、School settings、Community access 中的 Course Discussion 部分。

此步骤是可选的。FastComments 不依赖于原生“讨论”标签页的显示或隐藏。

步骤 1:添加嵌入部分 Internal Link

要为使用 LearnWorlds Site Builder 构建的页面添加评论:

  1. 进入 Website,然后 Design,再 Edit Website。
  2. 在 Page Manager 中选择要编辑的页面。
  3. 将鼠标悬停在页面上,点击 (+) 图标以添加一个区块。
  4. 选择 Embed 分类并点击 Add。
  5. 点击新元素,在侧边表单中打开其设置。

步骤 2:粘贴 FastComments 页面代码 Internal Link

复制以下代码片段。如果 tenantId 为 demo,请登录您的 FastComments 账户并重新加载此页面,以便代码片段包含您的租户 ID。

FastComments LearnWorlds 页面代码片段
Copy Copy
1
2<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script>
3<div id="fastcomments-widget"></div>
4<script>
5 (function fcLoad() {
6 function getPageWindow() {
7 try {
8 if (window.top.location.href) {
9 return window.top;
10 }
11 } catch (e) {}
12 return window;
13 }
14
15 function tryLoad() {
16 var container = document.getElementById('fastcomments-widget');
17 if (!container || !window.FastCommentsUI) {
18 return setTimeout(tryLoad, 500);
19 }
20 if (container.fastCommentsSetup) {
21 return;
22 }
23 var pageWindow = getPageWindow();
24 window.FastCommentsUI(container, {
25 tenantId: 'demo',
26 urlId: pageWindow.location.pathname,
27 url: pageWindow.location.href,
28 pageTitle: pageWindow.document.title
29 });
30 container.fastCommentsSetup = true;
31 }
32
33 tryLoad();
34 })();
35</script>
36

然后:

  1. 将代码片段粘贴到侧边表单中的 Embeddable script 输入框内。
  2. 点击 Update。
  3. 点击 Save 保存页面。

LearnWorlds 仅在页面更新后或预览时才会渲染嵌入内容,因此在此之前编辑器中可能不会显示评论区域。

该代码片段使用页面路径作为 urlId,因此同一段代码可以粘贴到多个页面上,每个页面都会拥有自己的评论线程。

自定义 Internal Link

可以通过自定义 CSS 和配置选项来更改小部件的样式和行为。

有关可用选项,请参阅自定义文档。