The Advanced Logic Section

A2J Author® allows authors to branch or set variables based on simple logic conditions under the Advanced Logic section in the Question Design Window (Figure 122). Creating conditions in A2J Author 5.0 is significantly different than drafting them in version 4.0.

 

Creating conditions is now done by typing into the “Before” text box or the “After” text box. By placing the scripting in the “Before” box, A2J Author knows to evaluate that condition before the end user sees the question that contains the logic. By placing the scripting into the “After” box, A2J Author knows to evaluate the condition after the end user presses one of the buttons.  

 

Advanced Logic Blank.png

Figure 122: Blank Advanced Logic section.

 

If a condition is tested before a question is displayed and the condition is true and the action is to move to another question, then the end-user will not see the current question. If the same condition is false, then the opposite is true.

 

The expression to be tested is typed directly into the “Before” or “After” boxes. For example, suppose a question asks for annual income. Let’s assume that if the end-user had entered a number greater than $35,000 that they would then need to answer a different set of questions. To reroute the end-user, write a condition similar to the one in Figure 123. A2J Author® would evaluate whether or not the income equaled an amount over 35,000. Based on whether that evaluation equals true or false, the author can then tell A2J Author to send the end-user to a particular question.

 

Advanced Logic_Income example.png

Figure 123: A sample advanced condition.

 

Variables can be evaluated in a condition using the following operators:

 

Symbol

Comparison

Example

Result

=

equals

10 = 10

True

<>

not equal

10 <> 10

False

>

greater than

10 > 5

True

<

less than

10 < 5

False

>=

greater than or equal to

10 >= 10

True

<=

less than or equal to

10 <= 10

True

is

synonym for equals

City is “Chicago”

true if the City variable contains Chicago

 

Remember to always enclose variable names in brackets [  ] when evaluating them in a condition.

 

Do This:                      [Children TF]=true

Do NOT Do This:       Children TF=true

 

Simple mathematical expressions can also be done.

    

Expression

Result

(15 - 15) > 10

false

 

A2J Author® also allows the use of AND and OR logic in the expressions. (These operators can be scripted in either lowercase or uppercase letters.)

 

Expression

Result

5 > 1 and 1 = 1

false

5 > 1 or 1 = 1

true

 

There are two possible actions following the evaluation of a condition: SET a variable to a value and/or GOTO a question. Set variable to value allows any variable to be set to a particular value or expression. GOTO a question allows authors to reroute (or branch) the end-user to a different question than had the condition evaluated differently.

 

It is important to remember that conditions are tested in order. Once the first true condition is found whose action is to go to another question, the rest of the conditions will not be tested. Thus, make sure that all of the conditions that set variables to values are listed above the conditions that use a GOTO command. There is no limit to the number of conditions that can be scripted for a question.

 

Avoid designing an entirely new condition to account for an opposite evaluation. For instance, now that A2J Author has evaluated whether [Income NU] is greater than $35,000, the author may want to set a separate action if [Income NU] is not greater than $35,000. To do this, the author does not need to construct another evaluation, e.g., [Income NU] <35000. Instead, add an ELSE statement so that if [Income NU]>35000 is not true, A2J Author can set a variable or go to a question (Figure 132).

 

So, in the example above (Figure 132), a single condition has set three actions as follows: 1) if [Income NU]>35000 is true, then set the variable Income too high TF to true; 2) if [Income NU]>35000 is true, then go to question <0-Do Not Qualify & Exit>; and 3) if [Income NU]>35000 is false, then set the variable [Income too high TF] to false. The author could then add a fourth action, to send the end-user to a different question if [Income NU]>35000 is false. Multiple actions can be based off 1 single expression.