Define variables in question text and create new variables conditional on others

More
5 years 2 months ago #142169 by Zirys
Dear users,

I want to show the following text to participants: "By paying x euros, you reduce y tons of CO2 emissions. This amounts to z % of your yearly CO2 emissions." Here, x is a random number, y is a function of x, z is a function of y.
Is it possible to implement in LimeSurvey?

I know how to create a random number ({rand(0,17)}), but I have not found a way to define this as a variable called, say, x, and then calculate (and show to participants) a new variable y based on x.

If someone could tell me whether this is possible in LimeSurvey, and if yes, could point me in a direction where I can find out how to do it, I would be very thankful.

Thanks in advance,
Zirys
The topic has been locked.
More
5 years 2 months ago #142170 by fvanderstarre
You can use Expression Manager to define a question as type "equation". See the Expression manager section in the online Manual. You can also find many helpful sample surveys there!
The topic has been locked.
More
5 years 2 months ago - 5 years 2 months ago #142172 by Zirys
I know this manual and I could not find an explanation of how to define a variable called x in the quesiton itself. It shows how to, e.g. make if statements with a variable that is already defined by the question code, but not how to define a variable in text.

It would be somthing like {x = rand(0,7)} to define the variable x.

Edit: Found out how to do it. Thanks for the hint.
Last edit: 5 years 2 months ago by Zirys.
The topic has been locked.
More
1 year 10 months ago #192582 by BOBYJAMES

I know this manual and I could not find an explanation of how to define a variable called x in the quesiton itself. It shows how to, e.g. make if statements with a variable that is already defined by the question code, but not how to define a variable in text.

It would be somthing like {x = rand(0,7)} to define the variable x.

Edit: Found out how to do it. Thanks for the hint.




hii ,
could you please tell how to do it ?
The topic has been locked.
More
1 year 10 months ago - 1 year 10 months ago #192584 by Joffm
Hi,
best to study the EM sample surveys, especially the first "Relevance, Tailoring and Equations"
manual.limesurvey.org/Expression_Manager_sample_surveys

And read the manual about question type "equation"
manual.limesurvey.org/Question_type_-_Equation

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 10 months ago by Joffm.
The topic has been locked.
More
1 year 10 months ago #192589 by BOBYJAMES
thanks for your reply..
but i can't find how to define a user defined variable..
can you please tell how we can define a variable and store some value to that variable... lets take it as x.. ?
The topic has been locked.
More
1 year 10 months ago #192590 by tpartner
Create an equation type question and load it with a hard value or via Expression Manager. This becomes your variable.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
1 year 10 months ago #192595 by BOBYJAMES
I try to do this... but didn't work as we expected..
can you please show an example of how to define a variable x in an equation question?
The topic has been locked.
More
1 year 10 months ago #192599 by tpartner
I'm sorry, I don't know what more to add or how to explain it more simply.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
1 year 10 months ago #192602 by Joffm
Did you study the survey I mentioned?
You also find it in the Demo installation here ("Tayloring Examples")

There you find four "user defined variables":
weightkg, heightm, BMI and weightstatus.

And fvanderstarre and tpartner explained it already.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Start now!

Just create your account and start using Limesurvey today.

Register now