Trapping browser closure???
May 25, 2016 12:00 AM
Hello everyone
I would like my lessons to send information to Google docs or a CGI script whenever the student ends a lesson. Of course, I encourage students to close the lesson in an orderly manner by clicking on an Exit Button to do so, but I suspect that some may choose to simply X out from the browser or simply walk away from the computer. Probably nothing much to be done if a student walks away but is there something that can be done about clicking on the X of the browser or Alt-F4? I presume that when a browser is closed it sends out a signal of some kind which could be caught by Lectora either directly or using JS (or whatever).
Any hints?
Andrew
Discussion (9)
And what if the computer is simply shut down? Or the connection drops? The only way to make a course properly complete is by placing a big red button that says "press me to complete" and threatening to deduct from learner salaries for incomplete courses ;)
On a more serious note, please look at onunload and onbeforeunload.
As Sergey said, you can catch the page exit in onbeforeunload, and then call the Lectora form submit from JavaScript.
You can do that by creating an action to submit the form, and putting it in a group (I know its only a single action, but that's how you get actions that don't have a specific trigger) You then call the action group from JavaScript by using the runGroup_ognnn(); format, where "ognnn" is the HTML name of the group.
Thank you John. I did not understand how to send the form through JS. In fact, except for what you (and Sergey) have written, I do not know where to find the information on the connection between Lectora and JS. Could you please tell me where it is (I cannot seem to find it on google or whatever)?
Thank you so much!
Funny you should say that. Actually, I DO have a big red button with a similar message (without the salary threat as I deal with students) :)
Yes I get it about onunload etc... but can I get onunload to trigger the Lectora form submission?
Or is it possible to use the Exit/Close state to trigger a Lectora form? That would be best but I cannot seem to find an action which says something like OnExit...
Thanks
undefined
I'm not sure about "onbeforeunload" but wouldn't the action be run before a page is unloaded, i.e. on every page? Couldn't the same effect be gained with a normal Lectora action added to the page or title (On: Hide)?
Tim
I put an action on the last page of my courses that communicates the completion status to the LMS. You could use comparable actions to communicate with Google Docs or whatever. If you wanted you could even have code for the Assignable Unit that runs on every page, saving some breadcrumb or other info to Google Docs (e. g. the page number, which you might not have if you aren't using an LMS). The advantage is that students do not generally close the browser before seeing the completion message on the last page.
I'm doing a webinar on JavaScript in Lectora in July, I think. Stay tuned :) Also, there's a 4-part blog on JS in Lectora that you might find helpful: http://trivantis.com/author/lectorasergey/
Thank you Sergey for the webinar and blog info. Sounds just great!
Also thanks Carl for your suggestion. The general idea is that some people may want to get out (or get tired) before the last page.
Thanks Tim for your suggestion too. I will try to investigate standard actions a little more.
"runGroup_ognnn(); format, where “ognnn” is the HTML name of the group"
what is the syntax to runGroup from Javascript in Captivate? I added the line but it got stuck at that line?
Thanks,
Discussions have been disabled for this post