Commit 231d2d0d by xiaowenfeng

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

parent e244d158
Showing with 53 additions and 11 deletions
......@@ -169,6 +169,7 @@ export default {
return {
pageIndex: 1, // pdf页码
pageLength: null, // 总页码
startTime: null,
scale: 2, // 缩放比例
borderSize: 9, // viewerContainer容器border大小
pageSize: 1,
......@@ -198,9 +199,10 @@ export default {
this.playInitializationData = window.parent.playInitializationData;
this.LMSPlayInitialize();
this.LMSTrackingInitialize();
this.LMSCatalogUrl();
// this.LMSCatalogUrl();
this.LMSGetLocationPoint();
this.LMSGetLessonStatus();
this.startTime = new Date().getTime();
pdfJs.GlobalWorkerOptions.workerSrc = require("pdfjs-dist/build/pdf.worker");
this.preview();
},
......@@ -360,6 +362,9 @@ export default {
}
this.pageIndex = this.pageIndex - 1;
this.LMSSetLocationPoint();
this.LMSSetLessProgress();
this.LMSSetSessionTime();
this.LMSCommit();
this.preview();
},
next() {
......@@ -371,10 +376,12 @@ export default {
}
this.pageIndex = this.pageIndex + 1;
this.LMSSetLocationPoint();
this.LMSSetLessProgress();
this.LMSSetSessionTime();
if (this.pageIndex === this.pageLength) {
this.LMSSetLessonStatus();
this.LMSCommit();
this.LMSSetLessonStatus("completed");
}
this.LMSCommit();
this.preview();
},
changeSelected(index) {
......@@ -549,6 +556,30 @@ export default {
this.playInitializationData.value = this.pageIndex;
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) {
$.ajax({
type: "post",
......@@ -570,14 +601,25 @@ export default {
}
});
},
LMSSetLessonStatus() {
this.playInitializationData.element = "cmi.core.lesson_status";
this.playInitializationData.value = "completed";
this.LMSSetValueUrl();
},
LMSGetLessonStatus() {
this.playInitializationData.element = "cmi.core.lesson_status";
this.LMSGetValueUrl();
timeToFormat(times) {
var result = "00:00:00";
var hour, minute, second;
if (times > 0) {
hour = Math.floor(times / 3600);
if (hour < 10) {
hour = "0" + hour;
}
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