你好,
我正在开发基于 scorm 的项目,我必须玩 scorm 2004 包。课程正在
使用 LMS 函数(LMSFinish()、commit()..etc)正常播放和捕获数据。
现在我要实现另一个功能,即恢复用户上次离开的包。
示例 cmi 数据
scoid:“1234”
数据[cmi.completion_status]:“不完整”
数据[cmi.exit]:"挂起"
数据[cmi.location]:"page3"
希望你能帮忙。
你好,
我正在开发基于 scorm 的项目,我必须玩 scorm 2004 包。课程正在
使用 LMS 函数(LMSFinish()、commit()..etc)正常播放和捕获数据。
现在我要实现另一个功能,即恢复用户上次离开的包。
示例 cmi 数据
scoid:“1234”
数据[cmi.completion_status]:“不完整”
数据[cmi.exit]:"挂起"
数据[cmi.location]:"page3"
希望你能帮忙。
通常使用“cmi.suspend_data”,因此您可以存储字符串(JSON 或其他分隔符格式,如果您想要或需要结构)来恢复答案。
'cmi.location' 有 1000 个字符供您存储一个字符串,它可以像“3”或“page3”一样简单。
您在内容演示/播放器中的导航需要能够响应有一个位置可以去。您可以使用 suspend_data 将学生的答案恢复到他们离开时的状态。
你如何决定你是否“恢复”有点棘手,因为除了 'cmi.entry' = 'ab-initio' 之外的任何东西都是简历。一些 LMS 系统返回空白或“恢复”,因此您知道在使用时获取您的“cmi.location”和“cmi.suspend_data”。
这是您必须编写的所有代码,或者您可以在我的 Wiki 上阅读一下。 https://github.com/cybercussion/SCOBot/wiki。
我对简历有一些解决方法,并且正在为我工作。我保存了suspended_data,然后检索了该数据,以便玩家恢复该位置。
Mehonder 的 Exec 解决方案
// 故事内容/user.js
let lastSlideLoaded = ''; //global variable
function Script1() {
if (lastSlideLoaded == '') {
lastSlideLoaded = 'X';
var ACT_firstID = window.globals.parsedParams["last_slide"]; //URL Argument
if (!ACT_firstID == (null || "" || "0")) {
Jump_Slide(ACT_firstID); //Set Slide
}
} else {
SetLastSlide();
}
}
function SetLastSlide() {
// send to last slide info to server//
var xhttp = new XMLHttpRequest();
var PACKID = window.globals.parsedParams["pack_id"];
var LASTID = window.DS.presentation.playerProps.attributes.CurrentSlideId;
var lastSlideURL = "/services_index.php?page=last_slide&pack_id=" + PACKID + "&last_slide=" + LASTID;
xhttp.open('GET', lastSlideURL, true);
xhttp.send();
}
function Jump_Slide(Target_Slide) {
// trigger slide change event //
g = DS.pubSub;
p = DS.events;
i = "_player." + Target_Slide;
g.trigger(p.request.NEXT_SLIDE, i, "_current")
}
@kishor-koshti 你是怎么做到的,我的意思是,告诉玩家从给定位置恢复?我能够捕获suspended_data,但我不知道下次启动该课程时如何将其设置回来。我在 javascript 上的 API 对象似乎是只读的。
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<style>
body { margin: 0; }
</style>
<script type="text/javascript">
var API = {};
function setupScormApi() {
API.LMSInitialize = LMSInitialize;
API.LMSGetValue = LMSGetValue;
API.LMSSetValue = LMSSetValue;
API.LMSCommit = LMSCommit;
API.LMSFinish = LMSFinish;
API.LMSGetLastError = LMSGetLastError;
API.LMSGetDiagnostic = LMSGetDiagnostic;
API.LMSGetErrorString = LMSGetErrorString;
}
function LMSInitialize(initializeInput) {
console.log("LMSInitialize: " + initializeInput);
// invokeCSharp("LMSInitialize: " + initializeInput);
return true;
}
function LMSGetValue(varname) {
console.log("LMSGetValue: " + varname);
//invokeCSharp("LMSGetValue: " + varname);
return "";
}
function LMSSetValue(varname, varvalue) {
console.log("LMSSetValue: " + varname + "=" + varvalue);
// invokeCSharp("LMSSetValue: " + varname + "=" + varvalue);
return "";
}
function LMSCommit(commitInput) {
console.log("LMSCommit: " + commitInput);
// invokeCSharp("LMSCommit: " + commitInput);
return true;
}
function LMSFinish(finishInput) {
console.log("LMSFinish: " + finishInput);
// invokeCSharp("LMSFinish: " + finishInput);
return true;
}
function LMSGetLastError() {
console.log("LMSGetLastError: ");
// invokeCSharp("LMSGetLastError: ");
return 0;
}
function LMSGetDiagnostic(errorCode) {
console.log("LMSGetDiagnostic: " + errorCode);
// invokeCSharp("LMSGetDiagnostic: " + errorCode);
return "";
}
function LMSGetErrorString(errorCode) {
console.log("LMSGetErrorString: " + errorCode);
// invokeCSharp("LMSGetErrorString: " + errorCode);
return "";
}
setupScormApi();
</script>
<iframe id="frm1" src="./Content/index_lms.html" style="width: 100%; height: 100%"></iframe>
</body>
</html>