Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: back button api lost connection #40

Open
fabmesto opened this issue Mar 5, 2021 · 4 comments
Open

Question: back button api lost connection #40

fabmesto opened this issue Mar 5, 2021 · 4 comments

Comments

@fabmesto
Copy link

fabmesto commented Mar 5, 2021

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.

@dipakdas99
Copy link

dipakdas99 commented Apr 15, 2021

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!

@fabmesto
Copy link
Author

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

@xob
Copy link
Collaborator

xob commented Apr 20, 2021

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

@vivaneo
Copy link

vivaneo commented Dec 26, 2023

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants