首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >书签LMS,Moodle SCORM

书签LMS,Moodle SCORM
EN

Stack Overflow用户
提问于 2012-03-01 00:27:19
回答 2查看 4.4K关注 0票数 0

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

有什么想法吗?

使用scorm 1.2和Moodle 1.9:)

非常感谢

代码语言:javascript
复制
<!-- ================ -->
<!-- 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 -->
<!-- ================ -->

加载的第一个索引页

代码语言:javascript
复制
<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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-03-02 11:20:52

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

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

这里有一个关于开始课程和寻找书签的快速入门:

代码语言: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;
票数 2
EN

Stack Overflow用户

发布于 2012-03-01 02:11:03

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

有关CMI属性的快速参考可以在Data Model部分中找到:http://scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9502874

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档