This script allows participants to opt out from a Highlighter question by providing a check box indicating that they do not have an answer or prefer not to provide an answer to the question. If participants highlight the image shown and select the check box, they will see an error message.
Detailed Steps
- Create a Page.
- Create your Highlighter question on the page.
- In the Properties section, deselect Question completion required.
- Modify the default instruction text if necessary.
- Create a standard Multi Choice question within the page.
- Add the opt-out text as an answer option such as Don't know, Not Applicable, Prefer Not to Answer.
- In the Properties section, deselect Question completion required.
- Delete the default instruction text from it.
- Copy the script below into Notepad or any other text editor (e.g. Notepad++, Textpad) and make the following changes:
- Change Q_HIGHLIGHTER to the name of your highlighter question.
- Change Q_DONTKNOW to your opt-out multi choice question.
- Insert the completed script into the Script section of the page by doing the following:
- Select the Page in the Questionnaire Tree.
- In the Scripting section of the page, click Edit Scripts.
- Paste the script into the On Validate tab.
- Click Save.
- Set up the custom error message.
- Create a hidden Single Choice question called ERR_MSG if you do not have one in your study already.
- Create an answer with error text such as Please either highlight the area(s) of interest or click Nothing to proceed.
- Change the Precode of the error message to HL_EXCL.
- Click Save.
- Validate and test your survey.
Script
/* Script Name: How do I add an exclusive check box on a page with a Highlighter question? (Power Surveys) 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. Reminder: Highlighters are not supported in mobile view and mobile view users will only see the 'none/dk' checkbox on screen. Please update study setting to desktop only or add logics around this question to prevent mobile users from seeing this page. */ VerbatimQuestion hlq = Q_HIGHLIGHTER; ChoiceQuestion hldk = Q_DONTKNOW; /*----- LEAVE CODE BELOW AS IS -----*/ ChoiceQuestion err = ERR_MSG; if ((hlq.Value == null) && (hldk.SelectedAnswer == null)) { if (IsATR) Set(hldk, 1); else { ValidationErrors.Add("AnswerIsRequired"); //Default system error } return; } else if ((hlq.Value != null) && (hldk.SelectedAnswer != null)) { if (IsATR) Unset(hldk, hldk.Answers); else { NewError(String.Format(((Answer)err.FindAnswerByCode("HL_EXCL")).Html, (string)hldk)); Set(hlq, String.Empty); Unset(hldk, hldk.Answers); } return; }
Note:
- ATR will bypass the validation script, so please be aware that ATR data will not be accurate for this setup. It will need to be checked manually through the link.
More Information
Please visit the following links to our Webhelp to learn more about this:
Comments
0 comments
Article is closed for comments.