Skip to content

Instantly share code, notes, and snippets.

@unger1984
Created August 2, 2018 08:53
Show Gist options
  • Select an option

  • Save unger1984/c846c38917ab2d9ed97ea0ec20feb5c4 to your computer and use it in GitHub Desktop.

Select an option

Save unger1984/c846c38917ab2d9ed97ea0ec20feb5c4 to your computer and use it in GitHub Desktop.
SCORM 1.2 Player/Wrapper
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var API = {};
(function ($) {
$(document).ready(function () {
setupScormApi()
// TODO Write path to index file
$('#content').attr('src', "LINK_TO_SCORM_INDEX.HTML")
});
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) {
displayLog("LMSInitialize: " + initializeInput);
return true;
}
function LMSGetValue(varname) {
displayLog("LMSGetValue: " + varname);
return "";
}
function LMSSetValue(varname, varvalue) {
displayLog("LMSSetValue: " + varname + "=" + varvalue);
return "";
}
function LMSCommit(commitInput) {
displayLog("LMSCommit: " + commitInput);
return true;
}
function LMSFinish(finishInput) {
displayLog("LMSFinish: " + finishInput);
return true;
}
function LMSGetLastError() {
displayLog("LMSGetLastError: ");
return 0;
}
function LMSGetDiagnostic(errorCode) {
displayLog("LMSGetDiagnostic: " + errorCode);
return "";
}
function LMSGetErrorString(errorCode) {
displayLog("LMSGetErrorString: " + errorCode);
return "";
}
function displayLog(textToDisplay) {
var loggerWindow = document.getElementById("logDisplay");
var item = document.createElement("div");
item.innerText = textToDisplay;
loggerWindow.appendChild(item);
var height = $('#logDisplay')[0].scrollHeight;
$('#logDisplay').scrollTop(height);
}
})(jQuery);
</script>
</head>
<body style="display: flex; flex-direction: column; align-items: center; justify-content: center">
<iframe id="content" name="content" style="border: 1px solid blue; flex: 5; align-self: stretch" frameborder="0"></iframe>
<div id="logDisplay" style="flex: 1; align-self: stretch; border: 1px solid red; padding: 5px; overflow-y: scroll;
overflow-x: hidden;">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment