- Posts: 44
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Pre-define the variable with Token attribute
- kevinleung
- Topic Author
- Offline
- Senior Member
Less
More
3 years 5 months ago #207271
by kevinleung
Pre-define the variable with Token attribute was created by kevinleung
Hi all,
I have a question about pre-define the variable with Token attribute. (e.g. showing the answer of last year)
The responds cannot be change.
For example, I used TOKEN:ATTRIBUTE_1 to pre-define Q1. The pre-defined answer is Option 1
Then I change it to Option 2 and it works.
However, if I close the browser and go to the survey again, Q1 changed back to Option 1.....
This is my step, may I know if there are any thing wrong....Thank you very much...
I will create "Equation" and "Radio"
Q1 is the radio question and this is the equation I am using:
Q1 = if(is_empty(Q1.NAOK), TOKEN:ATTRIBUTE_1, Q1.NAOK)
I allow the respondents update their responses:
"Allow multiple responses or update responses with one token: On"
It works fine if the respondents did not close the browser. But if they want to update their responses and go to the survey again, it change back to TOKEN:ATTRIBUTE_1
Thank you very much!
Kevin
I have a question about pre-define the variable with Token attribute. (e.g. showing the answer of last year)
The responds cannot be change.
For example, I used TOKEN:ATTRIBUTE_1 to pre-define Q1. The pre-defined answer is Option 1
Then I change it to Option 2 and it works.
However, if I close the browser and go to the survey again, Q1 changed back to Option 1.....
This is my step, may I know if there are any thing wrong....Thank you very much...
I will create "Equation" and "Radio"
Q1 is the radio question and this is the equation I am using:
Q1 = if(is_empty(Q1.NAOK), TOKEN:ATTRIBUTE_1, Q1.NAOK)
I allow the respondents update their responses:
"Allow multiple responses or update responses with one token: On"
It works fine if the respondents did not close the browser. But if they want to update their responses and go to the survey again, it change back to TOKEN:ATTRIBUTE_1
Thank you very much!
Kevin
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
3 years 5 months ago - 3 years 5 months ago #207272
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Pre-define the variable with Token attribute
I think you must use Q1 = if(is_empty(Q1.NAOK), TOKEN:ATTRIBUTE_1, Q1.NAOK) only in an hidden equation question type before the Q1 question.
See : manual.limesurvey.org/Expression_Manager..._Assignment_Operator
See : manual.limesurvey.org/Expression_Manager..._Assignment_Operator
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 3 years 5 months ago by DenisChenu.
The topic has been locked.
- kevinleung
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
3 years 5 months ago #207274
by kevinleung
Replied by kevinleung on topic Pre-define the variable with Token attribute
Hi Denis,
Yes, I set the "Equation" at the beginning.
It is working at the first time. But if I want to update the answer, it change back to ATTRIBUTE_1
By the way, "if" is missing in the manual, am I right?
Set a default answer to an array question type at start of a survey : {Q1_SQ1= if(is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}
Set a default answer to an array texts question type at start of a survey : {Q1_SQY1_SQX1 = if(is_empty(Q1_SQY1_SQX1.NAOK),"Inserted answer", Q1_SQY1_SQX1.NAOK)}
Yes, I set the "Equation" at the beginning.
It is working at the first time. But if I want to update the answer, it change back to ATTRIBUTE_1
By the way, "if" is missing in the manual, am I right?
Set a default answer to an array question type at start of a survey : {Q1_SQ1= if(is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}
Set a default answer to an array texts question type at start of a survey : {Q1_SQY1_SQX1 = if(is_empty(Q1_SQY1_SQX1.NAOK),"Inserted answer", Q1_SQY1_SQX1.NAOK)}
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
3 years 5 months ago - 3 years 5 months ago #207275
by DenisChenu
You really update answers ? answer persitence are set to Yes ?
What is your limesurvey version ?
Denis
PS : manual fixed, thanks you
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Pre-define the variable with Token attribute
Really strange ,kevinleung wrote: It is working at the first time. But if I want to update the answer, it change back to ATTRIBUTE_1
You really update answers ? answer persitence are set to Yes ?
What is your limesurvey version ?
Denis
PS : manual fixed, thanks you
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 3 years 5 months ago by DenisChenu.
The topic has been locked.
- kevinleung
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
3 years 5 months ago #207276
by kevinleung
Replied by kevinleung on topic Pre-define the variable with Token attribute
Hi Denis,
I am using Version 3.21.1+191210
This is my demo, the answer cannot update...
aristosurvey.com/LS/index.php/855196?newtest=Y&lang=en
Token: 1234
Thank you!
Kevin
I am using Version 3.21.1+191210
This is my demo, the answer cannot update...
aristosurvey.com/LS/index.php/855196?newtest=Y&lang=en
Token: 1234
Thank you!
Kevin
Attachments:
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
3 years 5 months ago #207287
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Pre-define the variable with Token attribute
Arg !!
Your right … bugs.limesurvey.org/view.php?id=16230
Can you report the issue for 3.X too please ?
Your right … bugs.limesurvey.org/view.php?id=16230
Can you report the issue for 3.X too please ?
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- kevinleung
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
3 years 5 months ago #207309
by kevinleung
Replied by kevinleung on topic Pre-define the variable with Token attribute
Hi Denis,
Thank you.
I saw that "3.22 have the same issue", so it should be fine.
May I know if there are any alternative solution to solve the issue?
Kevin
Thank you.
I saw that "3.22 have the same issue", so it should be fine.
May I know if there are any alternative solution to solve the issue?
Kevin
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
3 years 5 months ago #207311
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Pre-define the variable with Token attribute
No : it means the bug are in 3.22 too …kevinleung wrote: I saw that "3.22 have the same issue", so it should be fine.
I don't find it…kevinleung wrote: May I know if there are any alternative solution to solve the issue?
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- kevinleung
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
3 years 5 months ago #207312
by kevinleung
Replied by kevinleung on topic Pre-define the variable with Token attribute
Could we Pre-define the variable with Javascript?
Set the display condition of the Javascript (e.g. put it into "Equation").
If so, may I have an example of pre-define the variable with Javascript?
Thank you very much!
Set the display condition of the Javascript (e.g. put it into "Equation").
If so, may I have an example of pre-define the variable with Javascript?
Thank you very much!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
3 years 5 months ago #207313
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Pre-define the variable with Token attribute
There are an alternative, but it don't work in Question by Question mode : in group by groupmode : put the equation after the question, but in same group …
for javascript … something like this :
for javascript … something like this :
Code:
<script> $(function() { if($("#question{QID} :radio:checked").length == 0) { $("#question{QID} :radio[value='{TOKEN:ATTRIBUTE_1}']").click(); } }); </script>
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- kevinleung
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 44
- Thank you received: 0
3 years 5 months ago #207314
by kevinleung
Replied by kevinleung on topic Pre-define the variable with Token attribute
Thank you so much! It works!
How about other question type? (Array, Multiple choice, Text input). I think the example is fit for radio question only.
Is there some example/manual/guide to follow? Thanks.
How about other question type? (Array, Multiple choice, Text input). I think the example is fit for radio question only.
Is there some example/manual/guide to follow? Thanks.
The topic has been locked.