Writing a SCORM variable via Javascript trigger at course launch regardless of Resume

I'm going to write the language the user took my Storyline course in to my LMS with a JavaScript trigger:

var lmsAPI = parent;
lmsAPI.SetLanguagePreference("es_LA");

It works great, I end up with the parameter cmi.student_preference.language in my LMS with a value of es_LA.  A question for myself is, when should I write this?  Should I write it from every screen (for example) so I always know what the last-viewed language is? (I'm creating special multi-language SCORM packages with a separate .story file for each language; the user picks the language in our LMS and the LMS sends them to the appropriate language but uses the same tracking data regardless of language, a whole different conversation.)  I'd prefer not to have to send this data every time a slide gets loaded (more LMS communication, hundreds of screens multiplied by thousands of users.) I'd rather execute this trigger once, when the course launches regardless of whether or not the user has been in the course before. For example I could put the trigger on the first screen but if the user launches a different language and resumes to a screen other than the 1st, the language won't get updated, thus it seems I need to have the trigger fired from every screen (by putting the trigger in all master slides).  So conceptually what I'd like to do is trigger my JavaScript when the course launches (whether the user is Resuming to last-visited screen or not, regardless of what slide they go to first when launching the course), not when a slide loads.  Is there some method for doing this?  I need y'all to help me think outside of the limited box of my Storyline knowledge.  (No, I can't use the sort of method where I store the last screen myself as a variable, always return the user to the same screen to catch this trigger, then immediately send them to the real last-viewed screen because that sort of method performs unacceptably in HTML5 on iPad.)

Thanks,

David

4 Replies
David Kelling

Thanks, but that doesn't address my situation. The user can launch the course in English, go to screen 5, and exit.  Then the user can launch the course in Spanish and since we're using the same suspend data generated in the English viewing, they'll be asked if they want to resume to screen 5 in Spanish. If my language got written to the LMS as "en_US" on the first visit to the course when they viewed the first screen in the English version, when the user launches the Spanish version (different .story file, different SCORM package) if they resume to screen 5 they won't have viewed the first screen in Spanish where the trigger is to write "es_LA" to the LMS.  So that is why my current knowledge suggests only that I must send the language to the LMS on every screen.  Is there a way to (for lack of a better way of saying it) trigger a JavaScript when the course launches instead of when the user visits a slide?  Thanks

David Kelling

Great! How do I do that? I have no idea what you are talking about.  I assume when the user closes the browser window in which the course was launched by the LMS there must be something like an onUnload that wraps ups the SCORM session; how do I add something to that event in Storyline?  Thanks