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
  • DrMaggie's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 days ago #183248 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
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 days ago #183250 by DenisChenu
Q2 must be an equation question type : manual.limesurvey.org/Question_type_-_Equation

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
  • DrMaggie's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 days ago #183262 by DrMaggie
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:

File Attachment:

File Name: limesurvey...sfQ1.lss
File Size:18 KB
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 days ago #183263 by holch
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
  • DrMaggie's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 3 days ago #183269 by DrMaggie
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.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose