Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Help: Limit number of selectable answers for multiple choice question

  • AnneJasmin
  • AnneJasmin's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago #232336 by AnneJasmin
Please help us help you and fill where relevant:Your LimeSurvey version: 3.22.1 200129Own server or LimeSurvey hosting: Own ServerSurvey theme/template: Individual==================Dear Community,I desperately need help for a survey which should start tomorrow. I have to create a multiple choice question as follows: Out of the 10 possible answers for this question, the survey participants should only be able to select 5 answers. Although I indicated maximum number of answers "5" and minimum number of answers "5" under "Logic" for the question, the participants can still choose more than 5 questions.What could be the reason? Am I missing something?I would be so grateful for some help!Thank you!Anne

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232337 by holch

What could be the reason? Am I missing something?I


I don't know, maybe the outdated version of LS 3.x that you are using? It hasn't seen an update, bug or secuirty fix since 29/01/2020, so almost 2 years now.

the participants can still choose more than 5 questions.


So when you click on "next" there is no error message? The respondent can just move on? Is the question mandatory?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • AnneJasmin
  • AnneJasmin's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago #232339 by AnneJasmin
That could be a reason, but I can only use this version unfortunatey. :(

The participants get no error Message, they can just move on. The question is not mandatory. Should it be mandatory?

Thank you for the fast reply! :)

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232340 by holch
I just tested a little survey with one question of the multiple answer/choice type with max 5 and min 5. While there are no answers or less than 5 answer ticked the survey indicates that question is not yet answered correctly. When the 5th is ticked it becomes "correct" and for any further answer ticked it get's marked "wrong" again (red shade). When clicking on next, the following error message appears:

"One or more questions have not been answered in a valid manner. You cannot proceed until these answers are valid."

So yes, you CAN choose more than 5 answer options, but it LS should not let you move on (no matter if the question is mandatory or not, I just tested this).

So please send us a LSS export with just this question so we can have a look at what you have done and if it works on our installation.

Tested with LS 3.28.24+220816.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • AnneJasmin
  • AnneJasmin's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago #232341 by AnneJasmin
OK, thank you so much! I tested it again and indeed I get the same error message! However I think it will be very confusing for participants because there are other questions as well and it will take some time for them to find out what the error is. Do you know if there is a different option to limit the number of answers? :)

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232344 by tpartner
If you are able to insert JavaScript, this little script in the question source will disable unchecked boxes when 5 are checked:

Code:
<script type="text/javascript" data-author="Tony Partner">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Number of allowed answers
    var answers = 5;
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Listener on checkboxes
    $('.answer-item :checkbox', thisQuestion).on('change', function(e) {
      $('.answer-item :checkbox', thisQuestion).prop('disabled', false);
      if($('.answer-item :checkbox:checked', thisQuestion).length >= answers) {
        $('.answer-item :checkbox:not(:checked)', thisQuestion).prop('disabled', true);
      }
    });
 
    // Initial states
    if($('.answer-item :checkbox:checked', thisQuestion).length >= answers) {
      $('.answer-item :checkbox:not(:checked)', thisQuestion).prop('disabled', true);
    }
  });
</script>

Sample survey attached:  

File Attachment:

File Name: limesurvey...3293.lss
File Size:22 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: AnneJasmin

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232346 by holch

However I think it will be very confusing for participants because there are other questions as well and it will take some time for them to find out what the error is.


Generally good practice is to have one question per page, or at least only a limited amount of question.

The question with the "error/problem" is highlighted, so they should be able to see this. You might want to highlight it a little bit more to make it stand out and easier to see which question is with an issue.

Or you implement Tpartners Javascript solution, if you can.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: AnneJasmin

Please Log in to join the conversation.

  • AnneJasmin
  • AnneJasmin's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago #232347 by AnneJasmin
OK, I think I will go for that option and only display one question per page as I cannot insert JavaScript. Thanks so much to both of you! :)

I also have a problem with an array filter. I used it for a multiple choice question (Q1) which has several answers and one "other" field. The question afterwards (Q2) ist a ranking question and should display all the selected answers from Q1 as options to be ranked. To my surprise I managed to set up the filter but the "other" field is always displayed, even if empty and not even selected.

Do you know what could be the reason?

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232348 by holch

Do you know what could be the reason?


Probably the question / answer codes in both questions is not matching for the "other" option.

Send a LSS export with just those two questions (copy your survey, delete all the unnecessary stuff and leave just the relevant questions, export it as LSS and upload it here).

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: AnneJasmin

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago - 1 year 6 months ago #232349 by Joffm
Hi,

what could be the reason?

The usual reason is that you did something wrong.
But tto see this we need a lss export of these questions
@holch told you already.
Remeber: In the ranking question there is no "Other" option, but the inserted text.

To add something to your 5 options problem.

I think it will be very confusing for participants because there are other questions as well 

What is confusing if the participant sees a big red message?
But of course you can customize the message with a question validation  (count(self)==5)
And then you create a tip like
{if(count(self)<5,"<span style='color:blue; font-weight:bold'>Please, select some more options, we would like to get five</span>",if(count(self)>5,"<span style='color:maroon; font-weight:bold'>Please select only 5 options</span>","<span style='color:green'>Fine, you selected five options"))}

  

  



And to the way to display a survey.
We really often recommend to show a survey "group by group", but with only one question in each group.
This way you are very flexible (sometimes you can show two or more short questions on one page, sometimes not)

Joffm

And your array filtrer.
Again as @holch: I Very probably an error with coding.
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 6 months ago by Joffm.
The following user(s) said Thank You: AnneJasmin

Please Log in to join the conversation.

  • AnneJasmin
  • AnneJasmin's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago #232350 by AnneJasmin
Hi Holch, thank you a lot! 
Please find the survey structure attached to this message. 

File Attachment:

File Name: limesurvey...2967.lss
File Size:91 KB

Thanks youAnne

Please Log in to join the conversation.

  • AnneJasmin
  • AnneJasmin's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago #232351 by AnneJasmin
I uploaded the document (See below answers) :)

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose