0
votes

I've been running in to some trouble with HTML5 SCORM packages.

TL;DR; LMSFinish() isn't being called. x.prototype.terminate() within SCORM is also not being called which leads me to believe a problem with the package.

LMSFinish() is supposed to be called upon exit button click (and / or on window close). However console.log() and breakpoints within LMSFinish() reveal that this is not being called.

LMSInitialise is fine when the window opens, but for LMSFinish after inspecting the source inside SCORM and placing breakpoints within the window.unload() function I can see it only gets part of the way to exiting.

window.unload calls closeLms(), which in turn runs obfuscated x.prototype.terminate(). This terminate function appears to do a boolean check before calling some other functions which eventually leads to calling LMSFinish(). It never gets that far. The boolean check in x.prototype.terminate() is always false. If I set it to true in the console, some other properties don't exist and the resulting function call fails with an error.

Does any one have any idea why SCORM would fail to run LMSFinish()? The test SCORM package is simply 3 slides with no interaction.

EDIT: The only custom javascript written are the hooks for the SCORM API (LMSInitialise, LMSFinish e.t.c) These are called from the javascript within the SCORM package, as generated by whatever application the user decides to use to create it. (Articulate, Captivate e.t.c)

2
Popular issue with body unload events. Make sure window is used instead. I typically setup listeners for window.unload and onbeforeunload.Mark
Are you using custom JavaScript to handle SCORM, or code from a 3rd party tool? From your comment to Andrew below, you mention Articulate and Captivate, yet your question is written as if you're writing the JS yourself. Without a clear picture (and actual code), it's hard to provide helpful feedback.pipwerks
Apologies for not being entirely clear, I have edited the post to include a little more information. I cannot provide the package that causes the problem. I can only assume the application (Adobe Captivate) is generating the package with a setting that prevents the code execution for LMSFinish. Or something along those lines. I was hoping someone had seen this before.Simon Willan

2 Answers

0
votes

Depending on your browser and some other variables, code attached to window.unload doesn't always run.

A better approach is to save data regularly and have a save and exit button which you encourage the learner to click if they want to save their work.

You can also look at window.onbeforeunload.

0
votes

I figured this out in end. For anybody who might be having issues with SCORM not behaving as expected.

In my particular case LMSSetValue() and LMSGetValue() were only returning the things that were needed in the project. It turns out they both need to handle every value that SCORM tries to Set and Get regardless of if you use it or not.

I simple created an object as a property of window.API{} and made sure it was assigned all the values on LMSSetValue() in key value pairs, and those values were then ready for retrieval at LMSGetValue().