- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Random assignment to conditions
- fiona92
- Offline
- New Member
Less
More
9 years 10 months ago #109707
by fiona92
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?
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
9 years 10 months ago - 9 years 10 months ago #109735
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 Random assignment to conditions
Place the script in the source of a short-text question on a page AFTER the first QUESTION PAGE has been submitted.After the first page submission.... So after the first question is filled in, by the second question fill in this script?
See conditions or relevance - manual.limesurvey.org/Setting_conditions .And how do i make the different questionaires for the three groups?
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 10 months ago by tpartner.
The topic has been locked.
- esyild
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
9 years 1 month 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,
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.
- simulacrum6
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
7 years 6 days ago - 7 years 6 days 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
This will assign a random value between 1 and 4 to myQuestion, if it has not been previously assigned.
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: 7 years 6 days ago by simulacrum6.
The topic has been locked.