The Score button in ToolBook will provide you with the ability to show the user their current score. For many of you this will be enough to meet your needs. Others will want to go a step further and perform different actions depending on the achieved score.
To do this you will need to use the Actions Editor within ToolBook Instructor to analyze the score, and then set up some conditional behavior to occur based on that score. You will need to be familiar with the Actions Editor in order to implement this type of solution.
In this demonstration the behavior will be as follows:
On your summary page, add a Score field. You will find one of these in the Scoring and Tracking category of the catalog.
In order to tell the use they have passed or failed, two fields will be used. Informally I'll refer to these as the Pass Text Field and Fail Text Field .
You'll need to add two text fields to your summary page for this purpose.
Finally the Summary Page needs to be configured so that whenever it is Reset, the Pass and Fail text fields will be hidden (Note that a page is reset automatically immediately before it is exported to DHTML format - as well as when you do a Save of your book and choose to do a Reset type Save).
In ToolBook there is no built-in command in the Actions Editor to calculate the score and have that score be available to you as a percentage. Instead ToolBook only makes the score available to you as the number of points achieved.
However, in our example we need to be able to judge the user based on Percentage. In order to do that, we have to devise a workaround, and that is as follows:
This workaround suffers from an interesting problem. When you ask ToolBook to Score your quiz, ToolBook will display that score within the Score field once it is finished calculating it. This calculation process is extremely fast in a Native ToolBook application, however in DHTML format, this can take several seconds to execute within a browser. This means we need to be careful to not try to read the Score value, out of the Score field, until after ToolBook has actually put the score in there.
The solution is to use an Action Timer to periodically check the field to see if it is still empty. When it is no longer empty, the score must now be there, and we can proceed with analyzing the score.
The Actions Editor logic to score the book, as well as the conditional logic will both be placed in the Action Timer.
By configuring the Action Timer in the manner described above an On media timing event will be triggered every 500ms. Step 5 will take care of handling this event.
In order to get ToolBook to display the score in the Score field, it is necessary to tell ToolBook to Score the quiz. Although there is a Score This Quiz button in the Scoring and Tracking category of the catalog, this demonstration will not be using that button. Instead the Score action within the Actions Editor will be used.
The goal is to have the score shown to the user as soon as they enter the Summary page. As such we need to add logic to the On Load Page event for the Action Timer.
The conditional logic will also be added to the Actions Editor for the Action Timer. The logic will be under the On media timing event.
Every time the On media timing event is triggered (every 500ms) ToolBook will check to see if the Score field is populated with the score, and if it is then it will show the correct Pass or Fail text field.
The only line in this code which will likely look confusing is the one which says:
set myScore to characters 8 to (charcount(text of field "Score") - 1) of text of field "Score"
Although it is not necessary for you to understand how it works since it works without any modifications needed, if you are curious, here is what it is doing:
The Score field will be holding a value such as: Score: 78%
Although this looks great for display purposes it does us little good when what we need is just the number...the 78.In order to extract out just the number and leave the rest behind we need to extract characters (8) through (one less than the number of characters in the string). This tosses out the % and also the "Score: ", leaving just the raw number which we can use for computational purposes.
Created with the Personal Edition of HelpNDoc: Full-featured EBook editor