In this article about Adobe Captivate interactivity I introduce you to the wonderful world of conditional actions. If you intend building more sophisticated interactions or learning games in Captivate, then conditional actions are the simplest way to achieve your goals. I'll explain how to create conditional actions in the Advanced Actions dialog, how to set up decision blocks, how to configure logical IF > THEN > ELSE condition statements, and much much more.
By the way, please be aware that the concepts in this article require a good overall understanding of several other areas within the overall advanced action functionality. If you haven't already done so, I recommend you also read the following articles in this series to prepare yourself for what we cover in this article:
- Introduction to Adobe Captivate variables
- Creating editing and deleting user variables
- Displaying user variables at run-time
- Understanding Adobe Captivate run-time events
- Using Single Advanced Actions
- Using Standard Advanced Actions
To begin, let me tell you why conditional actions are my all-time favorite kind of advanced action.
Why I always choose conditional actions over standard actions
In this article explaining Adobe Captivate's Standard Actions, I said that don’t personally use them in my e-learning projects, preferring Conditional Actions instead. The reason is quite simple:
Conditional actions keep my options open; standard actions don’t.
The issue here is that you cannot add conditions to a standard action to convert it into a conditional action. But you can set up a conditional action to work exactly like a standard action, and enable or disable conditions as needed. So conditional actions are more flexible.
Consider the following examples:
- Example 1 - You build your e-learning interactivity using standard actions and then later find out you really needed to include some decisions. Since you cannot add conditions to standard actions, you are forced to throw away most if not all actions you’ve built so far, and start again using conditional actions. You've wasted time and money.
- Example 2 - You build your e-learning from scratch using conditional actions, even though you don’t think you’ll need to add decisions into the mix. If it turns out your initial assumptions were wrong and you do need your actions to become conditional, then you can easily do so. The risks are lower.
My belief, based on a lot of real-world e-learning design experience, is that while standard actions end up painting you into a corner, conditional actions give you the best of both worlds. Simple as that.
"Can’t you just design your project first before you build it?"
Now perhaps you're thinking I prefer conditional actions because I don't do any up-front design work on my project. That's not true. I do spend quite a lot of time designing my interactivity before I create the advanced actions. So how could it actually happen that you do all that work and still find out partway through an e-learning project that your first assumptions about what you’ll need to do were wrong? Well, it happens to me all the time. And trust me, I’m no newbie at creating e-learning.
Some clients (and know-it-all bystanders) have the misguided notion good instructional designers and conceive an e-learning project (using storyboards or whatever), and then build it from end-to-end in one go without changing tack. In over a dozen years building professional e-learning I’ve never seen that happen. In practice you ALWAYS seem to find your initial assumptions were wrong about some aspect of the design. And somehow simple things always seem to turn out to be far more complex than you imagined they would.
It’s for precisely these reasons that I now avoid standard actions in favor of conditional actions every time I build projects with Captivate. I cannot count the number of times this habit has saved my bacon. By all means choose your own path, but don’t say I didn’t warn you.
Creating conditional actions
Now let's look at the actual process for creating a new conditional action. It starts out more or less the same as that for standard actions, but the Advanced Actions dialog looks substantially different:
- From the Project menu select Advanced Actions (or hit SHIFT + F9 keys) to open the Advanced Actions dialog. The default settings will be for creating standard actions, not conditional actions.
- From the Action Type: drop-down list, select the option for Conditional actions.
At this point the Advanced Actions dialog is reconfigured somewhat to accommodate several additional elements required for working with conditional actions. Let’s look at these extra features in turn. Firstly the IF Decision Block area, secondly the Actions area, and finally the ELSE actions area.
About decision blocks
The first change you will notice is an extra horizontal section added in the dialog header with three untitled buttons in a horizontal array. These are known as Decision Blocks. The button currently highlighted with blue text represents the block of conditions and actions you’re actually looking at in the tables directly below in the dialog. Clicking one of the other buttons jumps you to a different decision block to show its respective conditions and actions. Double-click the name of any block to overwrite and rename it to something meaningful, but since only about a dozen letters will be visible in the button, you’ll need to keep it succinct.
A conditional action must have at least one decision block, but it can potentially have dozens more. In fact I’ve had more than 30 in a single Captivate 5.5 conditional action working without issue. There does not appear to be a built-in limit. Since you can potentially have dozens of decision blocks in a single conditional action, Captivate provides a set of special controls under the buttons to manage them.
Add new decision block
To add new decision blocks, click the tiny plus button. Be aware that any new block will be added right at the very end of the line to the far right of all other decision blocks. If you have dozens of them, this can be a bit of a pain, because then you will likely need to reposition the block by moving it as described below. But this is only possible if you have Cp 7.0.1 or later.
Scrolling left or right
Since you can only see three decision block buttons at any given time, the small triangular buttons on either end of the line of decision block buttons are there to allow you to scroll horizontally left or right to access other blocks that are not currently visible. As you can see in the screenshot above, once you reach the end of the line, the scroll button is greyed out (disabled). The fact that a scroll button is black (enabled) tells you there are other decision blocks available in that direction.
Remove a decision block
To remove a complete decision block, first click the relevant button to select it then click the icon underneath the decision block names.
Duplicate a decision block (Cp 7.0.1 or later)
This feature is only available with Captivate 7.0.1 or later versions. Select one of the blocks and click the icon. The new block will be added immediately to the right of the one that spawned it, with the letters _1 added to the end of the previous name. It’s a good idea to get in straight away and change the name because in the extra characters indicating this is a duplicate may not be visible on the button, and you may inadvertently find yourself editing conditions or actions in the wrong decision block.
Reorder decision blocks (Cp7 or later)
The two small grey left and right pointing arrows directly underneath the decision block buttons allow you to move the selected decision block earlier or later in the run-time execution order. Small as it might seem, this to my mind would have to be THE most important enhancement to conditional actions since they were first introduced. Believe me. These two small buttons will save you hours of wasted time cutting and pasting condition statements or action line items.
What if you’re on an earlier version of Captivate before 7.0.1?
Users of older versions of Captivate will notice their Advanced Actions dialog does not have the extra buttons that allow you to duplicate and reorder decision blocks in conditional actions. There’s really very little you can do about this other than upgrading to the latest version of Captivate. If that’s possible, I heartily encourage you to do so because these and other enhancements would make it more than worthwhile.
However, the real fun killer for creating conditional actions in earlier versions of Captivate is the inability to change the order of decision blocks after you add them to the line. In this case, if you find that your ideas about which decision blocks you needed were a little short-sighted, and you need to add one or more at the beginning of the execution order, then you’re in for some very tedious cutting and pasting to get them there. In fact, in many cases it’s probably quicker to just create a new conditional action and start again.
Workaround for changing the order of decision blocks in earlier Captivate versions
There’s no way to foresee the future and know in advance where you’ll be wrong about something. (The guy who develops an app for that will be very rich.) So, in practice it’s quite common to discover too late in your development that you needed some extra conditions at the very front of a conditional action.
Once I learned this the hard way a few times, I developed the habit of always leaving two or three spare decision blocks at the front of every conditional action I created. I found that Captivate would generally leave them alone and not complain about them being blank. However, just to be on the safe side, I would add the following condition line to each one:
IF 1 is equal to 2
Since such a condition always evaluates to FALSE, any action statements underneath will never get executed at run-time. I usually name these unused decision blocks SPARE to make their purpose more obvious.
Using this approach, if I found later in the development cycle that I needed to add extra decision blocks to a conditional action before the others, all I had to do was use one of the spare blocks. This practice has often saved me a lot of wasted effort.
Lacking the ability to clone or duplicate an existing decision block is not such a big deal as you can easily copy blocks of condition statements or action lines from one block and paste into another using the buttons provided on the header bar of the Actions table. In fact there will be plenty of times when you need to copy such lines from one conditional action to an entirely different one.
Order of run-time decision block execution
An important point you absolutely MUST understand about how conditional actions work is that at run-time ALL blocks of conditions are executed beginning with the block shown at far left in the dialog header, and moving to the right until there are no more blocks left.
So if you have three decision blocks with condition statements and actions in each one, then at run-time the first decision block will be checked to see if its condition statements evaluate to TRUE, and if so, then its actions will be executed, otherwise no action will be taken and Captivate moves to the next block in the chain, where the process is repeated until there are no more left.
By the way, this article is an excerpt from my: Infosemantics Guide to Adobe Captivate Advanced Actions e-book. Not only does this book offer more than 200 pages of essential information for Captivate developers, it also comes with the actual CPTX files I used for screenshots when writing the e-book. You can download and open these bonus files for Captivate versions 5, 6 and 7 to see exactly how the advanced actions and interactions I explain in the book are actually set up in a real project.
About IF > THEN > ELSE conditions in Captivate
To get comfortable with conditional actions you need to understand the concept of IF > THEN > ELSE. In software programming this is referred to as a ‘construct’ and its purpose is to control the flow of what happens in the application at run-time. You can think of it as being like a fork in a river, or two doors leading out of a room. You can either go one way or the other, but you cannot do both.
Thinking about decisions in this very black or white way might feel somewhat foreign at first, but in reality we all do it every day. For example:
- You either wake up in the morning, or you stay asleep. You can't do both, right?
- You either get up out of bed in the morning, or you stay in bed.
- You either eat something for breakfast, or you skip it.
- You either go to work, or you do something else.
Expressed as IF > THEN > ELSE statements, the actions above might look something like this:
- IF wake up is equal to TRUE, THEN get out of bed, ELSE stay asleep.
- IF hungry is equal to FALSE, THEN skip breakfast, ELSE eat breakfast.
- IF weekend is equal to TRUE, THEN stay home, ELSE go to work.
So each of your decisions to perform or not to perform day-to-day actions are usually determined by whether or not some specific condition is TRUE or FALSE.
Captivate’s conditional actions dialog is really just showing a typical IF > THEN > ELSE construct:
- IF the conditions in the top of a given decision block evaluate to TRUE…
- THEN execute the action line items in the first section of the decision block…
- ELSE execute the actions in the last section of the decision block.
By the way, it’s not mandatory to use the ELSE section of a decision block. In most cases you just leave these lines blank because you only need to specify ELSE actions if something should happen when the condition evaluates to FALSE.
About condition statements
Condition statements are what differentiate conditional actions from standard actions. In a standard action all actions listed will be executed. In a conditional action, actions will only be executed according to whether their conditions evaluate to TRUE or FALSE.
A condition statement is basically a short phrase that compares one thing with another using a couple of operands either side of a comparison operator sandwiched in-between. (Relax…I explain these terms in a moment.)
To start creating a condition statement, all you need to do is double-click anywhere on one of the blank lines in the Perform action if: section of a decision block. The first thing Captivate will ask you to do is choose your first operand from a drop-down.
In the programming world, an operand is some value that logic can be applied to in order to make a decision that will control the flow of the software application. (Remember we said your e-learning module is actually a software application too?) Looking at them another way, you can think of operands as being like the nouns in a sentence. They represent things.
As you can see in the screenshot above, Captivate’s drop-down gives only two types of operands:
- Variables – These can be either system variables or user variables. Even though this is the default value in the drop-down, you still need to open the drop-down and choose variable, and then it will allow you to scroll a list of available variables to choose the variable you want to use as the operand. (Yes, I agree that the interface is clumsy. Don’t get me started about that.)
- Literals – This can be either a number or a text string. When you choose this option, you get a text box into which you type your literal value. If your literals are the numbers 0 and 1, or the text strings TRUE and FALSE, you’re really working with what programmers call Boolean values. They’re used like ON/OFF switches to enable or disable actions.
Although having only two types of operands to choose from might not seem like much to work with, in practice it actually gives almost unlimited potential for creating powerful interactivity.
Each condtion statement added to the Perform action if: section of a decision block, has a comparison operator sandwiched between two operands that are being compared to each other. Operators are like the verbs in a sentence because they do things to the operands.
Captivate offers about seven operators to choose from in the Select comparison operator… drop-down. Each one is explained below:
- Is equal to – This operator compares the two operands to determine if they match exactly. If the operands are the same, the condition will evaluate to TRUE. If the operands differ in any way, it will be FALSE. This one (or its opposite below) is usually chosen as the operator to evaluate a Boolean value in a system variable or user variable.
- Not equal to – This time the operator is looking for a difference between the operands. If they are not the same, then the condition evaluates to TRUE. If they operands match perfectly, the condition evaluates to FALSE. (See also the Is equal to operator above.)
- Is greater than – This mathematical operator compares the numeric values of operands to see if the value of the first operand is greater than the second. If so, the condition returns TRUE. If not, it returns FALSE.
- Is greater or equal to – Similar to the previous operator, but this one will also return TRUE if the operands are equal to each other, as well as if the first one has a higher value than the second. This operator is mostly used when comparing the required passing score of a quiz with the user’s current score to see if they have passed or not.
- Is less than – This returns TRUE if the first operand has a lower numeric value than the second. You could use this operator when comparing the user’s score to see if they have fallen short of a passing score for the quiz.
- Lesser or equal to – This returns TRUE if the first operand is either equal to or lower than the second operand.
- Contains – This operator is very useful as a search operator to determine whether a text string contains a word or combination of letters. For example, you could use it to find out if a user’s text entry contains a specific word or term. It will also allow you to look for a combination of consecutive number characters in a larger number. For example, in the number 1234567890 it would return TRUE if you searched for 567.
WARNING! Don’t try to use math operators on text strings
With any of the mathematical operators shown above you should always be using a number literal, or a variable that holds a numeric value, for both operands. Captivate won’t prevent you from using mathematical operators to compare text strings, but the results won’t usually make any sense, because what happens under the hood is that strings are first converted into numeric values before being evaluated. There are rules governing how a numeric value is arrived at for a text string, but the bottom line is that you’re pretty much wasting your time doing this.
How conditions control run-time interactivity
So how do conditions, operands, and comparison operators control the flow of your e-learning at run-time? The basic use-case is that you have one or more actions that must only be executed if certain conditions are TRUE.
For example, the screenshot at right is comparing the value of the UserFirstName variable with the text string “Rod” to see if they are not equal to each other, that is, they do not match.
If they do not match, then the condition evaluates to TRUE and any actions listed below the condition would be executed.
In this case, the action is to Show a text caption welcoming the user, Rod. If the user happened to be named Fred or some other name, he would not see the welcoming text caption.
Stacking up multiple AND / OR condition statements
So what happens if you have multiple conditions stacked up in the decision block? Well Captivate evaluates all conditions to determine whether the overall IF section evaluates to TRUE and the actions underneath will be executed. If the overall result is FALSE, only actions found in the ELSE section at the bottom would be executed.
By default Captivate shows four blank lines in the Perform action if: section of a decision block, but you can really add as many separate conditions as you want. If you add more than four, the section simply adds a scrollbar to accommodate them (as shown below).
Also shown in the above screenshot is the drop-down list just to the right of the words Perform action if: These options allow you to control how the decision block evaluation is made:
Perform action if: All conditions are true
This is the default option. It means that every single one of the condition lines must evaluate to TRUE otherwise the entire block will evaluate to FALSE and none of the actions will be executed.
If you choose this option, each line will show the word AND in the last column at the right-hand end. This is to indicate that the first condition AND the second condition AND the third condition etc must be TRUE.
Be aware that every extra condition line you add further limits the circumstances under which your actions will be executed. So you need to be very careful when building decision blocks with multiple AND conditions, as it’s very easy to get lost in your logic and inadvertently create conditions that will mean your actions NEVER get executed. The limitations are just too tight. (This is actually a common cause of issues reported on the Adobe Captivate Forums where advanced actions are not working.)
Perform action if: Any of the conditions true
This option means if any one of the condition lines evaluates to TRUE, then the entire block will evaluate to TRUE and the actions will be executed. So instead of being restrictive, this option is relatively loose. All it will take is one of the conditions to be TRUE and your actions will get executed.
As you can see in the screenshot below, selecting this option adds the word OR to the end of each condition line. So it’s really saying the entire block will be TRUE if the first condition is TRUE, OR the second condition is TRUE, OR the third condition is TRUE, etc.
Perform action if: Custom
The Custom option is something of an enigma. If you select this option, Captivate then allows you to choose whether each condition line is set as to AND or OR relevant to the next line in the stack. You make this selection via another drop-down in the final right-hand column. (Due to a somewhat short-sighted decision on Adobe’s part to limit the width of the Advanced Actions dialog, you have to scroll the entire decision block sideways in order to open the drop-down menu and make your selection.)
Let me warn you in advance about something here. Trying to mix and match AND with OR statements in a decision block is likely to give you headaches, if not ulcers. But, in order to have them work as you expect, the secret is in remembering that the AND/OR value in the last column defines how that particular condition line relates to the next condition line directly below it. Additionally, the AND/OR on the last line of the decision block plays no part in the overall decision (because there’s no line after it to contribute to the decision).
So here are a few Custom decision scenarios to do your head in:
- If you have AND at the end of a line, this condition AND the next one must evaluate to TRUE in order for both of them to evaluate to TRUE.
- If you have OR at the end of a line, this condition OR the next one can be true in order for both them to evaluate to TRUE.
- If you have three condition statements, with the first two set to AND followed by the last one set to OR, then all three statements need to be TRUE in order for the overall set to evaluate to TRUE. (Remember that the final statement’s AND/OR doesn’t affect anything.)
- If you have three conditions statements, with the first two set to OR followed by the last one set to AND, then only one of the statements needs to be TRUE in order for the block to evaluate to TRUE and the actions below to be executed.
Is your head throbbing yet? If so, I really shouldn’t need to say anything more to discourage you from trying to use the Custom setting on the Advanced Actions dialog? Don’t feel bad about this. In many years of using Adobe Captivate’s conditional actions I have never resorted to using the Custom option. If I have a complex condition where I need to mix some AND with OR statements, I much prefer to separate them out into different decision blocks. I find this gives me much better control and is a lot less likely to get me involved in any logic conundrums.
Completing a conditional action
You’ll be happy to know that once you get past the complexities of working out the logic in your decision block, the rest of what you do when building a conditional action is something of an anticlimax because it’s more or less the same as building any standard action. In the Actions section immediately underneath the condition statements, all you need to do is list all of the actions that should be executed in sequence if the decision block as a whole evaluates to TRUE.
If something should happen when the decision block evaluates to FALSE, those actions must be specified in the ELSE block at the bottom.
And that’s about all there is to it! Don’t worry if the theory of it all seems a bit overwhelming at this point. As soon as you begin creating your own simple conditional actions, the theory falls into place.
Adding multiple decision blocks
Although the ability to add decisions is what differentiates conditional actions from standard actions, what really makes them super powerful is the ability to add multiple decision blocks that get executed one after the other in a specific sequence. This just takes everything to a whole new level because this fact enables e-learning designers to create interactions that potentially execute any number of decisions and any number of actions, from a single run-time event. That’s just awesome!
As mentioned earlier in this chapter, Captivate starts you off with three decision blocks as soon as you choose Conditional action from the Action Type: drop-down. Once you’ve filled them up, all you need to do is click the small button to add another at the right-hand end of the line.
If you try to save a conditional action without specifying conditions, Captivate will curtly warn you.
If you try to save changes with some condition lines or action lines not completed, then you’ll see a different warning box telling you “The Script is incomplete”.
Preview a conditional action
Although the Advanced Actions dialog does a reasonable job of showing the decision blocks and actions involved in a conditional action, it does have some shortcomings:
- If you use more than four lines of condition statements, you must scroll to see the rest.
- You can see a maximum of 8 action lines before scrolling.
- You cannot see IF conditions, THEN actions and ELSE actions in a single view.
Wouldn’t it be nice if you could see your complete conditional action in all it’s glory in a single view?
Well now you can…as long as you have Captivate 7.0.1 or later. Adobe added a small icon to the button bar in the top right corner of the Advanced Actions dialog. This icon is disabled for standard actions but becomes enabled when you select a conditional action. Just click the icon…
…and the Advanced Actions dialog changes to show a code-based view of your entire conditional action including all decision blocks and their respective actions. Use the small triangular arrows to collapse or expand individual decision blocks, or use the Collapse/Expand toggle button below.
If you've been following everything I've explained above, well done! You're well on the way to becoming an Adobe Captivate expert. The ability to use conditional actions to create complex interactivity is what really "separates the men from the boys" in the Captivate e-learning world.
There is yet one more type of Advanced Action that you need to know about - Shared Actions.
However, just knowing how single actions, standard actions, conditional actions or shared actions work is not enough to make you a top-earning professional e-learning developer. You also need to know how to use them to create the kind of sophisticated interactivity that more and more clients are asking for. That means you need to know which techniques to use in order to solve the day-to-day instructional problems e-learning developers encounter.
I'm talking about use cases that involve the following scenarios:
- Capturing and validating user input
- Responding to different types of mouse events
- Creating toggle actions
- Dynamic navigation
- Date manipulation
- Enhanced quizzing
I'll be covering these topics in other articles and blog posts.