# Randomly Select Question Groups

3 years 9 months ago #145897 by KMC
I see in the forums ways to randomly select individual questions. How have people set up to randomly select groups of questions?

I have 200 items in a pool, which are organized into 18 groups of questions. The question groups must remain intact. We want each participant to answer 6 groups of questions. We want all possible combinations of groups to be included in our large community sample.

LimeSurvey Partners
3 years 9 months ago #145898 by holch
It is basically the same as for the questions. You need to create a random number. As you have 18 groups, you need to create a random number from 1-18 for example and then hide and show the question groups via relevance equation depending on this random number.

This is the easy part. Your problem is that you want to show 6 groups out of 18, not 1 out of 18. You could create 6 random numbers, but you would need to find a way so that each number can only be chosen once, because I assume that you don't want to show always the same 6 questions groups.

However, I remember that I have just seen a workaround by Olle this or last week on the forum, where you could draw X question randomly from a pool of questions. I think it was done by having 1 group with the number of questions to draw and another group with the rest of the questions. Then all those questions would go into the same randomization group. Obviously this workaround won't work with groups.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

3 years 9 months ago #145899 by KMC
Replied by KMC on topic Randomly Select Question Groups
Thanks Holch. I want to do something that doesn't seem to be supported the same way it is for questions.

I'm not sure if I understand. The number of random combinations of groups vastly exceeds 18, so if I were to enumerate each combination and using a relevance equation based on that random number it would be a awkward.

Yes, I am looking for a way to show only the 6 of the groups. That's exactly my problem.

It does look the the workaround that you cite is only relevant to selection or questions, which is not what need. I need to select groups.

3 years 9 months ago #145901 by holch
Yes, the workaround "as is" will only work for questions, because it requires groups.

I just thought you might be able to take this as inspiration. But I have my doubts that there would be a simple solution.

Somehow you would need to create 6 random numbers but you would need to guarantee that they are unique. The uniqueness is the main problem. Maybe someone who is a little more savy with programing finds a solution.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

3 years 9 months ago #145902 by KMC
Replied by KMC on topic Randomly Select Question Groups
One thing I started to try was randomizing group order and then hiding the groups after the 6th group is presented.
I wasn't able to set a variable that would correctly count how many groups had preceded a particular group. To use that approach I initially set the variable to 1 in a fixed group at the start of the survey. Then I added an equation in each group that added 1 to that constant. I set relevance equations for each group to condition on that variable to remain below 7. However, I couldn't get the lime to count up to 7 as hoped.

3 years 9 months ago #145950 by tpartner
You should be able to use the relevanceStatus variable something like as follows. (this example is for a 5-group survey, displaying only 3 groups)

1) Randomize the group order

2) In each group, precede the visible questions with a hidden equation question (equation1, equation2...) containing something like this (varies by group). The equation creates a sum using the relevanceStatus of questions in the other groups.
`{sum(Q2.relevanceStatus, Q3.relevanceStatus, Q4.relevanceStatus, Q5.relevanceStatus)}`

3) Place relevance on the visible questions, referencing their corresponding equation questions something like this:
`equation1 LT 3`

Sample survey attached:

#### File Attachment:

File Name: limesurvey...4146.lss
File Size:22 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
##### Attachments:
The following user(s) said Thank You: holch, Jane

3 years 9 months ago - 3 years 9 months ago #145952 by holch
Ha! I knew someone like Tpartner will come up with a solution!

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 3 years 9 months ago by holch.

3 years 9 months ago #145969 by KMC
Replied by KMC on topic Randomly Select Question Groups
Thanks. That does work. It's a painful workaround as we have several question pools (200+ items) that are still being developed with new items and items are being rearranged across groups. If the logic can be applied at the group level rather than at the time level, it would be a nice additional feature for limesurvey.

3 years 9 months ago #145983 by KMC
Replied by KMC on topic Randomly Select Question Groups
TP,
We are running into what looks like idiosyncratic barriers on getting this implemented. We don't have the bandwidth to continue to learn/troubleshoot. Are you available for hire?

3 years 9 months ago #145992
There are a little icon at bottom of tparter profile : www.limesurvey.org/component/uddeim/?task=new&recip=11021

Maybe you can use www.limesurvey.org/profile/emailuser?uid=11021 too.

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: tpartner

5 months 3 weeks ago - 5 months 3 weeks ago #195973 by Jane
Thanks Tony!

A small improvement: you can also use the relevanceStatus of the equations in the other groups in each equation. For instance use in equation2:
`{sum(equation1.relevanceStatus, equation3.relevanceStatus, equation4.relevanceStatus, equation5.relevanceStatus)}`

Then you are independent of the other questions in the groups. Proof of concept:

https://survey.toolsforresearch.com/index.php/survey/index/sid/354146/newtest/Y/lang/en

#### File Attachment:

File Name: limesurvey...4146.lss
File Size:28 KB
##### Attachments:
Last edit: 5 months 3 weeks ago by Jane.
The following user(s) said Thank You: Matherion

5 months 3 weeks ago #195991 by Jane
@tpartner I have written a blog entry on our site:

Limesurvey: Randomly show x out of y question groups

The equation question in each random group can be huge if there are a lot of groups in the Randomization group. At the moment we are speaking of 160 groups in the same Randomization group!

Is there a way to shorten that? Or even make the equation the same for each random group? I have already tried things like calculating the sum of all equation.RelevanceStatuses and subtracting the current equation.RelevanceStatus but did not succeed.
The following user(s) said Thank You: Matherion

5 months 3 weeks ago #196022 by tpartner
Sorry, I can't think of anything within Expression Manager that will allow you to shorten it.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: Jane

5 months 1 week ago #196692
Because we're working on a survey with ~ 275 groups, I tried to find a way that's more scalable. By using the {self.gsec} variable and storing its value in an equation question within each group, and then checking whether that value is still lower than the desired number of questions (adding/subtracting what is needed given preceding groups), you eliminate the need to sum increasingly long strings.

In the example, there's a slider question resulting in a numerical value stored in {nrOfQuestions_nr}; every group contains a {group1seq} equation question that contains {self.gseq}; and all the questions in that group have as relevance equation {group1seq <= nrOfQuestions_nr} (in this example, the only preceding group is the one with the slider, and since {self.gseq} starts counting at 0, that works out nicely without the need for additional subtraction or addition).

I would have preferred this to be safer/more scalable/more maintainable by using as relevance equation {self.gseq <= nrOfQuestions_nr}, but for some weird reason that doesn't work. Anybody have any ideas why that could be? Shouldn't all values available in equation questions also work in relevance equations, since both use the expression manager?

I've attached an example survey that implements this.