Specifying what should happen when the user clicks the browsers x instead of content navigation in ToolBook
August 28 2008: updating a few things in the article after it was originally posted.
August 31 2008: updated the sample again; The sample file now includes an exit button which calls the same code as clicking the x.
November 12 2008: updated the article based on user feedback.
This sample file demonstrates how one can control if the user clicks the window x rather than the navigation provided within the content.
As of ToolBook 2004 SP2 and on ToolBook offers some level of control over what happens when the user clicks the x.
ASYMI_ActionOnClose of this book="complete"
ASYMI_ActionOnClose of this book="discard"
ASYMI_ActionOnClose of this book="suspend"
(For all the details see http://kb.sumtotalsystems.com/community_kb_tb_display.asp?id=Q111946064800035)
The problem with this approach
There are two problems with this:
- A user is not likely to be aware that their course is not marked as completed (the norm is to mark the course as incomplete unless the user clicks an exit button on the last page)
- There is no way to change how the course is closed (i.e. mark complete, incomplete or discard) on a page by page basis, or let it depend the score etc.
How to dynamically determine if a course is marked as completed or incomplete in the LMS when the learner click the browser X
This sample demonstrates an approach which will mark the course as incomplete unless you answer the question on the next page correctly. Note this sample will have a series of alerts to let you know what is going on. In a real life environment these should obviously not be there. The sample does not require use of version dependant obfuscated code nor does it require post HTML export edits. In other words it should be fairly safe to build something like this into a template
The sample works like this:
- ToolBook's external JavaScript Feature to call a JavaScript function on the book's on load book handler, which
- Use the in the DOM to Attach an event to the onbeforeunload event handler on the ToolBook HTML Window
- The onbeforeunload event handler calls back into ToolBook to notify that the window is about to close.
- The Action Editor call back handler is a shared action called tc_exitcallback (in the first version it was an action Method on the background called tc_exitcallbackmethod). The handler scores the book and if the score is larger than 0, the course will be marked as completed - if not it will be marked as incomplete. (It would not be difficult to use other conditions instead.)
Try a live version of the sample. (The live version is still the first version of the sample as there is very little difference between the versions at runtime. The main difference is in the implementation.)
Download the source files for the sample for ToolBook 9. Note that all 3 versions of the sample is there.
A few things to note
While the code is not depending on calling obfuscated code this does require obfuscation to be turned off when exporting. Based on userfeedback this is the most likely cause of problems when using this, You will see errors like: "Object does not support this property or method (line number 27)” error message.". NOTE: You will find the “Obfuscate exported JavaScript from Actions Editor” option when using the “Expert Mode” in the ToolBook Web Specialist.
I write "As with most my samples this doesn't work with popup windows, not because it cant be done - but because I haven't had time/inclination to do it." - well... User feedback from suggests this DOES work with popup windows. Thanks Jamy for sharing your findings
I have tested this in IE7 and Firefox and it works fine.
I have published to SCORM 1.2 and have successfully tested it in the ADL SCORM testsuite, and as this uses ToolBook's built in Action Editor exit actions it should work in most/all SCORM compliant LMS's, but I recommend testing it just to make sure.
Let me know what you think by leaving comments below