Welcome to the LimeSurvey Community Forum

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

Subquestion validation for Array(numbers)

  • jose_bu
  • jose_bu's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 1 month ago #213848 by jose_bu
Hi,

I need to validate subquestions in an array(numbers) with checkboxes. For each row, no more than two options should be selected. I can write the following as question validation (as it is shown in the manual): 
Code:
[color=#3498db]sum(self.sq_SQ001) <=2 &amp;&amp; sum(self.sq_SQ002) &amp;&amp; ..[/color].
Is it possible to do this in a more efficient way? For me, this would be very helpful, because I have a lot of these questions and in each question, there are a lot of subquestions. So the approach above will take long time. Is it, for example, possible to do this in a loop?
I have tried subquestion validation with this, however, I dont know how to get access to the columns.

Thank you for your help!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #213896 by Joffm
Replied by Joffm on topic Subquestion validation for Array(numbers)
Oh, please, don't tell me it's a lot of work.

You use the "self" operator, so you are independent of the question code.
If you prepare ONE long validation in a text editor. like
count(self.sq_SQ001)<3 and count(self.sq_SQ002)<3 and count(self.sq_SQ003)<3 and ... and count(self.sq_SQ030)<3 and ...

you just paste the necessary part into your question validdation.
Faster than anything else.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose