This script allows participants to opt out of an Open End question by selecting a check box indicating that they do not have an answer or prefer not to provide an answer to the question. Here, "Open End" refers to the following question types:
- Short Answer
- Long Answer
- Number (if the display is set to Text field)
Detailed Steps
- In your survey, add a Page element.
- Add an Open End question to the Page element.
- Open the Open End question properties and, under Additional options, deselect Response required.
- Under the Open End question, add a Multiple Choice question.
- Add the opt-out text as an answer option (for example, "I don't know" or "I'd prefer not to answer").
- In the Multiple Choice question properties, under Additional options, deselect Response required.
Your survey structure should now look similar to this. The Open End question and Multiple Choice are both nested inside the Page element, respectively.
- Open the Page element for editing and click the Scripting button.
- Copy and paste the script below into the On Complete tab.
- Replace VQ_Name with the name of the Open End question.
- Replace DK_Name with the name of the Multiple Choice question.
- Click Save.
- Preview and test your survey.
Script
/* Script Name: How do add an exclusive check box on a page with an Open End question? (Modern Surveys) To ensure your script works as expected, always copy the original script
from the Script Library found in the Alida Help Center. Failure to use the latest script
from the script library may cause unexpected results. */
const vq = response.getDataPoint('VQ_Name'); const vqValue = vq.get(); const dk = response.getDataPoint('DK_Name'); const vqHasValue = vqValue!= null; const dkHasValue = dk.getSelectedIndexes().length > 0; if(!vqHasValue && !dkHasValue) { response.setError("VQ_Name", "Please enter a response"); } else if (vqHasValue && dkHasValue) { response.setError("VQ_Name","Please enter one response only"); }
Comments
0 comments
Article is closed for comments.