Welcome to the LimeSurvey Community Forum

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

Randomly asking follow-up questions based on a multi-select question

  • drrwj01
  • drrwj01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 weeks ago #214393 by drrwj01
I am working on a little project where I am asking respondents to tell me what brands they use from a list (multi-select). I then want to ask them more about each brand but because people might select a lot of brands, I need a way to constrain the number of follow-ups in a random manner or based on some other criteria.Q1. Which brands have you purchased?Q2. How would you rate <brand 1> on each of the following attributes? [array question]Q3. How would you rate <brand 2> on each of the following attributes? [array question]Q4. How would you rate <brand 3> on each of the following attributes? [array question]Q5. How would you rate <brand 4> on each of the following attributes? [array question]Q6. How would you rate <brand 5> on each of the following attributes? [array question]Q7. How would you rate <brand 6> on each of the following attributes? [array question]Q8. How would you rate <brand 7> on each of the following attributes? [array question]Q9. How would you rate <brand 8> on each of the following attributes? [array question]Q10. How would you rate <brand 9> on each of the following attributes? [array question]Q11. How would you rate <brand 10> on each of the following attributes? [array question]I originally set this up like the above with a relevancy equation to only show the brands that were selected in Q1.Since this would get tedious if a person selected a lot of brands at Q1, I would like to randomly only ask 3 of Q1-10. It is easy to ask all brands selected in Q1 if number selected <4 but I am struggling on how to best do this.I followed the logic of  Can I select a random answer from a multiple choice question  but is only selects 1option. I assume I have to:
  • use an equation to: count the number of answers {count(that.Q1)}
  • Randomly select 3 of the brands form the total number selected
  • Populate a copy of Q1 that now has only 3  selections
While I think that is what I need, I am not sure how to do it.Any ideas? 


My alternative was to have the 10 brand questions each in a separate group and randomize the groups. I would then have a counter add +1 every time a brand was evaluated. Once 3 brands were evaluated, the rest of the brands would be skipped. But I could not get that to work. 

This does not seem like a new problem but I can't seem to find a solution
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 weeks ago #214399 by Joffm
Hi,
yes the solution you found is for only one random number; but you may extend it to several (there is a big example in the German section)

But better to use this javascript (originally from tpartner).
[url] forums.limesurvey.org/forum/can-i-do-thi...tion?start=15#194648 [/url]
I adapted it to your desired three numbers.
 

File Attachment:

File Name: limesurvey...3994.lss
File Size:27 KB


Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • drrwj01
  • drrwj01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 weeks ago #214441 by drrwj01
Thanks Joffm! That works perfectly for my needs. I knew it should be possible but I was going around in circles
The topic has been locked.
  • drrwj01
  • drrwj01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 2 weeks ago #214509 by drrwj01
If I want to select from a sub-set of the items in the multi-select question, I know I can populate a new multi-select with just the items I want to use with an equation but I assume I would need to modify the javascript so that it would work on a multi-select that was populated from another question rather than from an actual input.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #214517 by tpartner
Can you attach a small sample survey (.lss file) containing only the relevant questions?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • drrwj01
  • drrwj01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 2 weeks ago #214525 by drrwj01
Here is the lss
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #214531 by Joffm
Hi,
did you have a look at the source code of the equation?
Code:
<p style="margin:0cm; text-align:start; -webkit-text-stroke-width:0px"><span style="font-size:medium"><span style="font-family:Calibri, sans-serif"><span style="caret-color:#000000"><span style="color:#000000"><span style="font-style:normal"><span style="font-variant-caps:normal"><span style="font-weight:normal"><span style="letter-spacing:normal"><span style="orphans:auto"><span style="text-transform:none"><span style="white-space:normal"><span style="widows:auto"><span style="word-spacing:0px"><span style="-webkit-text-size-adjust:auto"><span style="text-decoration:none"><span style="font-size:13.5pt"><span style="font-family:-webkit-standard, serif"><span style="color:black">{Q1_A1 = Q0_A1,Q1_A2 =Q0_A2,Q1_A3 = Q0_A3,Q1_A5 = Q0_A5}</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>

There should only be plain, plain, plain text.

Second:
you separated the assignments by comma.
{Q1_A1 = Q0_A1,Q1_A2 =Q0_A2,Q1_A3 = Q0_A3,Q1_A5 = Q0_A5}
No, these are different assignments
{Q1_A1 = Q0_A1}
{Q1_A2 = Q0_A2}
{Q1_A3 = Q0_A3}
{Q1_A5 = Q0_A5}


If you change this it seems to do what you like to have.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #214532 by Joffm
No, not exactly.

But you may replace these lines
Code:
        $('input:checkbox', thisQuestion).on('change', function(e) {
            handleChecked();
        });

by
Code:
          handleChecked();

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • drrwj01
  • drrwj01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 2 weeks ago #214536 by drrwj01
Sorry the equation got messed up when I copied it into the new lss.

Yes, this now populates the Q1 with selected items from Q0 and allows for the random selection from Q1. Just need to figure out how to hide Q1 from respondents as if I hide the question it will not do the random selection. Usually don't do anything this complicated.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #214537 by Joffm
css class "hidden"

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • drrwj01
  • drrwj01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 2 weeks ago #214541 by drrwj01
Thanks, was just reading up on the difference between using css classes and the default toggle.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose