Welcome, Guest
Username: Password: Remember me

TOPIC: Array (Numbers) with Checkbox: Limit number of checked ones in a row

Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76212

  • Flasher
  • Flasher's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Hi,

I found in the BugTracker, that when using "Array (Numbers)" with "Checkbox layout" the option field "Maximum answers" is not working (respectively producing problems) because each checkbox is either 0 or 1, so for the logic each checkbox gives an answer (independently of if it is checked or not). Thus, only the number of checkboxes in "maximum answers" works but that didn't make sense/change anything about the behavior.

Anyway, I would like to limit the number of checkbox per row which can be checked. I think what I need is a "Sub-question validation equation" which sums up the values of the checkboxes. This sum must than be smaller or equal my maximum allowed number of checkboxes. Cause I'm new to LimeSurvey and not nuderstand the Expressions completely, I didn't found a solution. I tried things like:

sum(Q8???,Q8???,Q8???)<=2 where I tried different things for ???. Nothing worked. Can somebody give me a hint or solution. Maybe there is even another way of solving my problem.

Thanks in advance.

P.S.: I use Version 1.92 Build 120303
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76218

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Please attach a copy of the question you are trying to modify (the .lsq file) and we can give you a specific answer.
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76223

  • Flasher
  • Flasher's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
I attached an example question. Nothing special. 5 choices on the x-axis and 3 on the y-axis. No logic or anything else.
Attachments:
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76230

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
So, here is how you would do this in 1.92.

Here is what the running survey looks like:

limit_checkboxes_per_row_running.jpg


As you can see, when I clicked submit, it returned to the page and warned me that I could check at most 3 items per row.

Here is the actual survey file:

File Attachment:

File Name: limesurvey_survey_53654.lss
File Size: 24 KB


And for convenience, here are some screen shots of the setup.
(1) I renamed the X and Y axes to make it easier to understand the variable naming:

limit_checkboxes_per_row_qsetup.jpg


(2) To create the rules limiting the number of checked boxes per row, use the Logic section of the Advanced Question Settings like this:

limit_checkboxes_per_row_logic.jpg


(3) Then, use the Show Logic File button to validate that you typed everything correctly. Since there are no red lines surrounding the variable names, the equation is OK:

limit_checkboxes_per_row_logicfile.jpg



In the future, it might be nice for LimeSurvey to have "Minimum answers per row" and "Maximum answers per row" options, for that would let you more easily flag the rows that fail validation criteria, and you would not need to use the
"Question validation equation" option.
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76239

  • Flasher
  • Flasher's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Thanks a lot.

I wonder if there is also a solution with the sub-question validation equation. Would be time saving for big question to only write one sum-equation instead of #rows times. But I'm absolutely fine with this.

Would be nice to have that feature built-in. I mean, the options "minimum answers" and "maximum answers" already exists, but not work properly due to the mentioned bug track that checkboxes are alsways give an answer. Regarding that post the problem came because checkbox layout was implemented later on and nobody thought about that.

So many user might be confused that the options exist but not work. Good, that this question type is not used that often ;).
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76256

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5333
  • Thank you received: 296
  • Karma: 249
Great example, can you add that at docs.limesurvey.org/tiki-index.php?page=...ion+Manager+Examples where we plan to collect samples?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76261

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Mazi-

I've added that example to page 4 of /docs/demosurvey/ls_test_em_sq_validation.lss

/Tom
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76265

  • Flasher
  • Flasher's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Is there a possibilty to dynamically insert the sub-question-code when validating sub-questions. Something like sum(Test_{row_code}_1,Test{row_code}_2,Test_{row_code}_3)<=3

Or is there such thing? I didn't find anything in the manual.

Would be a faster, more fleixble solution with less code. Also because when now adding/deleting a sub-question, the validation has to be changed.
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76268

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Flasher-

You can't do the sum(Test_{row_code}_1, ...), since EM does not support nested expressions.

However, I have been planning enhancing support for the reserved "this" variable. See the notes here.

The goal would be to create row-level "this" variables so that you could simply say something like (I haven't locked down the syntax yet - so it may be a little different):
sum(this.NAOK.rowA) <= 2

and EM would internally expand that to:
sum(Test_rowA_1.NAOK, Test_rowA_2.NAOK, Test_rowA_3.NAOK) <= 2

So, that's on the wish list, but I can't provide an estimate of when we'd get to it.

/Tom
The administrator has disabled public write access.

Re: Array (Numbers) with Checkbox: Limit number of checked ones in a row 2 years 7 months ago #76342

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5333
  • Thank you received: 296
  • Karma: 249
I have added the example to the wiki at docs.limesurvey.org/tiki-index.php?page_...eckbox_quot_question

Would be really nice if others could help us extending that page.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.247 seconds
Donation Image