Welcome to the LimeSurvey Community Forum

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

Can I limit the number of times an option is chosen? specific example below

  • vixitasurveys
  • vixitasurveys's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #229111 by vixitasurveys
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.3.17
Own server or LimeSurvey hosting: LS hosting
Survey theme/template: LimeSurvey Fruity Theme
==================
Hello,
Is it possible to limit the number of times a participant chooses a specific option?

Specific Example: Can I limit how often the option "Don't know/can't say" be chosen in a radio button/array type of question, to say, 25% of the total number of questions? e.g., if there are 100 questions, the participant cannot choose "don't know/can't say" more than 25% of the time.

Thanks in advance!

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago - 3 years 2 weeks ago #229113 by tpartner
If all are in the same question, use a question validation equation with the countif() function.

- www.limesurvey.org/manual/ExpressionScri...#Access_to_functions

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 2 weeks ago by tpartner.
The following user(s) said Thank You: vixitasurveys

Please Log in to join the conversation.

  • vixitasurveys
  • vixitasurveys's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #229116 by vixitasurveys
Thank you! :)

I am not a coder, but willing to try my hand and experiment. Is there any place that teaches how to write this code?

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #229117 by Joffm
Just enter in the "question validation equation"  an equation that has to be TRUE.
In your case the number of "DK/NA" answers is less than 25% of the number subquestions.

So: countif(...)<xx 

in a radio button/array type of question

e.g., if there are 100 questions

But as I cannot imagine that you want the respondents to answer 100 subquestions in one array, there will be subquestions be hidden by relevance equation.
So you have to count the displayed subquestions.
Best you use the property ".relevanceStatus" and sum it, like
{sum(self.relevanceStatus)}
Now you have a dynamic function to calculate the 25%
ceil(sum(self.relevanceStatus)*0.25)

So you can validate that the number of "DK/NA" that you get by the countif-functions has to be less than this calculated limit of 25%.

countif("6",self.NAOK)<ceil(sum(self.relevanceStatus)*0.25) 

About this, read
[url] www.limesurvey.org/manual/Question_type_...28em_validation_q.29 [/url]

[url] www.limesurvey.org/manual/ExpressionScri...mplemented_functions [/url]

[url] www.limesurvey.org/manual/ExpressionScri....22that.22_variables [/url]

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tpartner, vixitasurveys

Please Log in to join the conversation.

  • vixitasurveys
  • vixitasurveys's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #229122 by vixitasurveys
Thank you! 100 was just an example, it is likely to be closer to 30 or 40. I shall read up the resources provided too. Appreciated! :)

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose