I want to do some housekeeping, when my course session starts and when it ends. How can I connect a trigger to those events?
"Timeline starts" and "Timeline ends" seems to be associated with slides and not with the story as such. I believe, that even timeline events on a master slide is fired on a per slide basis.
Of course I could hook into LMSInitialize and LMSFinish in javascript, but then the export of the course gets very complicated.
Timeline start of the first slide should do this, if you have an onslide button with an exit trigger on your last slide you should also be to add other triggers before this trigger.
Thank you Phil, but after a suspend the session can start on any slide, and the user might exit the course from any slide. I'm a former ToolBook user, where I could react with action scripting to LoadBook and UnLoadBook events. Does StoryLine have similar events?
- In my js-file I initiate the variable loadHandled to false
- On my masterslide(s) I create a trigger, that executes when timeline starts. The trigger is an execute-javascript trigger that calls the function handleLoad, that is in my js-file:
function handleLoad() { if (! loadHandled) { loadHandled = true; window["onunload"]=function(){DoMyOnClose();DoOnClose();}; } }
The function will only do something when being called for the first time during a session. I can put any housekeeping into the if statement. The last statement in the if makes it possible to execute my own housekeeping, when the course session ends. I just have to create the function DoMyOnClose in the js file.
I will use this setup for persisting variables to the LMS. The handleLoad function can read the variables from say lesson_location and initiate the Storyline variables via SetVar. The DoMyOnClose function can compress the variabels into an array and write a string-version of that to the LMS.
When I try to write to the LMS in my DoMyOnClose function, I get error 7, "Cannot make calls to the LMS before calling start". I then added window["onbeforeunload"]=function(){DoMyOnClose();DoOnClose();}; to my handleLoad function, but the problem with the error is still there.
5 Replies
I'm really interested in an answer to my question. Can anyone give a hint?
Timeline start of the first slide should do this, if you have an onslide button with an exit trigger on your last slide you should also be to add other triggers before this trigger.
Thank you Phil, but after a suspend the session can start on any slide, and the user might exit the course from any slide. I'm a former ToolBook user, where I could react with action scripting to LoadBook and UnLoadBook events. Does StoryLine have similar events?
Perhaps I found my own solution:
- In my js-file I initiate the variable loadHandled to false
- On my masterslide(s) I create a trigger, that executes when timeline starts. The trigger is an execute-javascript trigger that calls the function handleLoad, that is in my js-file:
function handleLoad() {
if (! loadHandled) {
loadHandled = true;
window["onunload"]=function(){DoMyOnClose();DoOnClose();};
}
}
The function will only do something when being called for the first time during a session. I can put any housekeeping into the if statement. The last statement in the if makes it possible to execute my own housekeeping, when the course session ends. I just have to create the function DoMyOnClose in the js file.
I will use this setup for persisting variables to the LMS. The handleLoad function can read the variables from say lesson_location and initiate the Storyline variables via SetVar. The DoMyOnClose function can compress the variabels into an array and write a string-version of that to the LMS.
Any comments?
When I try to write to the LMS in my DoMyOnClose function, I get error 7, "Cannot make calls to the LMS before calling start". I then added window["onbeforeunload"]=function(){DoMyOnClose();DoOnClose();}; to my handleLoad function, but the problem with the error is still there.
Any suggestions will be most wellcome!
This discussion is closed. You can start a new discussion or contact Articulate Support.