simplify-scorm icon indicating copy to clipboard operation
simplify-scorm copied to clipboard

Question: back button api lost connection

Open fabmesto opened this issue 3 years ago • 4 comments

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.

fabmesto avatar Mar 05 '21 12:03 fabmesto

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!

dipakdas99 avatar Apr 15 '21 06:04 dipakdas99

Hi @dipakdas99 Example url here: https://www.netedit.it/scorm/index.html

fabmesto avatar Apr 20 '21 09:04 fabmesto

@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.

xob avatar Apr 20 '21 15:04 xob

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 ?

vivaneo avatar Dec 26 '23 16:12 vivaneo