自动向LMS发送SCORM数据

Automatically send SCORM data to LMS

本文关键字:SCORM 数据 发送 LMS      更新时间:2023-09-26

到目前为止我有这个代码…

function sendData() {
    // this work out where I am and construct the 'cmi.core.lesson.location' variable
    computeTime();
    var a = "" + (course.length - 1) + "|";
    for (i = 1; i < course.length; i++) {
        a = a + qbin2hex(course[i].pages).join("") + "|";
            if (iLP == 1) {
                    a = a + course[i].duration + "|";
                    a = a + course[i].timecompleted + "|"
            }
    }
    SetQuizDetails();
    a = a + course[0].quiz_score_running + "|0|0|0|0|0|0|";
    objAPI.LMSSetValue("cmi.core.lesson_location", "LP_AT7|" + a);
    bFinishDone = (objAPI.LMSCommit("") == "true");
    objAPI.LMSCommit("");
    console.log("Data Sent!");
}
setTimeout(sendData(), 1000);

然而,它似乎没有像预期的那样工作。数据应该每1000毫秒发送一次到服务器,但事实并非如此。我遗漏了什么?

作为我的旁注,这是SCORM 1.2。

调用

setTimeout(sendData(), 1000);

相当于

var foo = sendData();
setTimeout(foo, 1000);

看到sendData不返回任何值,这就等价于

setTimeout(undefined, 1000);

你的意思可能是:

setTimeout(sendData, 1000);