- Posts: 166
- Thank you received: 26
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
- Topic Author
- Offline
- Elite Member
Less
More
1 year 5 months ago #233970
by davebostockgmail
Randomly Select 2 Answers from a previously answered multiple choice question. was created 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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
1 year 5 months ago #234012
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomly Select 2 Answers from a previously answered multiple choice question.
Hi,
here a solution without javascript, only some equation.
Result is a hidden multiple question with the two items selected.
Joffm
here a solution without javascript, only some equation.
Result is a hidden multiple question with the two items selected.
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
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 166
- Thank you received: 26
1 year 5 months ago #234014
by davebostockgmail
Replied by davebostockgmail on topic Randomly Select 2 Answers from a previously answered multiple choice question.
Thanks Joffm ... this is exactly what I needed.
Dave
Dave
Please Log in to join the conversation.
- Payek
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 1
2 months 1 week ago #256136
by Payek
Replied by Payek on topic Randomly Select 2 Answers from a previously answered multiple choice question.
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 , 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.
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 , 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.
Attachments:
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
2 months 1 week ago #256140
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomly Select 2 Answers from a previously answered multiple choice question.
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
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.
- Payek
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 1
2 months 1 week ago #256141
by Payek
Replied by Payek on topic Randomly Select 2 Answers from a previously answered multiple choice question.
@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
Maybe i can (should) use other solution, if yes point me please in right direction.
THX!
Pawel
Attachments:
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
2 months 1 week ago - 2 months 1 week ago #256142
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomly Select 2 Answers from a previously answered multiple choice question.
Well, in the meantime I created a sample survey.
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.
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.
- Payek
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 1
2 months 1 week ago #256144
by Payek
Replied by Payek on topic Randomly Select 2 Answers from a previously answered multiple choice question.
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
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.