Are you talking about a typical web page alert box?
In SL, set a variable called Exit_Course with a default value of "False".
Execute the following JS based on your triggering action.
let player = GetPlayer();
function myFunction() { if (confirm("You are about to exit the course!")) { player.SetVar("Exit_Course",true); } else { console.log("User Cancelled Exit!"); } }; myFunction();
In SL, add an action to EXIT COURSE when the VARIABLE Exit_Course changes IF Exit_Course is equal to True.
So basically, the JS controls the variable and the variable controls the exit function in SL.
I have attempted the solution by Owen (as shown above), though this does not seem to work for me on an ipad or Safari. I have published content as web output hosted on AWS with a link that exits for most other browsers and devices, though not on ipad.
Has anyone found a solution for this?
I'm not blessed with technical ability, so any help would be much appreciated.
The request was for JavaScript which can operate a little differently from browser to browser. I love JavaScript. It can do some amazing things. But it isn't always the right tool for the job. For something like this, I would keep it simple by simply triggering a layer with your Exit message and buttons to either close the course or dismiss the warning and return to the course (close the layer). Sometimes, the simple solution is to use the built-in functionality.
Hi Owen or anyone who would like to give me a second eye,
I'm not a programmer and I had help on this. But I'm trying to setup and automatic exit course, after a user doesn't do anything for a time. I've set this to 2 mins just for the test.
The publish course would be in TinCan, but the exit course isn't executing. I'm not sure what might be wrong with the logical order of the execute is.
FYI, the JavaScript is in the master. I thought this would be the most ideal place, instead of placing at the beginning of each page. This is also where I've included the variable as example provided by Owen above.
One obvious error i noticed in your Javascript... <script> tags were in the code. They are not needed when using triggers in Storyline to execute JS. After removing that and checking the console i noticed an error that 'player' was called multiple times. That indicates your setting that variable at multiple positions whereas that is only needed once. Im gonna check it further...
Removing the let player variable i got rid of the error, but it still doesnot work. I do suspect your timer function is never called. What i often do to get things like this working...add console.log statements to your code to see if something happens...and debug that way. Also helps to see onscreen the needed variables.. 'Exit_Course' being one of them...gonna check some more...
Ah yes.. another never executing part of code... $ signs in code indicate jQuery is used. And since quite a while jQuery is not standard included in Storyline. So you either need to manually add jQuery or use Vanilla Javascript for all parts with $ in the code.
I'm hoping to pick your brain on another sample I have. Unfortunately the sample you've sent is completely revised now. Me and a programmer manage to apply a sample work around. The file attached is a stripped down version for the client.
The only pages that wouldn't automatically exit the course, after a time out, were multi layers slides. in fact, the invisible, to allow the user to continue the course also wouldn't show up.
If anyone else would like to help, would be great appreciated.
Although not perfect this one, my previous approach with a Javascript Timer does work even with layers. In fact the exit is triggered on a Slide Layer itself.
What might be missing from your sample is a timer. And i did notice some choices on Slide Layer behaviour that might cause it not to work.
However this sample works and closes the SL after a minute automatically... on any slide on any layer....
17 Replies
Are you talking about a typical web page alert box?
In SL, set a variable called Exit_Course with a default value of "False".
Execute the following JS based on your triggering action.
let player = GetPlayer();
function myFunction() {
if (confirm("You are about to exit the course!")) {
player.SetVar("Exit_Course",true);
} else {
console.log("User Cancelled Exit!");
}
};
myFunction();
In SL, add an action to EXIT COURSE when the VARIABLE Exit_Course changes IF Exit_Course is equal to True.
So basically, the JS controls the variable and the variable controls the exit function in SL.
I will give it a try... Thank you!
Hi All,
I have attempted the solution by Owen (as shown above), though this does not seem to work for me on an ipad or Safari. I have published content as web output hosted on AWS with a link that exits for most other browsers and devices, though not on ipad.
Has anyone found a solution for this?
I'm not blessed with technical ability, so any help would be much appreciated.
Regards
Tim
The request was for JavaScript which can operate a little differently from browser to browser. I love JavaScript. It can do some amazing things. But it isn't always the right tool for the job. For something like this, I would keep it simple by simply triggering a layer with your Exit message and buttons to either close the course or dismiss the warning and return to the course (close the layer). Sometimes, the simple solution is to use the built-in functionality.
Hi Owen or anyone who would like to give me a second eye,
I'm not a programmer and I had help on this. But I'm trying to setup and automatic exit course, after a user doesn't do anything for a time. I've set this to 2 mins just for the test.
The publish course would be in TinCan, but the exit course isn't executing. I'm not sure what might be wrong with the logical order of the execute is.
FYI, the JavaScript is in the master. I thought this would be the most ideal place, instead of placing at the beginning of each page. This is also where I've included the variable as example provided by Owen above.
Any help is greatly appreciated, thank you, Rob.
One obvious error i noticed in your Javascript... <script> tags were in the code. They are not needed when using triggers in Storyline to execute JS. After removing that and checking the console i noticed an error that 'player' was called multiple times. That indicates your setting that variable at multiple positions whereas that is only needed once. Im gonna check it further...
Removing the let player variable i got rid of the error, but it still doesnot work. I do suspect your timer function is never called. What i often do to get things like this working...add console.log statements to your code to see if something happens...and debug that way. Also helps to see onscreen the needed variables.. 'Exit_Course' being one of them...gonna check some more...
Ah yes.. another never executing part of code... $ signs in code indicate jQuery is used. And since quite a while jQuery is not standard included in Storyline. So you either need to manually add jQuery or use Vanilla Javascript for all parts with $ in the code.
Quite sure this is the final barrier...
This is a good resource for converting jQuery to Vanilla JS
https://tobiasahlin.com/blog/move-from-jquery-to-vanilla-javascript/
And still some errors.. 'startClock' is not defined. Gonna get it right :-)
Thank you for the detail response. I'll try my best, but some of programming is beyond me at the moment.
Rob
Working on fixing it...either today i will get a working version....else sometime this week...
Really appreciate this. I followed as far as up to last part about the JQuery, then i was lost.
A coworker also suggest to include this at the end, not sure if thi s would help,
var dialog = ngDialog.close();
Thanks again!
Rob
What you basically should do with this kind of projects... break it up in small blocks..get those working and then combine them.
Blocks would be:
1) Properly working timer. Being able to set and reset it.
2) Mouseevents. Make sure you can track any mouseevents
3) Exit course through Javascript
If you have these 3 blocks working in simple separate Storyline's. Try combining them... and only then try to do the same in the MasterSlides.
Parts work...not all...when testing locally it nicely closes the project...online not yet.. have to go now.. but here is my test file.
Hi Math, thank you so much for your help! I'll see if I can work it out with a coworker with your attached sample.
Rob
If you check my other posts you can find MouseEvents samples. Adding those and you have all the components needed.
Kind regards,
Math
Will do that Math, thank you again!
Rob
This post was removed by the author
Hi Math,
I'm hoping to pick your brain on another sample I have. Unfortunately the sample you've sent is completely revised now. Me and a programmer manage to apply a sample work around. The file attached is a stripped down version for the client.
The only pages that wouldn't automatically exit the course, after a time out, were multi layers slides. in fact, the invisible, to allow the user to continue the course also wouldn't show up.
If anyone else would like to help, would be great appreciated.
Thank you, Rob
Although not perfect this one, my previous approach with a Javascript Timer does work even with layers. In fact the exit is triggered on a Slide Layer itself.
What might be missing from your sample is a timer. And i did notice some choices on Slide Layer behaviour that might cause it not to work.
However this sample works and closes the SL after a minute automatically... on any slide on any layer....
Kind regards,
Math
Math, thank you so much again. It was the programmer who suggested the idea to make the switch. You've really help me out, thank you!!
Rob