Pipwerks Adapter (JS) and page refresh

321 views
Skip to first unread message

Lis Tao

unread,
May 19, 2015, 1:44:52 PM5/19/15
to elearning-technolo...@googlegroups.com
Hi all, 

I've been trying to solve this issue I've been having. I have a course that at the end allows the user to retake the quiz by simply refreshing the page. So in my code I have: 

window.onload = function(){
   initCourse
(); //the initial set up here (same as from pipwerks example)...
}

//Button (using jQuery)
$
("a.retake-quiz").on('click', function(e) {
   e
.preventDefault();
   window
.location.reload();
});

So when the it all works great when the user reaches and scores the assessment section, but when they hit the button to refresh the page. I get this error in the console: 

connection.initialize called
SCORM
.API.find: API found. Version 1.2
API
: [object Object]
SCORM
.connection.initialize failed.
Error code: 101
Error info: General exception

Could this be because the LMS was already initialized and connected on the first time, and then the refresh cut the connection? Any help or suggestions as to why this happens would be greatly appreciated. Thanks all! 

Ted Powers

unread,
May 19, 2015, 4:25:07 PM5/19/15
to elearning-technolo...@googlegroups.com
Hi Lis
I did something like this a few years ago. What is happening is what you mentioned. the course on reload is trying to re-init. You cannot do that.
You need to update your code to not initialize again. Could be done through cookies and javascript if you are needing to reload. If you are using frames then you can use javascript and a global variable to determine how the init routine can work.

Good luck!

--
You received this message because you are subscribed to the Google Groups "eLearning Technology and Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elearning-technology-and...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lis Tao

unread,
May 19, 2015, 4:38:46 PM5/19/15
to elearning-technolo...@googlegroups.com
Thanks for the reply. 

It seems that must be the case then. When I called the following inside the console, it gave me:

// Called the following it gave me this: "LMSInitialize has already been called."
scorm.debug.getDiagnosticInfo(101)

One thing that I did try was to call to terminate the connection on the `unload/beforeunload` events on the page (when the user clicks to refresh). But when I do so, when testing in SCORM Cloud, the SCO is closed automatically. Not sure if this would be the best route considering this course is going on a variety of LMS and their handling of terminating could be different for each.

Unfortunately, I'm not sure if I can use cookies, and I'm not using frames. Just a simple HTML documents. I have tried to use sessionStorage and setting a flag after the first initialization. Although, when the page is refreshed (item was storage flag removed on unload), and I didn't initialize again, I could no longer save to the LMS? Any ideas as to why this is happening still?

To unsubscribe from this group and stop receiving emails from it, send an email to elearning-technology-and-development+unsubscribe@googlegroups.com.

Philip Hutchison

unread,
May 19, 2015, 7:45:46 PM5/19/15
to elearning-technolo...@googlegroups.com
You can't terminate then restart a session. A course can only be initialized once per launch, and the API connection needs to be kept active in the main window. You will need to refresh your content either by placing it in an iframe and reloading the iframe (the most common scenario), or by reloading it via ajax.

To unsubscribe from this group and stop receiving emails from it, send an email to elearning-technology-and...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "eLearning Technology and Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elearning-technology-and...@googlegroups.com.

Ted Powers

unread,
May 19, 2015, 8:37:46 PM5/19/15
to elearning-technolo...@googlegroups.com
lis
it would be better to setup your course, in this case, inside a frame and have your frame handle the communication between the course and the LMS. 
this will allow you to navigate better with the quiz and you would not have to worry about reinitializing. 
your course would work with your javascript functions in the parent frame. this will let you set and get your status and other scorm cmi as needed. i would try that. 

Best regards 
Ted J. Powers


Sent from my iPad
To unsubscribe from this group and stop receiving emails from it, send an email to elearning-technology-and...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages