tischer_s
OFFLINE
Fresh Lemon
Posts: 19
Karma: 0
Hi,
In my survey I have 16 treatments which are randomized via a rand(1;16) function.
Now I want to implement two hidden questions containing of the independant changed variables which are filled with numbers based on the random number.
In each treatment either the storage and/or the price is changed.
Here some examples:
Rand 1 -> storage: 2GB ; price: 0€
Rand 2 -> storage: 2GB ; price: 9,99€
Rand 3 -> storage: 2GB ; price: 19,99€
Now I want the variable price and storage and they should be hidden for the users but fill with numbers based on the values shown.
Rand 1 -> storage: 2 ; price: 0
Rand 2 -> storage: 2 ; price: 9,99
Rand 3 -> storage: 2 ; price: 19,99
Something like:
If randnumber=2, storag=2; price=9,99
This is no function but should cover what I want.
Can anoyone please help me with a function for this?
Best
Sebastian Tischer

JavaScript is currently disabled. Please enable it for a better experience of Jumi .
DenisChenu
OFFLINE
Moderator Lime
Posts: 6451
Thank you received: 844
Karma: 249
Hi,

Don't really understand your need here.

But you can use Equation question type and EM.

1st question RANDOM : {rand(1,3)}

Equation hidden question : {if(RANDOM== "1" or RANDOM== "2" or RANDOM== "3",2,"")}

etc ....

You can use one Equation question type and Assign a answer:

{ANDWER=if(RANDOM== "1" or RANDOM== "2" or RANDOM== "3",2,"")}

See :

manual.limesurvey.org/Expression_Manager

Last Edit: 3 months 3 weeks ago by DenisChenu . Reason: manual link

tischer_s
OFFLINE
Fresh Lemon
Posts: 19
Karma: 0
Hi DenisChenu,

I am sorry for not writing it more clearly.

I need to give an value to a variable based on the random number.

My questionnaire starts with a randomnumber generator (rand(1,16)). Then I have treatments which I only show when each randomized number is shown.

randnum 1 -> Treatment 1

randnum 2 -> Treatment 2

...

Each Treatment varies in price and storage. For a better export I want to have two new hidden "questions" where the number and storage of the treatment is in.

Like:

randnum 1 -> price: 0 storage: 2

randnum 2 -> price: 9,99 storage: 2

randnum 3 -> price: 19,99 storage: 2

Your expression is a good start unfortunately I don't know how to set a value as an answer...

{if(RANDOM== "1") then price=="0" and storage=="2"}

Is anything like this even possible?

Best and thank you very much

Sebastian

DenisChenu
OFFLINE
Moderator Lime
Posts: 6451
Thank you received: 844
Karma: 249
tischer_s wrote:
Your expression is a good start unfortunately I don't know how to set a value as an answer...
{if(RANDOM== "1") then price=="0" and storage=="2"}
Is anything like this even possible?

{ price= if ( RANDOM== "1" , 0 , 1 ) }
{ storage= if ( RANDOM== "1" , 2 , 1 ) } et ...

tischer_s
OFFLINE
Fresh Lemon
Posts: 19
Karma: 0
Hi DenisChenu,

Thanks a lot for your great help

This is exactly what I was searching for!

Only three questions:

1. how can I combine multiple statements like random=="1" and random=="2" etc?

2. what is the second number in the "1",0,1 statement?

3. how can I enter the number 9,99? Do I need a fullstop as separation?

Is this right?

{ price= if ( RANDOM== "1" , 0 , 1 ) , if ( RANDOM== "2" , 9 , 99 ) , if ( RANDOM== "3" , 19 , 99 }
{ storage= if ( RANDOM== "1" , 2 , 1 ) }

tischer_s
OFFLINE
Fresh Lemon
Posts: 19
Karma: 0
Hi again,

I am so sorry for disturbing you. Unfortunately I am not that technical knowledged thats why I am running into some trouble

I entered the following code now into my question field named "price":

{ price= if ( randnumber== "1" , "0" ,
if ( randnumber== "2" , "9,99" ,
if ( randnumber== "3" , "19,99" ,
if ( randnumber== "4" , "49,99" ,
if ( randnumber== "5" , "0" ,
if ( randnumber== "6" , "9,99" ,
if ( randnumber== "7" , "19,99" ,
if ( randnumber== "8" , "49,99" ,
if ( randnumber== "9" , "0" ,
if ( randnumber== "10" , "9,99" ,
if ( randnumber== "11" , "19,99" ,
if ( randnumber== "12" , "49,99" ,
if ( randnumber== "13" , "0" ,
if ( randnumber== "14" , "9,99" ,
if ( randnumber== "15" , "19,99" ,
if ( randnumber== "16" , "49,99" ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) }
Unfortunately it tells me that there is an extra comma in the function? Am I doing something wrong?

Thank you very much

Best

Sebastian

Last Edit: 3 months 3 weeks ago by tischer_s . Reason: Small typo

DenisChenu
OFFLINE
Moderator Lime
Posts: 6451
Thank you received: 844
Karma: 249
Because you allways need a 'if false' value.

{ price= if ( randnumber== "1" , "0" ,
if ( randnumber== "2" , "9,99" ,
if ( randnumber== "3" , "19,99" ,
if ( randnumber== "4" , "49,99" ,
if ( randnumber== "5" , "0" ,
if ( randnumber== "6" , "9,99" ,
if ( randnumber== "7" , "19,99" ,
if ( randnumber== "8" , "49,99" ,
if ( randnumber== "9" , "0" ,
if ( randnumber== "10" , "9,99" ,
if ( randnumber== "11" , "19,99" ,
if ( randnumber== "12" , "49,99" ,
if ( randnumber== "13" , "0" ,
if ( randnumber== "14" , "9,99" ,
if ( randnumber== "15" , "19,99" ,
if ( randnumber== "16" , "49,99" , "" ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) }

The following user(s) said Thank You:

tischer_s

tischer_s
OFFLINE
Fresh Lemon
Posts: 19
Karma: 0
Hi again,

thank you sooo very much for your great help! Now the equation is working without errors.

Unfortunately it is not giving me an answer based on the expression?

In my answer panel I get this output not any of the numbers we assigned to the randomnumber

May you please help me one more time?

Best

Sebastian

tischer_s
OFFLINE
Fresh Lemon
Posts: 19
Karma: 0
@DenisChenu:

May you please take a last look?

I am stuck with this error message...

Thank you very much for your help.

Best

Sebastian Tischer