根据您运行的 SCORM 版本,您需要从https://scorm.com/scorm-explained/technical-scorm/run-time/api-discovery-algorithms/复制并粘贴代码
完成此操作后,对于 sCORM 1.2
var API = getAPI();
if (API) {
var studentName = API.LMSGetValue("cmi.core.student_name");
console.log(studentName);
}
else {
console.log("Failed: Did you run this course directly and not via the LMS?");
}
对于 SCORM 2004
getAPI(window);
if (API) {
var studentName = API.GetValue("cmi.core.student_name");
console.log(studentName);
}
else {
console.log("Failed: Did you run this course directly and not via the LMS?");
}
代码略有不同。您最好使用https://pipwerks.com/laboratory/scorm/api-wrapper-javascript/来查找 SCORM API 并使用此包装器来处理版本中的细微差异。
至于课程名称 - 如果您正在运行特定的课程,您已经知道该课程的名称,因为您当前正在运行它。