Commit 231d2d0d by xiaowenfeng

增加了学习进度、学习时长追踪API

parent e244d158
Showing with 53 additions and 11 deletions
...@@ -169,6 +169,7 @@ export default { ...@@ -169,6 +169,7 @@ export default {
return { return {
pageIndex: 1, // pdf页码 pageIndex: 1, // pdf页码
pageLength: null, // 总页码 pageLength: null, // 总页码
startTime: null,
scale: 2, // 缩放比例 scale: 2, // 缩放比例
borderSize: 9, // viewerContainer容器border大小 borderSize: 9, // viewerContainer容器border大小
pageSize: 1, pageSize: 1,
...@@ -198,9 +199,10 @@ export default { ...@@ -198,9 +199,10 @@ export default {
this.playInitializationData = window.parent.playInitializationData; this.playInitializationData = window.parent.playInitializationData;
this.LMSPlayInitialize(); this.LMSPlayInitialize();
this.LMSTrackingInitialize(); this.LMSTrackingInitialize();
this.LMSCatalogUrl(); // this.LMSCatalogUrl();
this.LMSGetLocationPoint(); this.LMSGetLocationPoint();
this.LMSGetLessonStatus(); this.LMSGetLessonStatus();
this.startTime = new Date().getTime();
pdfJs.GlobalWorkerOptions.workerSrc = require("pdfjs-dist/build/pdf.worker"); pdfJs.GlobalWorkerOptions.workerSrc = require("pdfjs-dist/build/pdf.worker");
this.preview(); this.preview();
}, },
...@@ -360,6 +362,9 @@ export default { ...@@ -360,6 +362,9 @@ export default {
} }
this.pageIndex = this.pageIndex - 1; this.pageIndex = this.pageIndex - 1;
this.LMSSetLocationPoint(); this.LMSSetLocationPoint();
this.LMSSetLessProgress();
this.LMSSetSessionTime();
this.LMSCommit();
this.preview(); this.preview();
}, },
next() { next() {
...@@ -371,10 +376,12 @@ export default { ...@@ -371,10 +376,12 @@ export default {
} }
this.pageIndex = this.pageIndex + 1; this.pageIndex = this.pageIndex + 1;
this.LMSSetLocationPoint(); this.LMSSetLocationPoint();
this.LMSSetLessProgress();
this.LMSSetSessionTime();
if (this.pageIndex === this.pageLength) { if (this.pageIndex === this.pageLength) {
this.LMSSetLessonStatus(); this.LMSSetLessonStatus("completed");
this.LMSCommit();
} }
this.LMSCommit();
this.preview(); this.preview();
}, },
changeSelected(index) { changeSelected(index) {
...@@ -549,6 +556,30 @@ export default { ...@@ -549,6 +556,30 @@ export default {
this.playInitializationData.value = this.pageIndex; this.playInitializationData.value = this.pageIndex;
this.LMSSetValueUrl(); this.LMSSetValueUrl();
}, },
LMSSetLessProgress() {
this.playInitializationData.element = "cmi.core.lesson_progress";
this.playInitializationData.value = parseInt(
(this.pageIndex / this.pageLength) * 100
);
this.LMSSetValueUrl();
},
LMSSetSessionTime() {
this.playInitializationData.element = "cmi.core.session_time";
let currentTime = new Date().getTime();
this.playInitializationData.value = this.timeToFormat(
(currentTime - this.startTime) / 1000
);
this.LMSSetValueUrl();
},
LMSSetLessonStatus(status) {
this.playInitializationData.element = "cmi.core.lesson_status";
this.playInitializationData.value = status;
this.LMSSetValueUrl();
},
LMSGetLessonStatus() {
this.playInitializationData.element = "cmi.core.lesson_status";
this.LMSGetValueUrl();
},
LMSCommit(fn) { LMSCommit(fn) {
$.ajax({ $.ajax({
type: "post", type: "post",
...@@ -570,14 +601,25 @@ export default { ...@@ -570,14 +601,25 @@ export default {
} }
}); });
}, },
LMSSetLessonStatus() { timeToFormat(times) {
this.playInitializationData.element = "cmi.core.lesson_status"; var result = "00:00:00";
this.playInitializationData.value = "completed"; var hour, minute, second;
this.LMSSetValueUrl(); if (times > 0) {
}, hour = Math.floor(times / 3600);
LMSGetLessonStatus() { if (hour < 10) {
this.playInitializationData.element = "cmi.core.lesson_status"; hour = "0" + hour;
this.LMSGetValueUrl(); }
minute = Math.floor((times - 3600 * hour) / 60);
if (minute < 10) {
minute = "0" + minute;
}
second = Math.floor((times - 3600 * hour - 60 * minute) % 60);
if (second < 10) {
second = "0" + second;
}
result = hour + ":" + minute + ":" + second;
}
return result;
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment