Random assignment of Question A/B

More
3 years 10 months ago - 3 years 10 months ago #136600 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: https://www.limesurvey.org/forum/installation-a-update-issues/100282-random-%7Brand-1,4-%7D-berechnet-falsche-werte-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: 3 years 10 months ago by lime_user_22. Reason: clarification

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
3 years 10 months ago #136612 by holch
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'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #136613 by holch
You'll probably need something like:
{if(is_empty(G1Q1),floor(rand(1,2)),G1Q1)}

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #136614 by holch
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'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #136615 by holch
Here a working example that you should be able to find in one of the threads about the topic on the English forum.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Attachments:

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #136846 by lime_user_22
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?

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #136852 by holch
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'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #136980 by lime_user_22
I was using the wrong question code... But I followed the example you gave and got it to work now.
Thank you so much! :)

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!