Welcome to the LimeSurvey Community Forum

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

Random assignment to conditions

More
9 years 9 months ago #109707 by fiona92
Replied by fiona92 on topic Random assignment to conditions

tpartner wrote: Well, you can use the {SUBMITID} variable (which is available AFTER the first page submission) and the JavaScript modulus operator to load a hidden short-text question with sequential numbers between 1 and 4.

Note though, that the sequential number will increment with every respondent, even those who don't complete the survey.

Add this script to the source of a short-text question:

Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() { 
 
    var submitID = {SAVEDID};
 
     // Hide this question
    $('#question'+qID).hide();
 
    // Find sequential number between 1 and 4 based on the SUBMITID
    var conditionNumber = (submitID % 4) + 1;
 
     // Load the hidden question
    $('#question'+qID+' input.text').val(conditionNumber);
  });
</script>

.


I don't know where to fill in this script?
After the first page submission.... So after the first question is filled in, by the second question fill in this script? Of by the first question, after the page with welcome and intructions? And how do i make the different questionaires for the three groups?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 9 months ago - 9 years 9 months ago #109735 by tpartner
Replied by tpartner on topic Random assignment to conditions

After the first page submission.... So after the first question is filled in, by the second question fill in this script?

Place the script in the source of a short-text question on a page AFTER the first QUESTION PAGE has been submitted.



And how do i make the different questionaires for the three groups?

See conditions or relevance - manual.limesurvey.org/Setting_conditions .


.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 9 months ago by tpartner.
The topic has been locked.
More
8 years 11 months ago #118648 by esyild
Replied by esyild on topic Random assignment to conditions
I need your help.

I have two different questions and I want the survey tool to show one question at a time randomy. I want to assign my participants to the survey randomly. That is why I used the equation question type with rand(1,2) function. The test survey works perfectly. But when I activate it, it stuck on one condition and only shows the same question for everytime.

Do you know why it happened??

Thanks a lot.

Kind Regards,
The topic has been locked.
More
6 years 10 months ago - 6 years 10 months ago #152729 by simulacrum6
Replied by simulacrum6 on topic Random assignment to conditions
Probably not relevant anymore, but maybe some desperate limesurvey user will read this and rejoice:

Create a Question (myQuestion) of Type Equation. Set the Question Text to
Code:
{if( is_empty(myQuestion), rand(1,4), myQuestion )}

This will assign a random value between 1 and 4 to myQuestion, if it has not been previously assigned.
Last edit: 6 years 10 months ago by simulacrum6.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose