Welcome to the LimeSurvey Community Forum

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

How to randomize entire pages

  • Manon_Weinand
  • Manon_Weinand's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 3 months ago #239514 by Manon_Weinand
How to randomize entire pages was created by Manon_Weinand
Dear all, 

I need to do a survey for my master thesis, and I have 4 different scenarios. I need for LimeSurvey to assigne randomly each participant to one of the scenario (and thus NOT showing the 3 others). 
As I understood from previously answered questions, I need to ask LimeSurvey to generate a random number, using an equation type question. That's where I don't understand: people keep saying that I have to put the code "{if(is_empty(randnumber.NAOK), rand(1,4), randnumber.NAOK)}" and to put "randnumber" in the equation code BUT as LimeSurvey tells me, the equation code is a unique identifyer and thus I cannot put "randnumber" there... I thus don't understand where to put the "randnumber". 

I also don't understand how LimeSurvey will randomly assign the scenarios afterwards, can someone explain that to me? 

Thank you very much for your help (as you can see I'm a bit lost ^^)

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 3 months ago - 1 year 3 months ago #239516 by Joffm
Replied by Joffm on topic How to randomize entire pages
Because of your username, it could be that you speak German.
Then take a look at my "Tutorial 4: Zufall und andere Fälle", Chapter 2
You find it in the German part of the forum.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 3 months ago by Joffm.

Please Log in to join the conversation.

  • Manon_Weinand
  • Manon_Weinand's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 3 months ago #239519 by Manon_Weinand
Replied by Manon_Weinand on topic How to randomize entire pages
Dear Joffm,

Unfortunately I don't speak German (even though my last name is indeed German). I thus have this issue in English
(and sorry fot eh mutliple posts, I had a problem with my computer)

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 3 months ago #239520 by Joffm
Replied by Joffm on topic How to randomize entire pages
Well,
so again explained.
You use a question of type "equation" to
  • create a new variable and fill it 
  • assign a calculated value to another variable
You do the first.
If you create a question of type "equation" the calculated value of the equation is stored in the database in column "[questioncode]"
Example: 
A question with questioncode "ABCD" and this questiontext {sum(1,sqrt(9))}  will store "4" in variable "ABCD".
All function you find here
[url] manual.limesurvey.org/ExpressionScript_-...mplemented_functions [/url]

Exactly this you do to create your random number.
Create a question of type "equation" (let's call it "randnbr") and enter the shown function 
{if(is_empty(randnbr),rand(1,4),randnbr)}


Why do we recommend this construct?
As you can easily reproduce in Excel the random number changes with every mouse click in the page.
So if the question to generate the random number is inside a group with other questions the number is changed each time the respondent clicks.
Or if it is possible to go back in the survey and the question is touched again.
Therefore this IF: IF the random number is still empty fire the function "rand(x,y)", otherwise let the number as it was.
This structure of the IF is the same as in Excel.

As I wrote before this generated random number is stored in variable "randnbr".
It is a good idea to activate a survey, enter some well defined data and have a look at the answer table.
You get a lot of insight how variables are called and how data are stored.
Afterwards you stop the survey again.

And now the distribution of your respondents.
You know about "relevance equation" resp. "condition". The wording depends on your version of LimeSurvey.
Unfortunately you ignored the initial questions. The are not asked just for fun. 

This "condition" is logical term that is either TRUE or FALSE.
If TRUE the group/question/subquestion is displayed, if FALSE not.

Now in the field "relevance equation" / "condition" of your four groups you enter the condition to show it.
In group 1: randnbr==1, meaning: If the generated random number (randnbr) is equal 1 the condition is TRUE -> the group is displayed, otherwise it is hidden.
In group 2: randnbr==2
​​​​​​​In group 3: randnbr==3
​​​​​​​In group 4: randnbr==4

​​​​​​​This group level relevance you may study in one of the sample surveys
[url] manual.limesurvey.org/ExpressionScript_s...eys/en#Sample_Census [/url]

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • Manon_Weinand
  • Manon_Weinand's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 3 months ago #239521 by Manon_Weinand
Replied by Manon_Weinand on topic How to randomize entire pages
Dear Joffm,

Thank you so much for your answer, I managed to do it (both the equation question and the assignment of a number to each scenario).
However now the number is generated but when I start a previous of the survey, none of the scenario appear, is it possible that I missed something?

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 3 months ago #239525 by Joffm
Replied by Joffm on topic How to randomize entire pages
Obviously you missed something.
So send a lss export of the survey.

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • Manon_Weinand
  • Manon_Weinand's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 3 months ago #239526 by Manon_Weinand
Replied by Manon_Weinand on topic How to randomize entire pages
Here you are:
Again, thank you for your help !
 

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 3 months ago #239527 by holch
Replied by holch on topic How to randomize entire pages

However now the number is generated but when I start a previous of the survey, none of the scenario appear, is it possible that I missed something?


I was a little confused by the word "previous", but after importing your survey I guess you meant "preview".

If you look at the error message it becomes quite clear what the problem is, just read it, it is all there:

This survey cannot be tested or completed for the following reason(s):
There are empty question groups in this survey - please create at least one question within a question group.


You can't have empty groups, each group needs at least one question to be previewed.

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

Please Log in to join the conversation.

  • Manon_Weinand
  • Manon_Weinand's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 3 months ago #239528 by Manon_Weinand
Replied by Manon_Weinand on topic How to randomize entire pages
Dear holch,

Thank you for your answer. I just added random questions to the survey and it still does'nt work.
I'll give you the Iss file here to check it again.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 3 months ago - 1 year 3 months ago #239529 by Joffm
Replied by Joffm on topic How to randomize entire pages
There is HTML garbage in your equation
 
So the result is not just a number 1-4, but a number followed by something.

Here you see. The first record with your equation, the second after I removed the <p></p>
You see the small difference in alignment
 

If you display it (surrounded by #) you see this
#3    #
 You see the blanks.

This means: The comparison with a number will fail.

So remove the <p></p> 

Joffm

And to add something.
Is there a special reason that you always use questions of type "multiple", though it is obviously a single punch question (demographics).
Is it allowed to select several answers?
 
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 3 months ago by Joffm.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 3 months ago #239530 by holch
Replied by holch on topic How to randomize entire pages
Didn't even look further after seeing the clear error message. ;-)

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

Please Log in to join the conversation.

  • Manon_Weinand
  • Manon_Weinand's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 3 months ago #239531 by Manon_Weinand
Replied by Manon_Weinand on topic How to randomize entire pages
Dear Joffm,

Thank you so much you made my day (and my entire thesis)!!
I understood what the problem was, but how come there were these garbage in my HTML code?

I wish you a wonderful day!!

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose