I have a highlighter question that makes participants choose 5 consecutive numbers from 0 - 24.
How do I extract the numbers selected from the highlighter question and ensure that they are a consecutive array (i.e., 2, 3, 4, 5, 6)?
Would it also be possible to add this as a custom validation?
Best answer by Tom_1842
Since the selections need to be consecutive in order to pass the validation, I think you can put this in place just by using Custom Validation and a lot of clicking. You could set 21 Logic Sets where each checks for a selected count of 5 and that the 5 selections are consecutive numbers. It could like something like the below, with 19 more sets for each potential combination of 5 consecutive numbers (20 being the highest selection for the first number to have the fifth selection be 24).
To get the selection data in the format you’re looking for, you could use Branching and setting Embedded Data in the Survey Flow with the same Logic as above. Something like the below:
Since the selections need to be consecutive in order to pass the validation, I think you can put this in place just by using Custom Validation and a lot of clicking. You could set 21 Logic Sets where each checks for a selected count of 5 and that the 5 selections are consecutive numbers. It could like something like the below, with 19 more sets for each potential combination of 5 consecutive numbers (20 being the highest selection for the first number to have the fifth selection be 24).
To get the selection data in the format you’re looking for, you could use Branching and setting Embedded Data in the Survey Flow with the same Logic as above. Something like the below:
If you are up for writing some JS, a more flexible approach would be to use getSelectedChoices() and getSelectedAnswerValue() in addOnPageSubmit() to determine if the answers are consecutive. Use that result to answer a hidden question on the page, and use that question in a validation condition of your highlight question.