- Posts: 22
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
show n out of x questions and follow-up questions
- gsoto
- Topic Author
- Offline
- Junior Member
Less
More
6 years 4 months ago - 6 years 4 months ago #161857
by gsoto
show n out of x questions and follow-up questions was created by gsoto
I have 8 questions in a group. To each participant, 2 of the 8 questions should by shown at random. Also, for each of the 2 questions that are shown, a follow-up question should also be shown. I have arranged the questions in the following way:
q1
q1follow-up
q2
q2follow-up
…
q8
q8follow-up
I have tried the solution using relevanceStatus and a randomization group ( www.limesurvey.org/forum/can-i-do-this-w...stion-out-of-a-group ). For the follow-up questions, I have assigned the relevanceStatus of the "mother question" as relevance equation (so e.g. q1follow-up has a relevance equation of q1.relevanceStatus).
What works:
Some of the question orders I have ended up with (A, B are the questions and a, b are the corresponding follow-up questions):
q1
q1follow-up
q2
q2follow-up
…
q8
q8follow-up
I have tried the solution using relevanceStatus and a randomization group ( www.limesurvey.org/forum/can-i-do-this-w...stion-out-of-a-group ). For the follow-up questions, I have assigned the relevanceStatus of the "mother question" as relevance equation (so e.g. q1follow-up has a relevance equation of q1.relevanceStatus).
What works:
- 2 of 8 questions are shown at random
- the corresponding follow-up questions for the 2 randomly shown questions are also shown
- the follow-up questions are shown in weird positions
Some of the question orders I have ended up with (A, B are the questions and a, b are the corresponding follow-up questions):
- q4, q8, q4follow-up, q8follow-up (ABab) – this is the most frequent situation
- q8, q6, q6follow-up, q8follow-up (ABba) – happens sometimes
- q5, q1follow-up, q1, q6follow-up (AbBa) – happens rarely, but it's bad, because a follow-up question is shown before its "mother question"
- q5, q5follow-up, q1, q1follow-up (AaBb) – each question is directly followed by its follow-up question
Last edit: 6 years 4 months ago by gsoto. Reason: typo
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
6 years 4 months ago #161860
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic show n out of x questions and follow-up questions
Hi, gsoto,
to select randomly 2 out of 8 questions (with the follow up) you can do the following:
There are 28 ways to select 2 out of 8 (8 over 2).
1-2, 1-3, 1-4, 1-5 ,1-6 ,1-7, 1-8, 2-3, 2-4, 2-5, 2-6, 2-7, 2-8, 3-4, 3-5, 3-6, 3-7, 3-8, 4-5, 4-6, 4-7, 4-8, 5-6, 5-7, 5-8, 6-7, 6-8, 7-8
So you could create a random number (1-28) and display by relevance.
Like:
Q2, relevance equation: (randnbr==1) or (randnbr== or (randnbr==9) or (randnbr==10) or (randnbr==11) or (randnbr==12) or (randnbr==13)
...
Q5, relevance equation: (randnbr==4) or (randnbr==10) or (randnbr==15) or (randnbr==19) or (randnbr==23) or (randnbr==24) or (randnbr==25)
...
The follow-ups analogue.
Well, that will do it.
But, if you want to display randomly Q2->Q5 or Q5->Q2, I have no idea
Regards
Joffm
to select randomly 2 out of 8 questions (with the follow up) you can do the following:
There are 28 ways to select 2 out of 8 (8 over 2).
1-2, 1-3, 1-4, 1-5 ,1-6 ,1-7, 1-8, 2-3, 2-4, 2-5, 2-6, 2-7, 2-8, 3-4, 3-5, 3-6, 3-7, 3-8, 4-5, 4-6, 4-7, 4-8, 5-6, 5-7, 5-8, 6-7, 6-8, 7-8
So you could create a random number (1-28) and display by relevance.
Like:
Q2, relevance equation: (randnbr==1) or (randnbr== or (randnbr==9) or (randnbr==10) or (randnbr==11) or (randnbr==12) or (randnbr==13)
...
Q5, relevance equation: (randnbr==4) or (randnbr==10) or (randnbr==15) or (randnbr==19) or (randnbr==23) or (randnbr==24) or (randnbr==25)
...
The follow-ups analogue.
Well, that will do it.
But, if you want to display randomly Q2->Q5 or Q5->Q2, I have no idea
Regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: gsoto
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
6 years 4 months ago #161865
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic show n out of x questions and follow-up questions
If the questions are mandatory, you could...
1) Place each pair in a separate group.
2) Randomize the group order.
3) In group relevance, use the Expression Manager count() function to detect how many questions have already been answered.
So, for example, with 4 groups, the relevance for Group 1 is:
The relevance for Group 2 is:
The relevance for Group 3 is:
The relevance for Group 4 is:
Sample survey attached.
1) Place each pair in a separate group.
2) Randomize the group order.
3) In group relevance, use the Expression Manager count() function to detect how many questions have already been answered.
So, for example, with 4 groups, the relevance for Group 1 is:
Code:
{count(Q2, Q3, Q4) < 2}
The relevance for Group 2 is:
Code:
{count(Q1, Q3, Q4) < 2}
The relevance for Group 3 is:
Code:
{count(Q1, Q2, Q4) < 2}
The relevance for Group 4 is:
Code:
{count(Q1, Q2, Q3) < 2}
Sample survey attached.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: gsoto
The topic has been locked.
- gsoto
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 1
6 years 3 months ago #161871
by gsoto
Replied by gsoto on topic show n out of x questions and follow-up questions
Thanks for both your replies.
@Joffm: I had used this method in an earlier survey. However, I would have done it with a random number (1-56), not realizing that half of them would be duplicates (e.g. 1-2 and 2-1, which results in the same if the order of the questions is fixed). I was hesitant to use this method again though, because it's quite time-consuming to implement, and I'm looking for an as-simple-as-possible way to do this in the future. The beauty of the solution using relevanceStatus (link in my first post) is that you can easily change your mind about the n (if you want to show 3 out of 8 instead of 2 out of 8, just change LT 2 to LT3 in the relevance equation of each question). For this particular situation with follow-up questions however, I'm probably better off using the method you suggested.
@tpartner: Unfortunately, the questions aren't mandatory, so your solution won't work. It's not possible to get the relevanceStatus of a question group, right? This would allow me to adapt the relevanceStatus method on a group level.
@Joffm: I had used this method in an earlier survey. However, I would have done it with a random number (1-56), not realizing that half of them would be duplicates (e.g. 1-2 and 2-1, which results in the same if the order of the questions is fixed). I was hesitant to use this method again though, because it's quite time-consuming to implement, and I'm looking for an as-simple-as-possible way to do this in the future. The beauty of the solution using relevanceStatus (link in my first post) is that you can easily change your mind about the n (if you want to show 3 out of 8 instead of 2 out of 8, just change LT 2 to LT3 in the relevance equation of each question). For this particular situation with follow-up questions however, I'm probably better off using the method you suggested.
@tpartner: Unfortunately, the questions aren't mandatory, so your solution won't work. It's not possible to get the relevanceStatus of a question group, right? This would allow me to adapt the relevanceStatus method on a group level.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
6 years 3 months ago #161882
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic show n out of x questions and follow-up questions
No, there is no variable for group relevance status.
A workaround would be to insert a hidden (via CSS class) question into every group with a default answer. Then you could count those questions.
Something like:
Sample survey attached:
A workaround would be to insert a hidden (via CSS class) question into every group with a default answer. Then you could count those questions.
Something like:
Code:
count(hidden2.NAOK, hidden3.NAOK, hidden4.NAOK) < 2
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- gsoto
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 1
6 years 3 months ago #161898
by gsoto
Replied by gsoto on topic show n out of x questions and follow-up questions
Following a suggestion by a co-worker, I now implemented a solution based on random numbers, but simpler than rand(1-28). The solution uses three numbers randomA, randomB and randomC.
randomA: rand(1-
randomB: rand(1-7)
randomC: if(randomA + randomB > 8, randomA + randomB - 8, randomA + randomB)
Then for each question 1…n, use the following relevance equation: randomA == n or randomC == n
This ensures that 2 out of 8 question are shown at random. The order of the questions is fixed though, as Joffm already noted. The advantage is that all the questions can be on one page. Tony's solution would ensure true randomness (including in the order) and easy adaptation to e.g. 3 out of 8 questions, but forces me to have the questions in different groups. It's a trade-off, both solutions work – so thanks again for the suggestion!
randomA: rand(1-
randomB: rand(1-7)
randomC: if(randomA + randomB > 8, randomA + randomB - 8, randomA + randomB)
Then for each question 1…n, use the following relevance equation: randomA == n or randomC == n
This ensures that 2 out of 8 question are shown at random. The order of the questions is fixed though, as Joffm already noted. The advantage is that all the questions can be on one page. Tony's solution would ensure true randomness (including in the order) and easy adaptation to e.g. 3 out of 8 questions, but forces me to have the questions in different groups. It's a trade-off, both solutions work – so thanks again for the suggestion!
The topic has been locked.