[英]Bookmarking LMS, 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>
您可以使用cmi.core.lesson_location存儲學習者在課程中的當前位置。 如果您需要存儲更復雜的信息(例如學習者在課程中的當前狀態),請使用cmi.suspend_data。 這些都是讀/寫屬性,您可以在課程首次加載並連接到LMS,然后導航至課程中的適當位置時讀取。
可在“數據模型”部分下找到有關CMI屬性的快速參考: http : //scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/
設置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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.