Welcome to the LimeSurvey Community Forum

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

No duplicates for 4 or more subquestions

  • PaulMRFGR
  • PaulMRFGR's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 5 months ago #190179 by PaulMRFGR
No duplicates for 4 or more subquestions was created by PaulMRFGR
Hi there,

We have a question where respondents must select a price on a scale for each of 8 subquestions. Respondents should be unable to select the same price for 4 or more of the subquestions e.g. they can't select £10 for 4+ of the subquestions.

How can we go about doing this?

Thank you.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #190181 by tpartner
Replied by tpartner on topic No duplicates for 4 or more subquestions
What LimeSurvey version?

Can you attach a small sample survey (.lss file) containing only that question?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • PaulMRFGR
  • PaulMRFGR's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 5 months ago - 4 years 5 months ago #190183 by PaulMRFGR
Replied by PaulMRFGR on topic No duplicates for 4 or more subquestions
Version 2.05+

I've attached a .lss

Thanks :)

File Attachment:

File Name: limesurvey...7661.lss
File Size:28 KB
Last edit: 4 years 5 months ago by PaulMRFGR.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago - 4 years 5 months ago #190210 by tpartner
Replied by tpartner on topic No duplicates for 4 or more subquestions
For the benefit of others, you are using an array type question with question code "Combinations" and 35 answers with codes 1-35.

In this case, you can use the Expression Manager countif() function to count the number of selections of each answer.

- manual.limesurvey.org/Expression_Manager#Access_to_Functions

So, something like this in the question validation equation:

Code:
countif('1', that.Combinations) < 5
AND
countif('2', that.Combinations) < 5
AND
countif('3', that.Combinations) < 5
AND
countif('4', that.Combinations) < 5
AND
...
AND
countif('31', that.Combinations) < 5
AND
countif('32', that.Combinations) < 5
AND
countif('33', that.Combinations) < 5
AND
countif('34', that.Combinations) < 5
AND
countif('35', that.Combinations) < 5

Here is your sample survey back with that change:

File Attachment:

File Name: limesurvey...7661.lss
File Size:30 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 5 months ago by tpartner.
The topic has been locked.
  • PaulMRFGR
  • PaulMRFGR's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 5 months ago #190233 by PaulMRFGR
Replied by PaulMRFGR on topic No duplicates for 4 or more subquestions
Amazing! Thank you - this worked. Just quickly, if we wanted to change it to a maximum of 3 equal answers, how would we change the validation equation here?

Is it just a case of changing the '< 5' to '< 4'?

Again, as a complete novice to coding, I can only apologise for my ignorance.
The topic has been locked.
More
4 years 5 months ago #190237 by jelo
Replied by jelo on topic No duplicates for 4 or more subquestions

PaulMRFGR wrote: Is it just a case of changing the '< 5' to '< 4'?
Again, as a complete novice to coding, I can only apologise for my ignorance.

Being a novice wouldn't stop you from just trying it with <4, right?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: holch, tpartner
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose