Welcome to the LimeSurvey Community Forum

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

Randomly Select 2 Answers from a previously answered multiple choice question.

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
1 year 5 months ago #233970 by davebostockgmail
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.4.11+221114
Own server or LimeSurvey hosting: Own Server
Survey theme/template: Fruity (Customised Variant)
==================

Hopefully just a quick one here ... I have searched the forums for this and I think I have seen the answer before but I cannot find it (I can find multiple answers to selecting one answer)

Basically, I have an array of questions that when answered populates a hidden multiple choice question (the survey is in question by question mode).

This is followed up by 2 "why did you say that" open ended questions ....

What I need to do is as follows ...

Example : 
Please Tell me how much you like the following where 1 is very much and 3 is not at all
Apples
Bananas 
Oranges
Pears

All answering 1 will populate the multi code question ...

I would then like to select up to 2 of these from the multiple choice at random if they are selected .. if it is just 1 or 2 then both are selected ...

Now the twist ... if Oranges is selected regardless of other selections then it should always be chosen as one of the selections (prioritised)

So if I select Apples, Oranges and Pears then it should be Oranges and one of Apples or Pears at random etc.

Thanks in advance for your help 





 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 5 months ago #234012 by Joffm
Hi,
here a solution without javascript, only some equation.
Result is a hidden multiple question with the two items selected.

File Attachment:

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


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: davebostockgmail

Please Log in to join the conversation.

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
1 year 5 months ago #234014 by davebostockgmail
Thanks Joffm ... this is exactly what I needed.

Dave

Please Log in to join the conversation.

More
2 months 1 week ago #256136 by Payek
Your LimeSurvey version: 3.28.77+231213
Own server or hosting LimeSurvey: Own server
Survey topic/template: Fruity
==================================

Hello everyone!
I found this very elegant solution and I'm trying to apply it to my scenario, but my programming skills are "limited", so please help.
In my scenario I have 8 answers from which I want to select 3 (if at least 3 are selected):
LIST 1

a - always if checked

LIST 2
b - firstly from this list if checked
c
d

LIST 3
e - secondary from this list if checked
f
g
h

How can I extend the current solution by counting the answers from LIST 1 and 2 and if <3, adding the answer (drawing) from LIST 3?
Thank you in advance for your help and tips!

Pawel

PS I'm adding the original, working file because my results were nothing but a mess.
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 1 week ago #256140 by Joffm
Hi,
First, this is not the general solution for this (select x out of y only with ExpressionScript)

Therefore, please send a lss export of your real scenario.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
2 months 1 week ago #256141 by Payek
@Joffm thank you for your reply. I attached lss with this part of scenario. There is open text question with draw rules.
Maybe i can (should) use other solution, if yes point me please in right direction.

THX!
Pawel

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 1 week ago - 2 months 1 week ago #256142 by Joffm
Well, in the meantime I created a sample survey.
 

File Attachment:

File Name: limesurvey...37_J.lss
File Size:38 KB


Well, you showed an array before.
Now it is a multiple question.
But you only have to change the conditions
if(Q1_SQ001==1,...
to
if(P1_SQ001=="Y",...




Joffm

Later I will improve your sample.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 months 1 week ago by Joffm.
The following user(s) said Thank You: DenisChenu, Payek

Please Log in to join the conversation.

More
2 months 1 week ago #256144 by Payek
Thank you again!
Sorry, I forgot tell you about change array for multiple answers - I'll change conditions, tried this before and it was works.

Pawel

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose