- Posts: 74
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Auto-generate data into hidden question and then reference it in another Q
- Winocll_48635
- Topic Author
- Offline
- Banned
The hidden question to receive generated data is called "qspcode" and it looks like this...
question type: equation
mandatory: no
always hide question: yes
equation: {qspcode=if(TOKEN:ATTRIBUTE_1 == "001", "1", if(TOKEN:ATTRIBUTE_1 == "002", "2", if(TOKEN:ATTRIBUTE_1 == "003", "3", if(TOKEN:ATTRIBUTE_1 == "004", "4", if(TOKEN:ATTRIBUTE_1 == "005", "5", if(TOKEN:ATTRIBUTE_1 == "006", "6", if(TOKEN:ATTRIBUTE_1 == "007", "7", "8"))}
The question that is supposed to display the data generated into qspcode looks like this...
question source:
CS1. Thinking about {INSERTANS:197459X108X2371}, please rate your likelihood to recommend them to friends or family on a scale where 0 is "Not at all Likely" and 10 is "Very Likely".
{INSERTANS:197459X108X2473}
question as it displays before clicking the "edit" icon:
CS1. Thinking about util.shown, please rate your likelihood to recommend them to friends or family on a scale where 0 is "Not at all Likely" and 10 is "Very Likely". qspcode.shown
The token table that contains ATTRIBUTE_1 (spcode) looks like this...
The question text as it displays during testing is...
- steve_81
- Offline
- Premium Member
- Posts: 136
- Thank you received: 37
I guess there is something wrong in your equation itself. Try this in your qspcode:
{if(TOKEN:ATTRIBUTE_1 == "001", "1", if(TOKEN:ATTRIBUTE_1 == "002", "2", if(TOKEN:ATTRIBUTE_1 == "003", "3", if(TOKEN:ATTRIBUTE_1 == "004", "4", if(TOKEN:ATTRIBUTE_1 == "005", "5", if(TOKEN:ATTRIBUTE_1 == "006", "6", if(TOKEN:ATTRIBUTE_1 == "007", "7", "8")))))))}
This should give you the transformed value of the Token.
In the question CS1 you can refer simply per {qspcode} to get the new value (easier than these insertans).
What is the second insertans in your CS1?
To hide a whole group you can use the relevance equation. Just insert {TOKEN:ATTRIBUTE_1 == "006"} and this group will only be displayed for the spode/spcode 006.
Greets
Steve
- Winocll_48635
- Topic Author
- Offline
- Banned
- Posts: 74
- Thank you received: 1
I was trying to get groups of questions hidden under certain circumstances, and you helped with that as well. For some reason i thought i needed to use an 'if' statement in the relevance equation...ugh.
Thanks again for helping me fix my issue