书签LMS,Moodle SCORM

时间:2012-02-29 16:27:19

标签: javascript moodle scorm

我正在寻找一种使用JavaScript为页面添加书签的方法,这样当用户重新打开课程时,它会通过将其发送到SCORM / Moodle来记住他或她所在的页面。

任何想法的人?

使用scorm 1.2和Moodle 1.9:)

非常感谢

<!-- ================ -->
<!-- Bookmarking start -->
<!-- ================ -->
<script type="text/javascript" src="SCORM_API_wrapper.js"></script>
<script type="text/javascript">
//Using pipwerks namespace, SCORM 1.2

var success = pipwerks.SCORM.init();

if(success){
  var status = pipwerks.SCORM.get("cmi.core.lesson_status");
  if(status != "completed"){
    success = pipwerks.SCORM.get("cmi.core.lesson_status", "completed");
    if(success){
       pipwerks.SCORM.quit();
    }
  }
}

function setbookMark() {
    var setlessonLocation = scorm.set("cmi.core.lesson_location", "2");
}

function showbookMark() {
    alert(scorm.get("cmi.core.lesson_location"));
}

window.onload = function (){
    init();
    setbookMark();
}


</script>
<!-- ================ -->
<!-- Bookmarking End -->
<!-- ================ -->

加载的第一个索引页

<script type="text/javascript" src="SCORM_API_wrapper.js"></script>
<script type="text/javascript">
var scorm = pipwerks.SCORM;


function init(){

    //Specify SCORM 1.2:
    scorm.version = "1.2";

    var callSucceeded = scorm.init();
}

function end(){

    var callSucceeded = scorm.quit();
}


function bookMark() {
    var lessonLocation = scorm.get("cmi.core.lesson_location");
    if (lessonLocation == "1") {
        window.location = "1.html";
        }
    else if(lessonLocation == "2") {
        window.location = "2.html";
        }
    else if(lessonLocation == "3") {
        window.location = "3.html";
        }
    else if(lessonLocation == "4") {
        window.location = "4.html";
        }
    else if(lessonLocation == "5") {
        window.location = "5.html";
        }
    else if(lessonLocation == "6") {
        window.location = "6.html";
        }
    else if(lessonLocation == "") {
        window.location = "1.html";
        }
}

window.onload = function (){
    init();
    bookMark();
}

window.onunload = function (){
    end();
}
</script>

2 个答案:

答案 0 :(得分:2)

您可以使用cmi.core.lesson_location将学习者的当前位置存储在课程中。如果您需要在课程中存储更复杂的信息,如学习者当前状态,请使用cmi.suspend_data。这些都是读/写属性,您可以在课程首次加载并连接到LMS时读取,然后导航到课程中的适当位置。

可以在“数据模型”部分下找到有关CMI属性的快速参考:http://scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/

答案 1 :(得分:2)

设置lesson_location相当于创建浏览器cookie ...您需要在课程中编写JavaScript来解析保存的字符串并使用它。

您需要在多个地方更改代码 - 您提供的代码是一个示例,用于设置您的课程在初始化时完成。这不是你真正想要的。

这是关于开始课程和寻找书签的快速入门书:

var bookmark, initialized, status;
var scorm = pipwerks.SCORM; //shortcut for easier typing

function jumpToPage(url){

    //write some code that navigates to the specified url

    //Save whatever URL was just used as the bookmark
    //each time the function is invoked.
    scorm.set("cmi.core.lesson_location", url);

}

function init(){

    //the default URL in case no bookmark is found
    //or when course is launched for first time
    var url = "url_of_first_page.html";

    initialized = scorm.init();

    if(!initialized){ alert("Course failed to initialize"); return false; }

    //Get the lesson status from the LMS
    status = scorm.get("cmi.core.lesson_status");

    if(status === "completed"){

        //You're already done, get out of here
        scorm.quit();
        return; //exit init() function

    } else if(status === "ab-initio"){

        //this is the very first launch, no bookmark will be found in LMS
        //do nothing

    } else {

        //Check for a bookmark
        bookmark = scorm.get("cmi.core.lesson_location");

        //If a bookmark is found, use its value as the target URL
        if(bookmark){ 
            url = bookmark;
        }

    }        

    jumpToPage(url);

}


window.onload = init;