gpt4 book ai didi

javascript - 书签 LMS、Moodle SCORM

转载 作者:行者123 更新时间:2023-11-28 16:21:21 25 4
gpt4 key购买 nike

您好,我正在寻找一种使用 JavaScript 为页面添加书签的方法,以便当用户重新打开类(class)时,它可以通过将其发送到 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>

最佳答案

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

您需要在许多地方更改代码 - 您提供的代码是一个示例,它将您的类(class)设置为在初始化时立即完成。这并不是您真正要找的东西。

以下是有关开始类(class)和寻找书签的快速入门:

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;

关于javascript - 书签 LMS、Moodle SCORM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9502874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com