This use case is an answer to this question on the user forum Aggregate the results of four text-entry-boxes on the same slide. I thought it to be a good illustration of one of my previous recommendations when preparing advanced actions: think about all possible situations. For that reason I'll explain two different scenarios. The example is created in Captivate 6 but can easily be transformed for 5 and 5.5. To make the rewind possible in the example, I used a third scenario that will not be explained. It is the most complicated one, because I couldn't use the system variable cpQuizInfoPointsscored in this case, that variable cannot be reset.
If you read the thread on the user forum, you'll know that four Text Entry Boxes are used to ask validated entries. Each TEB has its own Submit button, and the sequence is not imposed. The user can choose to have one or more TEB's blank, by just clicking on its Submit button. If you want to avoid blank entries, have a look at an old blog post where I explain the work flow to check that: Where is Null
When all Submit buttons have been clicked, three situations are possible:
- a Success text and a button to the Next section if all 4 answers were correct
- a Hint text with a choice between two buttons: Review or Next
- e Failure text with only a Review button
The example has only 3 slides:
- 'Questions' with the 4 entry boxes and the initially hidden text containers and buttons
Play with it to see the different situations (use the Rewind button)
Here is the cheat sheet:
- TEB1: Brussel, Brussels or Bruxelles
- TEB2: Dutch or Nederlands
- TEB3: 3 or three
- TEB4: 8 or eight
Objects on Questions slide
In the example (Captivate 6) this slide has:
- 4 TEB's with their associated variable (which I'll not use in the actions) and Submit button; the scenario to be chose depends on the number of attempts you chose here (Action accordion); I unchecked all captions in the Options dialog
- 4 Questions (Text Captions)
- Review button (used a shape from button category, added text to it): not visible, triggers simple action to jump to Review section
- Next button: not visible, triggers simple action to jump to Next section
- Three texts: Success, Hint, Failure (used shapes - added a character Sarah); not visible
Besides the variables associated with the TEB's, that will store the chosen answer, I created 5 user variables:
v_1, v_2, v_3, v_4 with an initial value of 0, will get the value 1 when the user has submitted that TEB; those variables are not necessary in the first scenario
v_total: initial value=0, will store the total number of TEB's that have been confirmed by their Submit button
For this scenario the attempts for all the TEB's are set to 1.This means that the user can click only once on the Submit button, cannot change his mind.
Events and variables
Each Text Entry Box has two events: On Success and LastAttempt. In this scenario it is possible to trigger the same advanced action TEBCheck by both events and for each TEB.
I used the variable v_total to count the number of times the Submit button is clicked, each one will only once result in an action because the attempt is set to 1.
To make it possible to check the number of correct answers, I checked 'Include in Quiz' in the Reporting accordion with score left to 1point. That way the system variable cpQuizInfoPointsscored can be used to check the number of correct answers.
Advanced Action (conditional) TEBCheck
This action has 4 decisions (see screenshots in Gallery) - ELSE is never used
Always: is a mimicked standard action, to increment v_total
TextCorrect: checks if both variables v_total AND cpQuizInfoPointsscored have the value 4 which means that all TEB's have been submitted and all answers were correct. Then the appropriate text and the Next button are made visible (I also had to make the actor SaraSmall visible)
TextHint: checks if all TEB's have been submitted (v_total =4) AND if the score (cpQuizInfoPointsscored) equals 3. In that case the appropriate text, the Next and the Review will get visible
TextFailure: checks if all TEB's have been submitted (v_total =4) AND if the score (cpQuizInfoPointsscored) is less than 3. The appropriate caption will get visible and the Review button
There is no need for ELSE, if none of the conditions is fulfilled the user can just go on submitting TEB's because in that case v_total is not yet equal to 4. Also there is no need to hide text/buttons because only one of the decisions can result in a positive answer, they are mutually exclusive.
Note: I wanted to keep this scenario as simple as possible, only one advanced action that is triggered by 8 events (Success, LastAttempt for each TEB). Real programmers could blame me for this, because for the LastAttempt, which is in reality a Failure event, the second decision TextCorrect can never be fulfilled! So for the purist: create two different advanced actions, and for the LastAttempt action you can delete the second decision, which results in 3 decisions for that action instead of 4 for the Success action I described here.
If you want to allow more than one attempt the previous scenario would not work because the value of v_total is increased with each click on a Submit button. Example: if you allow 2 attempts for each TEB, the value of v_total would result in 4 if both attempts were used on two TEB's, and that is not what you want.
Events and variables
That is the reason for using the variables v_1....v_4 that will be set to 1 each time the Submit button is clicked for the corresponding TEB. And the counter v_total will not be created by incrementing, but by calculating the sum of the 4 variables v_1...v_4. That way the value can never exceed 4.
Because the variable v_... depends on the TEB, now I'll need to create an advanced action for each TEB: CheckTEB1, CheckTEB2, CheckTEB3, CheckTEB4. For the lazy user: you can use this action both for the Success and LastAttempt event; for the purist: create a slightly different action for the LastAttempt event, in which you delete the second decision TextCorrect (see note in first scenario).
Advanced Actions (conditional) TEBCheck1 .... TEBCheck4
Those actions have the same 4 decisions as in the first scenario, even better, only the first decision (mimicked standard action) has to be changed. You have to assign the value 1 to the corresponding variable v_1.... v_4 and the variable v_total is calculated with 3 subsequent Expression statements. Remember: no functions like Sum are available, and you can use only one operator (+) in a statement, hence that sequence of Expressions.
Have a look at this Always decision for the first action TEBCheck1
Use the Duplicate function to create the similar actions TEBCheck2... 4. The only editing to be done is to change the variable highlighted in the screenshot! Nothing else has to be edited, but be sure to attach the correct action to the correct events.