Welcome to the LimeSurvey Community Forum

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

Random assignment of Question A/B

  • lime_user_22
  • lime_user_22's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 9 months ago - 7 years 9 months ago #136600 by lime_user_22
Random assignment of Question A/B was created by lime_user_22
Hi there,

I have one question in my survey that should be preceded by two versions of a text (A/B ). The text is in a "text display" question type. I want either version A or version B to be shown randomly to participants.
Therefore I created a random number as {rand(1,2)} and set it up in the previous group as "equation" question type. The next question group then has the questions/texts A and B with the relevance as ((randnumber=="1")) or "2" respectively.
So that, if the hidden random number question generates "1", text A should be shown. And if it generates "2", text B should be shown.

So far, everything works brilliantly. However, when I go to test the survey (and leave the random number as "not hidden" for now to check), I can see that it sometimes does not link correctly to question A or B. Instead, the random number is sometimes generated as "1", but it shows text B (and not text A, as it actually should).

I have tried setting up the random number generation in the same question group or in the previous question group, I have tried it with marking the question following the A/B texts as mandatory or not mandatory, but so far nothing helps.

It is basically exactly the same as the problem as described here in German: www.limesurvey.org/forum/installation-a-...e-bei-if-bedingungen
This thread recommends to make sure that no additional random number is generated somewhere that might interfere with the questions' relevance, but I can't figure out how to do that...

Version 2.05, Build 150413, Chrome 49.0.2623.112 m

I would really appreciate any help or tips.
Many thanks in advance
Leonie
Last edit: 7 years 9 months ago by lime_user_22. Reason: clarification
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #136612 by holch
Replied by holch on topic Random assignment of Question A/B
Is the equation on the same page? If I recall right, the equation is fired on each instance. So this can happen.

I am sure that are threads covering this problem in the forum.

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

The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #136613 by holch
Replied by holch on topic Random assignment of Question A/B
You'll probably need something like:
Code:
{if(is_empty(G1Q1),floor(rand(1,2)),G1Q1)}

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

The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #136614 by holch
Replied by holch on topic Random assignment of Question A/B
And: You have an old version of LS, so their might be bugs that have been solved already, so it is quite hard to help you.

At the moment you can upgrade to 2.06 LTS which is pretty stable, or 2.5 which has a new interface but still has some hickups now and then and received quite a few updates every couple of days.

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

The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #136615 by holch
Replied by holch on topic Random assignment of Question A/B
Here a working example that you should be able to find in one of the threads about the topic on the English forum.

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

The topic has been locked.
  • lime_user_22
  • lime_user_22's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 9 months ago #136846 by lime_user_22
Replied by lime_user_22 on topic Random assignment of Question A/B
Thanks for the quick reply!
The randomization is on the same page, but when I tried it on the previous page it gave me the same problem. I'm really new to Lime Survey and programming, so any further help would be much appreciated.

I tried this {if(is_empty(G1Q1),floor(rand(1,2)),G1Q1)} , but it only works once for every text version, when I test it for the third time it doesn't show any text at all. Am I missing something here?

Unfortunately, I can't upgrade to a newer version of LS since I am using a University access...
Somehow I cannot open .lss files on my computer, is there any other way you could show me?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #136852 by holch
Replied by holch on topic Random assignment of Question A/B
What do you mean it only works "once" for every text version? You said the respondent needs to see either text A or text B...

You need to import the .lss file into your Limesurvey account. It is an exported Limesurvey survey that shows what I did.

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

The topic has been locked.
  • lime_user_22
  • lime_user_22's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 9 months ago #136980 by lime_user_22
Replied by lime_user_22 on topic Random assignment of Question A/B
I was using the wrong question code... But I followed the example you gave and got it to work now.
Thank you so much! :)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose