Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Override Captivate's SCORM output onUnload with JS?

Community Beginner ,
Apr 25, 2018 Apr 25, 2018

Using Captivate 2017 and publishing as HTML5.

I'm trying to replace Captivate's built in SCORM bookmarking using custom JS calls to set and commit information: SCORM_CallLMSSetValue("cmi.core.lesson_location", window.cpAPIInterface.getVariableValue('highestTopic')) [highestTopic is an integer)

on certain slides, and this works wonderfully as long as the user closes the activity using the Exit button on the slide after the quiz results, which includes the following JS:

SCORM_SetBookmark("");

SCORM_objAPI.LMSSetValue("cmi.core.exit", "logout");

SCORM_CallLMSCommit();

SCORM_objAPI.LMSFinish('');

However, if the user closes the window using the parent window's controls, Captivate performs its own calls that overwrite my information (the custom cmi.core.lesson_location data) onUnload of the window. It overwrites my integer information with a string of the slide name that was showing at the time the window was closed.

Is there any way to override or disable this so that my information is preserved? I've tried digging through the JS created by Captivate on publishing the SCO, but I have had no success in finding the correct line of code where this is happening. If I add my own onUnload to the body of the index_scorm page, set and commit my data, then terminate the SCORM connection, will that override Captivate's onUnload, or will theirs beat mine to the punch?

1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Apr 26, 2018 Apr 26, 2018

Finally worked out a solution, for anyone else who comes along with a similar need. Note that this all involves SCORM 1.2, but I'd bet the same applies to 2004 - just the SCORM variable names would be different.

Captivate will always pass the last slide's label (URI encoded) to the LMS via SCORM's cmi.core.lesson_location variable if the Captivate activity's window is closed. It doesn't seem to matter if you have Never Send Resume Data in the advanced Quiz preferences or not. You can override thi

...
Translate
People's Champ ,
Apr 25, 2018 Apr 25, 2018

Not sure if yours would execute if the unload was already called.

I think you best bet is to modify the set bookmark function in the scormdriver .js.

I don't know how you are setting "'highestTopic', but you should be able to modify the function to:

function SCORM_SetBookmark(strBookmark) {

    WriteToDebug("In SCORM_SetBookmark strBookmark=" + strBookmark);

    SCORM_ClearErrorInfo();

    

     if ( window.cpInfoCurrentSlide +1 < window.highestTopic )

     {

         return false;

     }

     else

     {

     return SCORM_CallLMSSetValue("cmi.core.lesson_location", strBookmark);

     }

}

cpInfoCurrentSlide is zero based and the bookmark is set on enter of a slide, so if you are on slide 10 and you set your variable to 10 on side enter it will set the bookmark, if you go to side 9 it will not.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 25, 2018 Apr 25, 2018

Yeah, I just tested it out of curiosity, and their unload gets called first. So that's not an option.

Tweaking SCORM_SetBookmark might be a solution, or at least lead me in the right direction. It's complicated in that I have a subset of slides that I need to restrict SCORM bookmarking to. This subset also contains interstitial Knowledge Check slides that need to be ignored as far as bookmarking, so I can't rely on cpInfoCurrentSlide easily. This gives me something to think about though.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 25, 2018 Apr 25, 2018

If you use slide titles it would be easy to set it up as all of the titles are in an array. You could ignoer bookmarking if the title had an indexOf "knowledge check" else check to see the current bookmarks location in the array and if it's less than the current slide, don't bookmark.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 25, 2018 Apr 25, 2018

I'm leaning that way. Excluding slides isn't particularly difficult, but sticking with Cp's method of storing bookmarks won't get me where I was hoping to go.

I forgot to mention that my whole point in all of this was to ultimately replace the ugly Captivate dialog that appears if there is a bookmark when a SCO is restarted with a customized option to resume/restart on Slide 1 based on stored SCORM info from a previous session. So falling back on Captivate's SCORM bookmarking isn't ideal, but it may be the only way forward unless I want to completely reinvent the wheel.

I have managed to kill the dialog on a repeat SCO session launch by setting SCORM_SetBookmark to null on the entry of every slide. Maybe I can pass the slide info to a different SCORM variable and use it instead.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 25, 2018 Apr 25, 2018

In my experience, that ugly dialog comes from a cookie that is set when self-paced learning is checked in the TOC settings.

I use sweet alert to generate a resume dialog. Captivate stores progress in the suspend_data and also in the lesson_location.

The very first character of the suspend data is a letter that corresponds to the current slide, then there are sequences that designate all of the slide and whether they have been completed.

So if you get the suspend data and the first letter is "c" you are on slide 3.

Captivate always returns to the point at which you exited based on the lesson_location, so you need to change the way it bookmarks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 25, 2018 Apr 25, 2018

This is interesting. You're right about the dialog. I had forgotten that I had unchecked Self-paced learning, so that was why it wasn't coming up any more. I stripped out the clearing of the SCORM bookmark on each slide, but Captivate does not appear to provide an option to (or just automatically) resume from the previous location on a new session without the TOC self-paced option.

I'll need to create my own dialog then, and use the stored info in lesson_location and/or suspend-data as references. I'll also need to do as you suggested and validate/modify the bookmark values before they are pushed to lesson_location in the scormdriver script.

Thanks for your help and insight.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 25, 2018 Apr 25, 2018

Also, I'll have to do more research on the suspend data, as I just tested my SCO, and if I close the window during any slide prior to the quiz at the end, nothing gets stored in cmi.suspend_data. The LMS is showing just a 0 for that data. Lesson_location is showing the actual slide title, but with %20s replacing all the spaces.

Now I have an additional puzzle to work out, as Captivate doesn't appear to be comitting the SCORM info until the whole SCO is either closed with the window controls or exited with the button on the post-results slide. I'll hammer that out on my own though.

Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 25, 2018 Apr 25, 2018

That happens depending on the LMS since the session isn't terminated correctly and the type of exit is not set so it doesn't save the data.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 25, 2018 Apr 25, 2018

*sigh* I need to be more thorough.

If Never Send Resume Data is checked in Cp (it was, in my project), then no suspend_data is generated, which explains why I was seeing a 0 value for it in the LMS even when the suspend state was being set correctly. Unchecking it resulted in the sea of data committing on each slide, and the users place is automatically resumed on a restart of the SCO. in the future, I may attempt to construct a dialog that gives the user the option to start over from the beginning, but for now this will do.

The only hitch is that Cp resumes exactly where the user closed out - even in the middle of the quiz, and it seems the score (number of correct answers in the previous session, etc.) is also preserved in the suspend_data dump. Now to build checks that will redirect users from slides I don't want them to resume from.

Anyway, I greatly appreciate your help today.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 26, 2018 Apr 26, 2018
LATEST

Finally worked out a solution, for anyone else who comes along with a similar need. Note that this all involves SCORM 1.2, but I'd bet the same applies to 2004 - just the SCORM variable names would be different.

Captivate will always pass the last slide's label (URI encoded) to the LMS via SCORM's cmi.core.lesson_location variable if the Captivate activity's window is closed. It doesn't seem to matter if you have Never Send Resume Data in the advanced Quiz preferences or not. You can override this through in-Captivate Javascript actions on Close/Exit buttons in your project, but lesson_location will always be reset every time your SCO is launched.

TLCMediaDesign is absolutely correct that Captivate uses both cmi.core.lesson_location AND, more importantly, cmi.suspend_data to handle automated SCORM bookmarking. Unfortunately, cmi.suspend_data has a hard limit of 4096 characters and Captivate writes a HUGE amount of data to this variable if Never Send Resume Data is unchecked (i.e. you want Captivate's automatic SCORM bookmarking). It can easily overrun this limit and you can end up with strange results - even breaking the bookmarking altogether.

If you check Never Send Resume Data, Captivate will still pass information via SCORM (such as lesson_location), but NOT to cmi.suspend_data. cmi.suspend_data will always hold a value of zero (the default SCORM value). So, if you want to store and use your own SCORM bookmarks, you can set a custom value for cmi.suspend_data (you'll need to commit it each time) and it will persist, whether users use your in-activity controls to close the unit or if they close the window. You can then read in this value on each session and either automatically return the user to their last location or even build a dialog on the first slide of your project to give the users a choice to resume or start over.

This was a significantly easier approach for me than trying to work with Captivate's automatic bookmarking, modifying the scormdriver.js file for every project, and having to check and redirect the user's place if it tried to let them resume from an undesirable place.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources