Conditions show or hide controlled questions based on the response a respondent provides to one or more controlling questions. There are single and compound condition types. See Universal Survey Block Parameters to learn how to assign the conditions described below to a question or instruction block in your survey.
Configuring Single Conditions
Single conditions are based upon a specific response or range of responses to a question. A question controlled by a single condition only displays to respondents if the condition evaluates to true based on the controlling question.
Parameter | JSON Code Example | Description | Requiredness | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The name of the condition | "name": "condition1" |
|
Required | ||||||||||||
The type of the condition | "type": "single" |
|
Required | ||||||||||||
The name of the question block | "blockName": "q1" |
The name of the controlling question block being evaluated by the condition | Required | ||||||||||||
The operation of the condition |
|
The operation used to compare the triggering response to the respondent's response. The following operations are supported for single conditions:
The following operations are supported for single conditions when the triggering response is an optional answer:
|
Required | ||||||||||||
The answer |
|
|
Required | ||||||||||||
In the "answer" node: | |||||||||||||||
The type of answer |
|
The type of response value that the condition evaluates against. The type must match the controlling question’s type and be consistent with the operation of the condition.
Note: Conditions for textEntry question types aren’t supported unless the condition is referencing an optional answer. Note: Conditions for numberEntry only support number entry questions with a single answer, not those with multiple answers (e.g. Enter your height in feet and inches). |
Required | ||||||||||||
The triggering value of a name type answer | "name": "1" |
The condition uses the operation (==, !=, INCLUDES, NOT_INCLUDES) to evaluate the respondent’s response against this value. | Required if type is name | ||||||||||||
The triggering value of a number type answer | "number": "10" |
The condition uses the operation (==, !=, <, >, <=, >=) to evaluate the respondent’s response against this value. | Required if type is number | ||||||||||||
The triggering value of a static type answer |
|
|
Required if type is static | ||||||||||||
In the "optionalAnswer" node: | |||||||||||||||
The name of a triggering optional answer | "name": "q1-notapplicable" |
The condition uses the operation (==, !=) to evaluate the respondent’s response against this value. | Required |
Example Single Condition JSON Configuration
The following JSON snippet illustrates the single condition parameters described above. The configuration below is not reviewed or licensed for use in collections.
"conditions": [
{
"name": "condition1",
"type": "single",
"blockName": "q1",
"operation": "<=",
"answer": {
"type": "number",
"number": "20",
}
},
{
"name": "condition2",
"type": "single",
"blockName": "q2",
"operation": "==",
"answer": {
"type": "name",
"name": "1",
}
}
{
"name": "condition3",
"type": "single",
"blockName": "q3",
"operation": "NOT_INCLUDES",
"answer": {
"type": "name",
"name": "q1-1",
}
}
{
"name": "condition4",
"type": "single",
"blockName": "q4",
"operation": ">",
"answer": {
"type": "static",
"value": "13:50",
}
}
{
"name": "condition-optional",
"type": "single",
"blockName": "q5",
"operation": "==",
"optionalAnswer": {
"name": "q1-notapplicable"
}
}
]
Configuring Compound Conditions
Compound conditions combine two or more conditions using an operation.
Parameter | JSON Code Example | Description | Requiredness |
---|---|---|---|
The name of the condition | "name": "condition3" |
|
Required |
The type of the condition | "type": "compound" |
|
Required |
The operation of the condition | "operation": "AND" |
The operation that connects the conditions within this compound condition. The following operations are supported for compound conditions:
|
Required |
The conditions being compounded | conditions": ["condition1", |
The single or compound conditions that are being evaluated in the compound condition | Required |
Example Compound Condition JSON Configuration
The following JSON snippet illustrates the compound condition parameters described above. The configuration below is not reviewed or licensed for use in survey collections.
{
"name": "condition3",
"type": "compound",
"operation": "OR",
"conditions": ["condition1", "condition2"]
}