Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Assessment report (after group of questions) - with long text nested conditions

  • kruk75
  • kruk75's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 2 months ago #164434 by kruk75
Hi Guys,


I struggle with some conditions issue in assessment survey.

When I use short condition like this:

{if (P102.NAOK == "A4", "Some answer", "Other answer")} it works perfectly.

but when I try to make the response longer e.g.

{if (P102.NAOK == "A4", "Some answer",
"Longer text longer longer longer Other answer
couple of lines of text
couple more
even more lines
more lines")}

it doesn't work. What's wrong?

If it is a problem with longer text, is there any workaround (calling external php script)?

Is it possible to do some actions based on questions response via javascript?

Thanks in advance for any feedback




LM 2.72.4+
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #164438 by tpartner
Try placing the text strings in separate equation type questions and reference those in your IF() statement.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 2 months ago #164464 by DanielB
Multi-line strings should be enclosed in backticks (`), shouldn't they? But then you'll run into problems with Internet Explorer.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #164484 by tpartner
You can maintain HTML tags if you use htmlentities() and html_entity_decode().

So, something like this in the equation question:
Code:
{htmlentities('Some text displayed if Q1 == "A1"<br />...and some more on a new line<br />...and some <strong style="color:red;">bolded red text</strong>.')}

And, something like this where you want to display the text:
Code:
{if(Q1 == 'A1', html_entity_decode(equation1), html_entity_decode(equation2))}





Sample survey attached:

File Attachment:

File Name: limesurvey...6331.lss
File Size:15 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • kruk75
  • kruk75's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 2 months ago - 6 years 2 months ago #164548 by kruk75
Thanks for the reply.

The combination of both solutions seems to do the trick. I used hidden questions for long text response and "if statement" to decide what answer to show. html_entity_decode works like a charm (no worries with formatting sign etc.)

Pls find below one of the code line that do the trick

{if(P102.NAOK == "A2", html_entity_decode(P102a.question), html_entity_decode(P103a.question))}

P102a.question, P103a.question are hidden questions

Special thanks to Tony Partner!
Last edit: 6 years 2 months ago by kruk75.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose