Hi9,
there are several mistakes.
1. In your survey Q2 is a "text display" question, but it should be of type "equation". So you only display something, but nothing is stored.
The same in Q4.
2. {Q2=if(is_empty(Q2),rand(0,30),Q2)}
Here you assign something to another question; unfortunately it is trhe same (Q2)
The correct syntax to generate a random number in a question of type "equation" (Q2) is
{if(is_empty(Q2),rand(0,30),Q2)}
And Q4? You only set the constant
{10}
As you read in the manual about the assignment operator
Using assignment operator
The main reasons you may want to use the assignment operator are:
- You need to set the default value via equation for a question that does not accept default values (such as list radio, where the user interface lets you pick one of the answer options, but does not let you enter an equation). However, be careful, as LimeSurvey will not be able to validate that your equation generates one of the allowable answers for that question;
- You need to forcibly change the response to a previous question based upon a later response;
Example of assignment:
You can use questions of type "equation" to assign values to other questions, like
{Q2_SQ001=if(Q1_SQ001 gt 3,"Y","")}
{Q2_SQ002=if(Q1_SQ002 gt 3,"Y","")}
{Q2_SQ003=if(Q1_SQ003 gt 3,"Y","")}
Here you preset the subquestions of the (hidden) "multiple" question Q2, if in the "array" question Q1 the subquestions were rated "greater than 3"
Then you can use Q2 as array filter for further questions.
Joffm
Read about ExpressionScript here
[url]
www.limesurvey.org/manual/ExpressionScript_-_Presentation/en
[/url]