Widgets and Custom Questions - part 2: where I described the use of the TextArea widget
- Extended TextArea Widget - more functionality: where I used a widget from Jim Leichliter to be able to reset the Short Answer question.
Widgets were meant for SWF-output only, including the widget by Jim (this one, he has some widgets that are also compatible with HTML5). Since Captivate 7 the TextArea widget got a companion, the 'Scrolling Text Interaction'. Don't be confused by the name, it is essentially the same widget, but compatible with HMTL5 output.
In this post I will explain the conditional advanced action, and also point to another well-hidden gem, only in Captivate 8: the Captivate team has now embedded the variable control in the Scrolling Text Interaction! Don't tell that they are not listening to users :) What was only possible with the extended TextArea widget by Jim in previous versions, can be done with the supplied Scrolling Text Interaction.
Translated: when the answer is submitted, the conditional action should show a Positive feedback when:
- the three first words are included in the text
- the last two words are not included in the text
Because of the missing operator 'does not contain' this cannot be done with one decision, one IF combination using AND, which explains why the user was stuck.
Solution 'Divide et Impera'
- Check first if all the conditions are fulfilled and store that result in a Boolean variable. There are a lot of Booleans in Captivate: variables that can have only two values, No/Yes, 0/1, False/True. I will mostly choose for the 0/1 combi. I created a user variable v_TA_OK with a default value of 0 (meaning all conditions are not yet OK)
- Show the appropriate feedback based on the value of that Boolean.
- all statements are executed in sequence and
- all decisions are executed in sequence
- the action is not stopped when a positive condition is met
This has led to a conditional advanced action with three decisions.
Watch this movie, created with Captivate 8, customized theme 'Flat', using custom shape buttons (one is a freeform shape) with three states and the new Scrolling Text Interaction.
Advanced actions - variables
v_one, v_two, v_three to store the words (can also be more words in one variable, but they'll have to appear in that sequence) that have to be included in the answer
v_notOne and v_notTwo for the words that are forbidden in the answer
v_Answer to be associated with the TextArea or Scrolling Text that will store the value typed in the answer
v_TA_OK: the Boolean variable explained above; default value = 0, will only be set to 1 if all conditions result in correct.
- v_null: an empty variable that is needed to create conditions for the other advanced actions (as the ones that check if all word fields have been filled); I will not explain those actions here; more info: Where is Null?
Conditional action Check_Short
This action is triggered by the Submit button on the Short Answer slide. This was the answer to the problem presented at the beginning. I will not explain the other advanced actions like the one triggered by the Reset button or the different actions On Enter for slides to reset the situation to normal. The action has 3 decisions:
This decision checks if all the imposed words are present in the Short Answer, using the operator 'contains', with AND combination. If that is the case, the Boolean v_TA_OK will be set to 1.
The not-allowed words are checked with this decision, using again the operator 'contains' but this time in an OR combination, because even if only one of those words is present, the negative feedback has to appear. If any of the words appears, the Boolean v_TA_OK is reset to 0. It is very important that this check only occurs after the first decision! After this second decision (in this case) all conditions have been evaluated and the Boolean variable v_TA_OK has its final value, will be used in the last decision
Only this last decision has also an ELSE part, as you can see in the total view of this conditional action:
As I explained in the last slide of the movie, because of the stack order, where an Interaction always is on top even though it is not on top in the Timeline, I had to hide the Interaction to be able to show the Feedback groups, because they were in the same location. Here is the Timeline of this Short Answer slide:
You see that the Interaction (indication is Widget on timeline) is not on top. The Next button is not on this slide, but on the first slide and timed for the rest of the project. That shape button is hidden/shown when necessary.
I wanted to emphasize the importance of sequence by this blog post, and the fact that Captivate will always evaluate all conditions/decisions. This is not always the case in normal programming languages. Trying to explain:
- The first decision is positive, variable v_TA_OK will be set to 1, but there will not be ending of the condition
- If the first decision is negative, variable v_TA_OK will remain at 0, no need to include an ELSE part. This means that the variable can never be set to 1 anymore, but the second decision will nevertheless be checked by CP.
- If both negative words are not included, nothing happens with the second decision, v_TA_OK will keep its value 1 or 0 depending on the result of the first decision, because there is no ELSE part.
- If one of both negative words are included, the second decision will reset v_TA_OK to 0, whatever its value was at the end of the first decision