View Issue Details

This bug affects 1 person(s).
IDProjectCategoryView StatusLast Update
07433Feature requestsConditionspublic2021-11-15 08:40
Reporterbartsch Assigned Togalads  
Status acknowledgedResolutionopen 
Summary07433: random assignment of survey participants to conditions
DescriptionRandom assignment of participants to experimental conditions is a key issue in social science research. For example, a research design might involve randomized distribution of participants to different groups, each of which is presented with a different versions of a stimulus.

Therefore, I suggest to implement a feature in LimeSurvey that allows to randomly distribute survey participants to different groups. The randomly assigned "group membership" can then be used as a condition to show or hide certain questions (e.g., each group of participants is shown one of several boilerplate questions that include different version of a stimulus image or video).
Additional InformationA possible solution: create and autofill a random number
I would propose to implement a feature "randomized conditions" (or something like that) in the survey setup. For example, there could be a dice symbol, and when you click on this symbol, you would see a numerical input field where you could enter the number of groups/conditions needed.

If you enter that the number of randomized conditions should be X, then a Javascript in the survey would be customized such that it creates a random number in the range of 1 to X.

If the survey is executed, then the script would create a random number in the range of 1 to X, and would enter the value of the random number into a column of the results table.

The script below has been proposed at the forums as a workaround to do just that. In the workaround, the script is inserted in a question, e.g., a numerical input question. This question serves to open a column in the results table where the value of the random number can be entered by the scipt.

<script type="text/javascript">


        var randNumber = Math.floor(Math.random()*X + 1);



(where X is the number of Conditions needed, SSSS is the survey ID, GGG is the group ID, and QQQ is the Question ID of the numerical input question that contains the script)

If the script is implemented in a survey desing feature rather than in a question, then the feature would have to create a question first, as a container where the value of the random number can be entered by the script.

The question that serves as a container for the random number should be hidden from survey participants. This is not currently possible to do in Lime Survey 1.90+ (see the following bug report:

However, at the forums I found two ideas how to hide a question without preventing autofilled entries.

Idea 1:
Re: Prefill hidden fields or (hidden questions)
In config-defaults.php:
$deletenonvalues = 1; // By default, LimeSurvey does not save responses to conditional questions that haven't been answered/shown. To have LimeSurvey save these responses change this value to 0.
Copy to your config.php and set to 0.

Idea 2:
Re:Prefill hidden fields or (hidden questions)
Or just hide the questions with CSS. Add the following to the end of template.css (or whatever your style sheet is):
display: none;

Where QQ is the question ID.

Assuming that we have created a random number with values from 1 to X, and have entered the value of the random number as an autofilled entry to a hidden container question, then we have assigned a kind of randomized group membership identifier to each participant (i.e., the value of the random number).

Now, the next thing needed is a display in the conditions setup that allows to select the hidden container question (which might be labeled "randomized conditions," for example). Further, the condition setup should allow to select different values of the random number as conditions for showing or hiding other questions. Optimally, the X possible values of the random number would appear as predefined answers in the conditions setup.

TagsNo tags attached.
Bug heat2

Users monitoring this issue

User List There are no users monitoring this issue.




2010-09-18 13:04

reporter   ~24355

Working with conditions can be a pain. Both when setting up the survey but also when analysing the results.

It would I feel, be much simpler to just generate the random group membership locally (very easy in e.g. excel), split the participants list in to subsets based on group membershop and then just execute different surveys for each subset?

Issue History

Date Modified Username Field Change
2021-11-15 08:25 galads Assigned To => galads
2021-11-15 08:25 galads Status acknowledged => confirmed
2021-11-15 08:25 galads Status confirmed => acknowledged
2021-11-15 08:40 galads Status acknowledged => confirmed
2021-11-15 08:40 galads Status confirmed => acknowledged