The Survey Editor allows you to specify an exact number of values (i.e., response options) that must be selected in order for a response to be considered valid. This document outlines the process for forcing an exact value response within survey questions containing an exclusive option.
Tip: Click here to see the instructions if your question does not contain an exclusive response option.
Adding the Question
To add a question that contains an exclusive response option and also requires an exact number of values that must be selected for a valid response, first add the question and all desired response options. Then, click the response option you want to make exclusive so that its options appear to the right side of the staging area.
In the options panel, check the "Exclusive" box to enable it. If QA codes are being shown (via the "View Options" menu), an "EXC" code will appear for the response option you marked exclusive.
Adding the Requirement
Next, access the XML Editor by selecting "Edit XML" from the "More Tools" drop-down under "Build" in the navigation menu.
Locate the question in the survey XML. After the question's comment tag (or the title, if there is no comment), enter the following code on a new line:
<validate> if not (this.count == 3 or this.r8): error("Please select exactly 3 features") </validate>
Then make the following adjustments:
- Replace "3" with the number of responses your question will require as a valid response.
- Replace "r8" with the row, column or choice label of the exclusive response option.
- Replace "Please select exactly 3 features" with the error message that will be displayed if a participant tries to enter a number of responses that do not match the required number.
Once you are satisfied with your changes, click "Save" to return to the Survey Editor.
Testing the Setup
To test the setup, select "Test Survey" from the "Preview" drop-down in the navigation menu. Once you reach the question, attempt to select a different number of values than is required and continue. The question should display the error message you specified in the survey XML.
When you select the correct number of response options, you should be able to continue to the next question.