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

More
6 months 3 weeks ago #164434 by kruk75
kruk75 created the topic: Assessment report (after group of questions) - with long text nested conditions
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+

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #164438 by tpartner
tpartner replied the topic: Assessment report (after group of questions) - with long text nested conditions
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.

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #164464 by DanielB
DanielB replied the topic: Assessment report (after group of questions) - with long text nested conditions
Multi-line strings should be enclosed in backticks (`), shouldn't they? But then you'll run into problems with Internet Explorer.

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #164484 by tpartner
tpartner replied the topic: Assessment report (after group of questions) - with long text nested conditions
You can maintain HTML tags if you use htmlentities() and html_entity_decode().

So, something like this in the equation question:
{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:
{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.
Attachments:

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago - 6 months 3 weeks ago #164548 by kruk75
kruk75 replied the topic: Assessment report (after group of questions) - with long text nested conditions
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 months 3 weeks ago by kruk75.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!