Intro
Today's posting is about advanced actions but not complicated. This is why this is very well suited for users who want to start with advanced actions and variables. I'm trying to answer a question from the Captivate user forum: "I would want the total time taken for the quiz to be displayed...".
Example
Play with this example to see a possible solution, realized with some advanced actions. After the introduction slide the time spent on each question slide will be stored and displayed on the next slide. The total time spent on the quiz will be visible as well. Both will be showed in seconds. On the score slide the total time of the quiz is displayed, either in seconds or in minutes. If it is a really long quiz, it would also be possible to display in hours of course :-). I will explain briefly the variables and advanced actions used. In the Gallery you'll find a screenshot of each advanced action.
Variables
I used the system variable cpInfoElapsedTimeMS and created some user variables:
- v_start will store the start time for a question (in milliseconds), reused on each question slide
- v_end will store the end time for a question (in milliseconds), reused on each question slide
- v_duration will store the time spent on a question (in seconds), reused on each question slide
- v_total will store the time spent on the quiz so far (in seconds)
- v_help is a variable used to transform the total time to minutes
- v_minutes will store the total time spent on the quiz in minutes
On the second question slide, a text caption, labeled InfoTime shows the value of the variables v_duration and v_total. This Text Caption is set to display for the rest of the project and will be hidden by an advanced action on entering the Score slide. For the moment there is no possibility to have a 'mask' to display the time, sometimes you'll see a lot of decimals.
Advanced actions
I have included all the advanced actions as screenshots. Have a look at the image gallery. There are 3 advanced actions:
1. SetStart
This standard action is executed on entering the first Question slide. It populates the variable v_start with the value of the system variable cpInfoElapsedTimeMS at that moment.
2. StartNext
This standard action is executed on entering all Question slides with the exception of the first one. There are more activities here:
- the user variable v_end gets the value of the system variable cpInfoElapsedTimeMS at that moment;
- the variable v_duration is calculated from v_end and v_start; it is in milliseconds after this statement
- the variable v_duration is translated to seconds
- the variable v_total is recalculated (in seconds)
- the variable v_start is reset to the value of the system variable cpInfoElapsedTimeMS at that moment to start the chrono for this question
3. EnterScore
This conditional action is triggered on entering the score slide. It has 2 decisions, the first Standard is really a standard action, the second Minutes is a conditional action. If you are puzzled about this combination of standard and conditional action, please check this article Combining Standard and Conditional in one Advanced Action.
3.1 Standard decision
- hides the Text Caption TimeInfo (that was displayed for rest of project)
- repeats the statements 1-4 of the action StartNext; we do not need 5, because there is no question slide anymore
On the score slide you have 2 Text Captions to show the total time spent on the Quiz; initially both are invisible:
- YesMinutes shows the total time in minutes and will be set to visible if the total time is greater than 60 sec; you'll find this in the Then part of this decision
- NoMinutes to show the total time in seconds, will be set to visible if total time is smaller than 60 sec; you will find this in the Else part of this decision
Let me know if you disliked or liked this explanation. And if you have more questions, do not hesitate...