- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Evaluate response to question 2 depending on response to question 1
- DrMaggie
- Topic Author
- Offline
- New Member
Less
More
5 years 6 days ago #183248
by DrMaggie
Evaluate response to question 2 depending on response to question 1 was created by DrMaggie
Hello everybody,
my apologies if this has already been answered - didn't find anything similar to my question by searching the forum.
I want to be able to evaluate and answer a question Q2 "automatically" (requiring no action from the user) based on the response to the previous question Q1. Then, I want to be able to use the _string_ corresponding to the selected Q1 and Q2 answers in the formulation of the next question Q3.
Here's the work flow I'm envisaging:
Step 1: User actively selects one option (it's a radio button) to answer Q1
Q1: Select product to evaluate:
> Product One (answer code =A1)
> Product Two (answer code =A2)
> Product Three (answer code =A3)
Step 2: The second (hidden) question looks like this:
Q2: The link to the product specification page
> www.specs.com/product1_spec.html (answer code =S1)
> www.specs.com/product2_spec.html (answer code =S2)
> www.specs.com/product3_spec.html (answer code =S3)
Q2 should be automatically evaluated based on the answer to Q1, so that Q2=S1 if Q1=A1 etc.
Step 3: The text of the next question should contain the _text-strings_ corresponding to the selected Q1 and Q2 answers:
Q3: Have you read the specification for <text-string_of_selected_Q1_option> at <text-string_of_selected_Q2_option>?
> Yes
> No
> Not sure
....
Note that I want to make it very easy also for someone not familiar with programming to modify the survey if e.g. the links in Q2 are changed. If possible, I would therefore like to avoid using javascript, and only base the solution on "logic" and "expressions" inside the survey question definitions, that would not have to be changed if only the Q2 answer options are edited. But of course I'm open to any help & suggestions!
Thanks in advance for your help!
PS I'm using a self-hosted instance of LimeSurvey 3.15
my apologies if this has already been answered - didn't find anything similar to my question by searching the forum.
I want to be able to evaluate and answer a question Q2 "automatically" (requiring no action from the user) based on the response to the previous question Q1. Then, I want to be able to use the _string_ corresponding to the selected Q1 and Q2 answers in the formulation of the next question Q3.
Here's the work flow I'm envisaging:
Step 1: User actively selects one option (it's a radio button) to answer Q1
Q1: Select product to evaluate:
> Product One (answer code =A1)
> Product Two (answer code =A2)
> Product Three (answer code =A3)
Step 2: The second (hidden) question looks like this:
Q2: The link to the product specification page
> www.specs.com/product1_spec.html (answer code =S1)
> www.specs.com/product2_spec.html (answer code =S2)
> www.specs.com/product3_spec.html (answer code =S3)
Q2 should be automatically evaluated based on the answer to Q1, so that Q2=S1 if Q1=A1 etc.
Step 3: The text of the next question should contain the _text-strings_ corresponding to the selected Q1 and Q2 answers:
Q3: Have you read the specification for <text-string_of_selected_Q1_option> at <text-string_of_selected_Q2_option>?
> Yes
> No
> Not sure
....
Note that I want to make it very easy also for someone not familiar with programming to modify the survey if e.g. the links in Q2 are changed. If possible, I would therefore like to avoid using javascript, and only base the solution on "logic" and "expressions" inside the survey question definitions, that would not have to be changed if only the Q2 answer options are edited. But of course I'm open to any help & suggestions!
Thanks in advance for your help!
PS I'm using a self-hosted instance of LimeSurvey 3.15
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
5 years 6 days ago #183250
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 Evaluate response to question 2 depending on response to question 1
Q2 must be an equation question type :
manual.limesurvey.org/Question_type_-_Equation
with
with
Code:
{if(Q1=="A1","https://example.org/spec1.html")} {if(Q1=="A2","https://example.org/spec2.html")} {if(Q1=="A3","https://example.org/spec3.html")}
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 following user(s) said Thank You: DrMaggie
The topic has been locked.
- DrMaggie
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
5 years 6 days ago #183262
by DrMaggie
Replied by DrMaggie on topic Evaluate response to question 2 depending on response to question 1
Thank you so much, DenisChenu, for your help!
In order to display the relevant text strings in Q3, I ended up using the expression "Have you read the specification for {Q1.NAOK} at {Q2.NAOK}?", which seems to work fine.
In case anyone wants to play around with this, I have attached the .lss file:
In order to display the relevant text strings in Q3, I ended up using the expression "Have you read the specification for {Q1.NAOK} at {Q2.NAOK}?", which seems to work fine.
In case anyone wants to play around with this, I have attached the .lss file:
Attachments:
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11639
- Thank you received: 2737
5 years 6 days ago #183263
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Evaluate response to question 2 depending on response to question 1
Actually, if you don't need the URL to be saved in the database, you could actually skip the second question that is hidden and just write the equation on the question text of your Q3. As I understand, you just want to show the URL to a certain paper. Nothing else. So I don't see the need for the equation question. Of course you can use it, but I don't think it is necessary.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- DrMaggie
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
5 years 6 days ago #183269
by DrMaggie
Replied by DrMaggie on topic Evaluate response to question 2 depending on response to question 1
Hi holch,
thanks for your comment! Could you help me with a code example, so that I can better understand how to include the if-statement block in the Q3 text?
However, in the real-life use case that I'm trying to implement, there is a point to actually storing the link URL as such - it is our intention to allow external software packages to access the replies stored in the LimeSurvey database, and then the information needs to be as complete as possible.
thanks for your comment! Could you help me with a code example, so that I can better understand how to include the if-statement block in the Q3 text?
However, in the real-life use case that I'm trying to implement, there is a point to actually storing the link URL as such - it is our intention to allow external software packages to access the replies stored in the LimeSurvey database, and then the information needs to be as complete as possible.
The topic has been locked.