..:: Blog ::..

 ToolBook Blog Minimize

Aug 26

Written by: Tomas Lund
Tuesday, August 26, 2008 2:17 PM

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:

  1. 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)
  2. 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:

  1. ToolBook's external JavaScript Feature to call a JavaScript function on the book's on load book handler, which
  2. Use the in the DOM to Attach an event to the onbeforeunload event handler on the ToolBook HTML Window
  3. The onbeforeunload event handler calls back into ToolBook to notify that the window is about to close.
  4. 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

 

Tags:

Re: Controlling the Browser Window x

Tomas,
Thank you very much for putting this on your blog - after implementation it'll finally stop those pesky users pressing the wrong button and complaining their record has been lost!

It was a pleasure to meet you at EeLS last week, thank you again for all your helpful advice!
Jennifer

By Jennifer on   Wednesday, August 27, 2008 11:14 AM

Re: Controlling the Browser Window x

Hi Jennifer

Glad to help, I too have heard lots of stories about those "pesky" users who are just using their browsers they way it was designed:-) Good we can finally do something about it.

It was a pleasure to meet you at Eels, I had a good time there.
Tomas

By Tomas on   Wednesday, August 27, 2008 12:15 PM

Re: Controlling the Browser Window x

Hi there Tomas!

I'm trying out your solution to those users that can't find the big fat Exit Lesson button and I have a question. So far, I've not gotten it to work because apparently my test book assigned a difference ID value to that one background. When I run the test and exit by closing, I get the expected dialog to tell me it is calling back to my book, but then I get an error saying 'b0' is undefined. I searched in the exported book and found the string I was looking for but it was "b42._AXF_tc_exitcallbackmethod=function(source);"

Any thoughts?
Thanks,
Peter H.

By PeterH on   Wednesday, August 27, 2008 8:21 PM

Re: Controlling the Browser Window x

I've found my problem... the book I was trying to modify to use your code, has one background, and the background ID is 19. So when I change your javascript to look for "b19...." it works.

Wonderful code Tomas... thank you for posting it! :-)

Peter H.

By PeterH on   Wednesday, August 27, 2008 10:39 PM

Re: Controlling the Browser Window x

Thanks, My pleasure Peter

I am glad to hear you have solved the problem and I probably should have been a little more clear what the b0 means (b means background, 0 means id number 0 so if your background has idnumber 1 it would be b1). I think this is the weak spot in my solution; that its dependant on the id of the current background. It wouldnt be that hard to make it slicker, but the article/sample is a proof of concept and has a few rough edges (like having to implement it if you are new to ToolBook:-)), clearly if I did this as a consulting job i would widgetize they whole thing so it would be more or less automatic.

By TomasLund on   Thursday, August 28, 2008 8:21 AM

Re: Controlling the Browser Window x

Hi Tomas,

I am using your code which I think is fantastic and helped us out with a major issue we used to have, but still I have a question for you.
The problem we had was that whenever the student clicked in the button "Exit Mark as Complete", the course in the LMS (sumtotal as well) was sent to the completed assignments... but if you tried to enter the course one more time, and aswer any activity or exam, you were able to. So then, when you finish the course for the second time with, for example, a greater grade in the evaluation, the LMS used to show you 2 different grades ( the one you got the first time (total grade in the LMS), top of the page, which is the one that the data base saves, and the "new" one, at the bottom of the page).
Now, this problem is gone if you close the course with the x button from the browser window. I dont know if you have tried this, but if you complete the course, close it from the browser x button, and then enter it again, from the group of completed courses in the LMS... even though your grade has changed, or the status of the course.. when you close it with the x button, the LMS informations maintains as the first time you completed it.

My question for you is .. do you know why if both buttons call the same functions, once you complete and re enter the course, the behavior is different? What does the x browser button does to maintain the information of the LMS and not changing it as the other button does?

Thank you so much!
Karla

By Karla on   Tuesday, June 08, 2010 11:10 PM

Re: Controlling the Browser Window x

Hi Karla
Its hard to tell exactly what goes wrong without seeing the actual file. My guess is that the problem could happen if you are using ToolBook builtin Exit Mark as complete button with actions editor code in it, is that the case?? If so then i think what happens is that the built in button will actually send SCORM data before proceeding to close the window which will trigger the same code as clicking the browser X. In SCORM a SCO can only be closed once so I think it is using the button code not the Browser X code. In order to make it work you should use a regular button, not an exit button. See the sample file for more details. Hope this explains. if not feel free to get back to me.
Cheers
Tomas

By TomasLund on   Wednesday, June 09, 2010 10:48 AM

Re: Controlling the Browser Window x

Thank you so much for the sample course. One extra thing that I would love to see is a delay (or goodbye page) when closing the course. I would love to also see the lmsfinish before everything closes down.

(Tomas Lund. deleted log as it made the whole page look messy

By terrib on   Wednesday, June 08, 2011 12:55 PM

  
 Search Minimize


  
 Quick links Minimize


  
 Blog List Minimize


 Print   


Copyright 2007 by ToolBookConsulting.com   Terms Of Use  Privacy Statement