- Posts: 2
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
6 years 2 months ago #164434
by kruk75
Assessment report (after group of questions) - with long text nested conditions was created 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+
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
6 years 2 months ago #164438
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 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.
The topic has been locked.
- DanielB
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
6 years 2 months ago #164464
by DanielB
Replied by DanielB on 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.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
6 years 2 months ago #164484
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 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:
And, something like this where you want to display the text:
Sample survey attached:
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:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- kruk75
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
6 years 2 months ago - 6 years 2 months ago #164548
by kruk75
Replied by kruk75 on 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!
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.