- Posts: 111
- Thank you received: 20
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Can I get an answer value by the name of a question (as string) in EM?
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
10 years 1 month ago - 10 years 1 month ago #105791
by orvil
Best regards/Beste Grüße,
O. Villani
Can I get an answer value by the name of a question (as string) in EM? was created by orvil
Hi all,
thanks to EM it is easy to get the answer of a question for further processing, like
{if(Q1_SQ001=="42","got it!","try again")
but: is there a way to get an answer value by having the question code (i.e. "Q1_SQ001") itself as the result if a calculation? Like
{if({QX.NAOK}=="42","got it!","try again")
where the content of QX.NAOK is "Q1_SQ001".
I've tried it in the way above with nested paranthesis, unfortunately without success.
thanks to EM it is easy to get the answer of a question for further processing, like
{if(Q1_SQ001=="42","got it!","try again")
but: is there a way to get an answer value by having the question code (i.e. "Q1_SQ001") itself as the result if a calculation? Like
{if({QX.NAOK}=="42","got it!","try again")
where the content of QX.NAOK is "Q1_SQ001".
I've tried it in the way above with nested paranthesis, unfortunately without success.
Best regards/Beste Grüße,
O. Villani
Last edit: 10 years 1 month ago by orvil.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
10 years 1 month ago #105793
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 Can I get an answer value by the name of a question (as string) in EM?
{if(Q1_SQ001.NAOK=="42","got it!","try again")
{if(Q1_SQ001.shown=="42",Q1_SQ001.shown,"try again")
etc ...
With EM : all part without quote are variable.
{if(Q1_SQ001.shown=="42",Q1_SQ001.shown,"try again")
etc ...
With EM : all part without quote are variable.
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.
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
10 years 1 month ago #105799
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Can I get an answer value by the name of a question (as string) in EM?
Hi,
thanks for your reply. Of course, all parts without qoute are variable, unfortunately I don't need the result of the if-statement as a variable. The tricky thing for me is in the left part of the equation {if({QX.NAOK}...
The problem is:
- I'm having the name of a question (eg.: Q1) stored as a result of a calculation in another question (let's say in QX).
- Now I'd like to access the answer to Q1 by using the calculation result of QX
An example:
The content of QX is "Q1_SQ001" (a string, internally calculated by EM)
The content of Q1_SQ001 will may be "42" (or anything else, edited by a participant, but at survey creation time I don't know if I will have to look for Q1_SQ001 or Q1_SQ002 or Q2_SQ001... => this will be stored in QX)
That is why I'd like to access the result of Q1_SQ001 via indirecet reference of QX.
I hope that's not too confusing :sick:
thanks for your reply. Of course, all parts without qoute are variable, unfortunately I don't need the result of the if-statement as a variable. The tricky thing for me is in the left part of the equation {if({QX.NAOK}...
The problem is:
- I'm having the name of a question (eg.: Q1) stored as a result of a calculation in another question (let's say in QX).
- Now I'd like to access the answer to Q1 by using the calculation result of QX
An example:
The content of QX is "Q1_SQ001" (a string, internally calculated by EM)
The content of Q1_SQ001 will may be "42" (or anything else, edited by a participant, but at survey creation time I don't know if I will have to look for Q1_SQ001 or Q1_SQ002 or Q2_SQ001... => this will be stored in QX)
That is why I'd like to access the result of Q1_SQ001 via indirecet reference of QX.
I hope that's not too confusing :sick:
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
10 years 1 month ago #105803
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 Can I get an answer value by the name of a question (as string) in EM?
Hi,
{if({QX.NAOK} : no, don't use 2 times {{ for EM, just one.
Can you provide a little lss file for example ?
{if({QX.NAOK} : no, don't use 2 times {{ for EM, just one.
Can you provide a little lss file for example ?
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.
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
10 years 1 month ago #105805
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Can I get an answer value by the name of a question (as string) in EM?
Yes, good idea. I'll create an example lss!
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
10 years 1 month ago - 10 years 1 month ago #105810
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Can I get an answer value by the name of a question (as string) in EM?
Hi Denis,
here is a hopefully understandable example of what is meant.
As you will find in the description: there is a way to avoid indirect referencing, but it would bei pain :woohoo: :woohoo: :woohoo: for editing the survey and may be pain for the serverload.
THX THX THX
PS.: UUPS the helptext of the first question is wrong. It should be ...will be either "QY" or "QZ"
here is a hopefully understandable example of what is meant.
As you will find in the description: there is a way to avoid indirect referencing, but it would bei pain :woohoo: :woohoo: :woohoo: for editing the survey and may be pain for the serverload.
THX THX THX
PS.: UUPS the helptext of the first question is wrong. It should be ...will be either "QY" or "QZ"
Best regards/Beste Grüße,
O. Villani
Attachments:
Last edit: 10 years 1 month ago by orvil.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
10 years 1 month ago - 10 years 1 month ago #105835
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 Can I get an answer value by the name of a question (as string) in EM?
Yes, no quote.
BUT : you can not set default value in the same page : this need to be on different page. Because : EM in same page update HTML, and can not updated .
But here, because you have dfault value in QY, you can use:
But, if you do:
The response are prefilled by 24 and not 48 : because when page start : QY.NAOK is empty.
if you use 'QY.NAOK' or "QY.NAOK" : EM don't appply here.
The remove the quote , and it's OK.
BUT : you can not set default value in the same page : this need to be on different page. Because : EM in same page update HTML, and can not updated .
But here, because you have dfault value in QY, you can use:
Code:
{if(1==1,QY.NAOK,QZ.NAOK)}
Code:
{if(QY.NAOK>1,QY.NAOK,QZ.NAOK)}
if you use 'QY.NAOK' or "QY.NAOK" : EM don't appply here.
The remove the quote , and it's OK.
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: 10 years 1 month ago by DenisChenu.
The topic has been locked.
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
10 years 1 month ago #105846
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Can I get an answer value by the name of a question (as string) in EM?
Sorry,
I'm confused and can't catch your point. How does this match the problem to adress indirectly?
I'm confused and can't catch your point. How does this match the problem to adress indirectly?
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
10 years 1 month ago - 10 years 1 month ago #105858
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Can I get an answer value by the name of a question (as string) in EM?
I think that with Expression Manager, as with JavaScript, you cannot have dynamic variable names.
You cannot take the VALUE of a variable and use it to create/modify another variable NAME.
.
You cannot take the VALUE of a variable and use it to create/modify another variable NAME.
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 1 month ago by tpartner.
The topic has been locked.
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
10 years 1 month ago #105876
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Can I get an answer value by the name of a question (as string) in EM?
Hallo Tony,
thanks for your reply - I'm afraid you are right. My ulterior motive was it's may be like php.
So I have to follow another path - not that elegant, but hopefully with more success!
Thank to all for your effort!
thanks for your reply - I'm afraid you are right. My ulterior motive was it's may be like php.
So I have to follow another path - not that elegant, but hopefully with more success!
Thank to all for your effort!
Best regards/Beste Grüße,
O. Villani
The topic has been locked.