Welcome to the LimeSurvey Community Forum

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

Prefill multiple choice question from multiple choice array

  • socius
  • socius's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 7 months ago - 6 years 7 months ago #158130 by socius
Dear all,

I fear that this question - or a similar one - was asked before, but I somehow cannot get an answer in the forum and the manual. I use LS 2.6.4-lts.

The short story is: I have a multiple choice array and want to use the answers of the subquestions for array filtering.

The longer story: As a starting point I have a array (numeric) question in checkbox-0/1 mode with 10 rows (for a number of n activities respondents can engage in) and 6 columns (for 6 different groups of people that the respondent engages in the specific activities together). In short, I have a 10x6 array with checkboxes - let's call this question q1, with q1_1_1 to q_10_6.

Now i want to ask further questions for all the combinations in this array that are ticked, e.g. the combination of activity and group, e.g. engagement in activity 1 with group 1, etc. For this reason I would like to transfer/transform the answers from the 10x6 array into a multiple choice variable with 10x6=60 possible rows. This prefilled multiple choice question should be utilised as an array filter for the subsequent questions on the ticked combinations.

Now my question is: do I need Javascript for that prefilling? Reading the manual ( manual.limesurvey.org/Expression_Manager..._Assignment_Operator ) I get the impression that I could achieve this with the Expression Manager alone, where I first create the 60 row multiple choice question (q2_1 to q2_60) and then assign values to the answers of these subquestions with a hidden equation-type question and some code like:
Code:
{q2_1=if(q1_1_1==1,"Y","N")}
{q2_2=if(q1_1_2==1,"Y","N")}
{q2_3=if(q1_1_3==1,"Y","N")}
{q2_4=if(q1_1_4==1,"Y","N")}
...
{q2_60=if(q1_10_6==1,"Y","N")}

Finally q2, this prefilled multiple choice question, should then serve as array filter for the following questions.

I tried this, but it didn't work out. Do you have an answer to this? Is it possible w/o Javascript as I have the impression from the manual? Or do we need Javascript here (and how about would that work?).


Thanks a lot for your time and help!
Best, G
Last edit: 6 years 7 months ago by socius. Reason: Changed symbol to "?"
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago #158135 by DenisChenu
With checkbox : Y is for yes but no is '' (empty). And array_filter is done for empty

{q2_1=if(q1_1_1==1,"Y","")} must work

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: socius
The topic has been locked.
  • socius
  • socius's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 7 months ago #158140 by socius
Hi and thanks again :-) now it works!

But: is it true, that it only works this way (creating filter variable, assign values via EM, use filter variable) if the filter variable (in this case q2) is created on an earlier page than the questions to filter? (In my example here this seems the case...) If yes: I guess the realtime solution needs javascript, right?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago #158146 by DenisChenu
Yes need javascript. See demonstration.sondages.pro/676785 for a pre "relevance on subquestions"

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: socius
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose