diff --git a/_sources/lectures/TWP52_en.rst b/_sources/lectures/TWP52_en.rst index e19079513c..b2c46915e8 100644 --- a/_sources/lectures/TWP52_en.rst +++ b/_sources/lectures/TWP52_en.rst @@ -305,7 +305,8 @@ Review + OptionMenu() - +.. raw:: html + :file: ../../scorm_package/chapter1.html .. disqus:: :shortname: pyzombis diff --git a/_static/APIWrapper.js b/_static/APIWrapper.js new file mode 100644 index 0000000000..4f1753ddb1 --- /dev/null +++ b/_static/APIWrapper.js @@ -0,0 +1,45 @@ +// SCORM API Wrapper +var findAPITries = 0; +var API = null; + +function findAPI(win) { + while ((win.API == null) && (win.parent != null) && (win.parent != win)) { + findAPITries++; + if (findAPITries > 7) { + return null; + } + win = win.parent; + } + return win.API; +} + +function getAPI() { + var theAPI = findAPI(window); + if ((theAPI == null) && (window.opener != null) && (typeof(window.opener) != "undefined")) { + theAPI = findAPI(window.opener); + } + if (theAPI == null) { + alert("Unable to find an API adapter"); + } + return theAPI; +} + +function initializeAPI() { + API = getAPI(); + if (API != null) { + API.LMSInitialize(""); + } +} + +function terminateAPI() { + if (API != null) { + API.LMSFinish(""); + } +} + +function setProgress(progress) { + if (API != null) { + API.LMSSetValue("cmi.core.lesson_status", progress); + API.LMSCommit(""); + } +} diff --git a/_static/SCORMFunctions.js b/_static/SCORMFunctions.js new file mode 100644 index 0000000000..e94380937f --- /dev/null +++ b/_static/SCORMFunctions.js @@ -0,0 +1,40 @@ +// SCORM Functions +function loadPage() { + initializeAPI(); + console.log("SCORM API initialized."); +} + +function unloadPage() { + terminateAPI(); + console.log("SCORM API terminated."); +} + +function loadChapter(chapter) { + loadPage(); + + var completionStatus = API.LMSGetValue("cmi.core.lesson_status"); + + if (completionStatus === "completed") { + document.getElementById("completion-status").innerText = "This chapter has been completed."; + document.getElementById("complete-button").style.display = "none"; + } else { + document.getElementById("completion-status").innerText = "This chapter has not been completed."; + document.getElementById("reset-button").style.display = "none"; + } +} + +function completeChapter(chapter) { + setProgress("completed"); + alert(chapter + " completed! Progress recorded."); + document.getElementById("completion-status").innerText = "This chapter has been completed."; + document.getElementById("complete-button").style.display = "none"; + document.getElementById("reset-button").style.display = "block"; +} + +function resetChapter(chapter) { + setProgress("incomplete"); + alert(chapter + " reset to incomplete."); + document.getElementById("completion-status").innerText = "This chapter has not been completed."; + document.getElementById("complete-button").style.display = "block"; + document.getElementById("reset-button").style.display = "none"; +} diff --git a/_templates/layout.html b/_templates/layout.html index 00a8807a4f..68b4225437 100644 --- a/_templates/layout.html +++ b/_templates/layout.html @@ -275,6 +275,8 @@ {% endraw %} {% endif %} + + {% endblock %} {# Silence the sidebar's, relbar's #} diff --git a/scorm_package/chapter1.html b/scorm_package/chapter1.html new file mode 100644 index 0000000000..75a19d5582 --- /dev/null +++ b/scorm_package/chapter1.html @@ -0,0 +1,16 @@ + + +
+ + +Checking completion status...
+ + + + diff --git a/scorm_package/chapter2.html b/scorm_package/chapter2.html new file mode 100644 index 0000000000..9ebae3f91b --- /dev/null +++ b/scorm_package/chapter2.html @@ -0,0 +1,15 @@ + + + + + +Complete this chapter by clicking the button below.
+ + + diff --git a/scorm_package/imsmanifest.xml b/scorm_package/imsmanifest.xml new file mode 100644 index 0000000000..8fed7e6a0c --- /dev/null +++ b/scorm_package/imsmanifest.xml @@ -0,0 +1,38 @@ + +