Hi,
I try to create something that will assign participants randomly to one of 4 groups, but I don't get it to work.
I work with LS 1.91, so I cannot add "question type equation". I have found some solutions, but I run into problems, so I think I make a mistake somewhere.
The following script I adjusted from another forum post (which can be found here
www.limesurvey.org/en/forum/can-i-do-thi...-the-others?start=10)
<script type="text/javascript">
<!--
$(document).ready(function()
{
// Find a random number between 1 and 4
var randNumber = Math.floor(Math.random()*3 + 1);
$('input#answer96682X129523X1961293').val(randNumber);
checkconditions(randNumber,'96682X129523X1961293','text');
})
//-->
</script>
where 96682 is Survey ID, 129523 is Group ID, 1961293 is Question ID)
In the next question group I created 4 questions, and depending on the random "answer" participants would get one of the 4 questions (by adding the condition "answer to 'random' question equals 1" --> question 1; "...equals 2" --> question 2, etc.). This seems to work.
When I try to hide this question, however, it does no longer work (the question is hidden, but the questions following this question are not shown either).
Also, if I have 4 groups, is the "Math.floor(Math.random()*3 + 1)" correct, or should it be "Math.floor(Math.random()*4 + 1)" (as is shown in the link below). And are the random numbers obtained than 1 2 3 and 4 or 0 1 2 and 3? I have tested the above solution a number of times, but only got 1 2 or 3 as a response. Not sure if that is just coincidence, or that I actually only create those 3 numbers.
This is another solution that I found, but it did not work for me:
docs.limesurvey.org/tiki-index.php?page=...rol_survey_behaviour
I hope someone can help!
Many thanks in advance!