Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Constant Sum Question - Requiring a Minimum Number of Boxes to check

Hi!
I was wondering if it were possible to specify a minimum number of boxes someone has to fill out in a constant sum question.

Ex.:  I have a question where the survey takers have 100 points to allocate to 20 choices.  Is it possible to require each survey taker to fill in at least 3 boxes?

Thanks!
RT
asked Feb 14, 2022 by RT

1 Answer

0 votes
Please try out this custom JavaScript verification:

// Settings
var minimumResponses = 3;
var message = 'Too few responses.';

// Run
var numberOfResponses = 0;
$('input[name="hid_list_[% QuestionName() %]"]').val().split(',').forEach(function(item){
    if (SSI_GetValue('[% QuestionName() %]_' + item)) {
        numberOfResponses++;
    }
});
if (numberOfResponses < minimumResponses) {
    strErrorMessage = message;
}
answered Feb 14, 2022 by Zachary Platinum Sawtooth Software, Inc. (214,575 points)
Thanks so much!
I just have one quick follow-up question then:
Does it matter if I select "before" or "after" in that drop-down menu in the Custom JavaScript Verification tab?
What's the difference?
Thanks again!
For this case - and most cases - you should be fine with "before" or "after."  The system verification it mentions is talking about the built-in verification (e.g., the error message that shows up if a respondent's constant sum scores total to 99 instead of 100).  While both verifications have to pass for a respondent to continue, if the one that runs first fails, then that error is printed to the page and the other one doesn't bother running.  So you're effectively selecting an answer to the question "if both the normal verification and my custom verification are going to fail, which error message do I want to show?"
...