In this article
Conditions allow you to determine the flow of a survey using an IF-THEN-ELSE logic.
You can build Conditions using the Condition Builder functionality described here, or you can create them using scripting. Note that if scripting is used then this will take precedence over logic created using the builder, and a message will be displayed in the condition to inform you of this. If script is used in a condition then it will be displayed in the Survey pane beside the condition ID, and a message will be displayed on the question details page to warn you that it exists and will therefore take precedence. If script is not used then the condition ID will include the question on which the condition is based.
To create a condition using the Condition Builder:
- Create a Condition node in the survey (go to Adding Items to a Survey for more information).
- Open the node’s Details overlay - (for a new node it will open automatically).
- In the Branches drop-down, select the branches you wish to include in the condition; IF-THEN, or IF-THEN-ELSE.
- From the lists of questions and quotas, select the item that you wish to build the condition on.
- In the Responses drop-down, select the option(s) you wish to use in the condition.
- Select the answer options that are to be included in the condition, then click Done.
Figure 1 - Example of the Details overlay for a Condition node
The Details overlay shows a list of all the questions and quotas in the survey on which the condition can be based. The totals of each are given in the tab headers; in this case 13 questions and 0 quotas are available. The questions are listed in the order in which they appear in the survey.
If you have a large number of questions in your survey, then the first 50 will be listed. You can filter the questions to reduce the list to find the question(s) you wish to work with. To do this, type characters into the Search and filter field; the filter will update the list of questions as you type to show only those questions that include the entered character string. The Search and filter field is not case-sensitive.
This procedure describes the IF-THEN-ELSE setup. In the event you wish to create an IF-THEN condition, merely ignore the ELSE part.
Note: If you change a condition from IF-THEN-ELSE to IF-THEN, any items in the ELSE branch will be deleted. If you wish to keep these items, move them elsewhere in the survey before you change the condition.
The answer options for that question are displayed. Note that the codes are given for each answer.
Important
The exact procedure from here on will depend on the type of question you have selected; different question types require different fields and options. This procedure uses a Multi question.
Figure 2 - The answer options for the selected question
Note: The selection system is dynamic; at all times the system only shows you information, options and input fields that are relevant to what you have already selected. The options Match, Don’t match, Answered and Not answered are common for the majority of question types, and other options may be available as appropriate. None of the input fields here are case-sensitive.
If you select more than one answer option, for example in a multi question, you can choose whether all the options are to be matched or whether any are to be matched. The resulting logic will be either a AND b AND c, or a OR b OR c.
A summary of the condition so far is displayed. The field names, operators and values are written out in the form of a sentence (not using symbols) describing the condition, so the condition’s expression can be read and more easily understood - ringed below. Note that you can add conditions within conditions to build multiple levels of logic.
Figure 3 - The condition summary
You now need to add the THEN clause that is to be enacted if the logic evaluates to TRUE.
- In the design area, click the +THEN button.
- Add the item you wish to be enacted if the logic evaluates to TRUE.
Figure 4 - Adding the THEN clause
The Add Item overlay opens (go to Adding Items to a Survey for more information).
For example this could be a question or information item that only applies if the respondent has selected a specific answer in a previous question, or it could be that you want to stop the survey if the respondent has given a particular answer to another question.
Once you have added the THEN item, if you are not using the ELSE clause then the condition is now complete.
If you have selected to use the ELSE clause then it will be included in the Survey pane and you add the appropriate item in the same way as you added the THEN item.
- Click the + Else button to open the Add Item overlay (go to Adding Items to a Survey for more information), and add the item you wish to be enacted if the logic evaluates to FALSE, in other words, if the THEN item is not enacted.
The condition is now complete. For ease of reference the full text of the condition is written into the Survey pane beside the condition item. If the pane is not wide enough to show all the text then the text will be truncated - hover the mouse pointer over the condition to view the full text in a pop-up.
Note: If you attempt to create an invalid condition it will not be saved and a message will be displayed informing you of this. Note also that if the condition is valid then it will be saved; if you have made a mistake and used for example the wrong question, the system cannot know this - check your work.
Note that any changes you make to a condition can be undone in the Change log (go to Change Log for more information).