Javascript 自动向LMS发送SCORM数据

Javascript 自动向LMS发送SCORM数据,javascript,scorm,Javascript,Scorm,到目前为止我有这个代码 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 + qbin2

到目前为止我有这个代码

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);
函数sendData(){
//这将计算出我的位置并构造“cmi.core.lesson.location”变量
computeTime();
变量a=“”+(课程长度-1)+“|”;
对于(i=1;i
然而,它似乎并没有达到预期的效果。数据应该每1000毫秒发送一次到服务器,但事实并非如此。我错过了什么

正如我旁白所说,这是SCORM 1.2。

那么,您是在打电话吗

setTimeout(sendData(), 1000);
这相当于

var foo = sendData();
setTimeout(foo, 1000);
setTimeout(undefined, 1000);
由于
sendData
不返回任何内容,因此这相当于

var foo = sendData();
setTimeout(foo, 1000);
setTimeout(undefined, 1000);
你可能是说:

setTimeout(sendData, 1000);

你可以将许多事情描述为“那没有发生”。。。通常最好准确地描述发生了什么……数据正在创建,并且正在到达“
objAPI.LMSCommit(“”
”),但数据似乎并没有在服务器上结束。但是,已经到位的退出功能包括一个额外的行来停止LMS(
objAPI.LMSFinish(“”
”)确实有效。objAPI.LMSCommit(“”)应该告诉LMS存储数据。可能会查出这是不是真的。上面的调用似乎做了2次,这不是一个停止,但可能会增加从客户端到后端的SCORM聊天。这是一个旧的代码片段。忘了把它拿出来。