This script determines when participants provide the same rating to two products or services. An open-end question is presented as a follow-up question to determine why the participant provided the same rating for both products / services. The example script assumes that you have created two single-choice questions with identical option lists.
Detailed Steps
Create a Conditional Sequence
- On the Authoring Navigation Bar, hover over Folder, and then select Conditional Sequence.
- Select the Conditional Sequence in the tree.
- Expand the Properties section below the Filter Editor.
- Under Condition Using, select Script.
- Click Save.
Prepare the Script in Notepad
- Open Notepad or a similar text editing tool
- Copy the script below into Notepad
- Edit the script in Notepad by doing the following:
- Replace Q1_SINGLE_CHOICE with the name of the first Single Choice question
- Replace Q2_SINGLE_CHOICE with the name of the second Single Choice question
/* Script Name: How do I add a conditional sequence based on comparing two single-choice questions? To ensure your script works as expected, always copy the original script from the script library found in the support portal. Failure to use the most up to date script from the script library may cause unexpected results. */ EnterCondition = false; if ((int)Q2_SINGLE_CHOICE == (int)Q1_SINGLE_CHOICE) { EnterCondition = true; }
Note: The question names used in scripts are case-sensitive. Ensure that you use the exact question names as they appear in the Questionnaire tree of the study.
Insert the Script into your conditional sequence
- Copy the completed script into the Conditional Sequence.
- Click Save.
- Create additional questions in your conditional sequence. These questions will be answered by those who enter the conditional sequence based on the criteria you have prepared in the script.
- Click Validate and test your study.
Additional Information
The If statement used in the script compares the value of the option of the answers selected by the respondent. The value of the options increases from the top down, starting at one. See the table below for an example.
Answer | Value |
Excellent | 1 |
Neutral | 2 |
Poor | 3 |
Given the answers above, the system will evaluate the answer Poor (3) as greater than Excellent (1). The system evaluates the script's If-statement based strictly on the order in which the answers are presented. The following table presents the Conditional values used by if-statements in C# and in scripting
Condition | C# Scripting |
Equal To | == |
Not Equal To | != |
Greater Than | > |
Less Than | < |
Greater or Equal To | >= |
Less Than or Equal To | <= |
Example Scripts
The following script presents the questions in the Conditional Sequence if the respondent provides an answer with a higher value in the first question than in the second:
/* Script Name: How do I add a conditional sequence based on comparing two single-choice questions? To ensure your script works as expected, always copy the original script from the script library found in the support portal. Failure to use the most up to date script from the script library may cause unexpected results. */ EnterCondition = false; if ((int)Q2_SINGLE_CHOICE < (int)Q1_SINGLE_CHOICE) { EnterCondition = true; }
The following script presents the questions in the Conditional Sequence if the respondent provides answers with different values in both questions:
/* Script Name: How do I add a conditional sequence based on comparing two single-choice questions? To ensure your script works as expected, always copy the original script from the script library found in the support portal. Failure to use the most up to date script from the script library may cause unexpected results. */ EnterCondition = false; if ((int)Q2_SINGLE_CHOICE != (int)Q1_SINGLE_CHOICE) { EnterCondition = true; }
Comments
0 comments
Article is closed for comments.