Skip to content

Instantly share code, notes, and snippets.

@elearningplugins
Forked from flesch/README.md
Created March 31, 2022 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elearningplugins/b5c371960e81e003ee891a4724bbef3d to your computer and use it in GitHub Desktop.
Save elearningplugins/b5c371960e81e003ee891a4724bbef3d to your computer and use it in GitHub Desktop.
Fake SCORM API

Fake SCORM API

Some courses won't work outside of an LMS. That's annoying when you just want to review a course, so drop this in to provide a fake SCORM API implementation - getAPI should then pick up this fake API.

window.API = (function(){
var data = {
"cmi.core.student_id": "000000",
"cmi.core.student_name": "Student, Joe",
"cmi.core.lesson_location": "",
"cmi.core.lesson_status": "not attempted"
};
return {
LMSInitialize: function() {
return "true";
},
LMSCommit: function() {
return "true";
},
LMSFinish: function() {
return "true";
},
LMSGetValue: function(model) {
return data[model] || "";
},
LMSSetValue: function(model, value) {
data[model] = value;
return "true";
},
LMSGetLastError: function() {
return "0";
},
LMSGetErrorString: function(errorCode) {
return "No error";
},
LMSGetDiagnostic: function(errorCode) {
return "No error";
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment