simplify-scorm
simplify-scorm copied to clipboard
Question: back button api lost connection
hi, i would like to understand if my code is correct for start lesson:
<a id="a-apri-lezione" href="javascript:void(0);" onclick="scorm.start(); return false;">
STAART
</a>
<iframe src="" style="border:0px #ffffff none;" id="iframescorm" name="myiFrame" scrolling="no" frameborder="1" marginheight="0px" marginwidth="0px" height="650px" width="100%" type="text/html" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" mozallowfullscreen="mozallowfullscreen"></iframe>
<script src="/scormAPI.js"></script>
<script>
var scorm = {};
scorm.url = 'MY_LESSON_URL';
scorm.student_id = 'MY_ID';
scorm.student_name = 'MY_NAME';
scorm.start = () => {
window.API.cmi.core.student_id = scorm.student_id;
window.API.apiLogLevel = 4;
document.getElementById("iframescorm").setAttribute("src", scorm.url);
}
</script>
This code works, but when user click back button API lost connection with lesson. To restart everything I am forced to refresh browser.
Hi @fabmesto, What is the scorm URL? Could you please guide me on that? I am assuming you've uploaded an uncompressed zip file in the s3/cloud storage bucket is that right? Thanks in advance!
Hi @dipakdas99 Example url here: https://www.netedit.it/scorm/index.html
@fabmesto Looking at your example with the Chrome Console open, you can see that when pressing the Back button on the browser, the training gets unloaded and correctly terminates the SCORM API (which it is supposed to do; when a training is unloaded, it should terminate the API). Once the API is terminated, it does not allow being initialized again.
One solution could be to listen to the Terminate event, and call the API's reset function to allow it to be used again. See the Resetting section of the readme.
Hi,
I don't know if the repository code still works but I can't do it:
I have the following error:
Uncaught TypeError: Cannot set properties of undefined (setting 'ScormAPI')
at scormAPI.js:8:33
at scormAPI.js:691:3
Can you help me ?