Welcome to the LimeSurvey Community Forum

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

Problem parsing expression script.

  • linuxhooligan
  • linuxhooligan's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 months 3 weeks ago - 6 months 3 weeks ago #265097 by linuxhooligan
Problem parsing expression script. was created by linuxhooligan
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.6.55+240220
Own server or LimeSurvey hosting: shared hosting
Survey theme/template: fruity
==================


This is a generic question to Limesurvey, not pdfReport plugin.

I am working with the demo survey provided by the pdfReport (link:  

File Attachment:

File Name: limesurvey...04-3.lss
File Size:37 KB
  ) and I am running into an expression script parsing error that I cannot explain.  Details:

1) The first question in the sample survey has an email form and an expression script that doesn't generate any errors in Lime survey until I either make any change and hit save or just hit save after the question is opened.

2) Here is how to replicate the issue:

a) Create a new blank survey.

b) Import the sample question:  

File Attachment:

File Name: limesurvey...04-3.lsq
File Size:5 KB


c) When you import it, as long as you don't hit save everything looks fine and Lime survey visually confirms that the expression script in the question is okay.  Screenshot:  

d) Then open up the question and just hit save.  Now Limesurvey believes it cannot parse the expression script.  Screenshot:  

3) I don't understand two things:

a) Why does this error happen?  Everything looks fine when I import the question and the survey (regex) even works great on the email field when testing the survey, but as soon as I edit the question and hit save that parsing error shows up.

b) What is the proper way to fix this issue?  In the past I created a very long expression that concatenated all of the problem characters into one long expression but that doesn't seem quite right given the above behaviour.  Any suggestions?

Thanks.

 
Last edit: 6 months 3 weeks ago by linuxhooligan.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 3 weeks ago #265098 by Joffm
Replied by Joffm on topic Problem parsing expression script.
You have nested quotes and you used the HTML editor. And that's the problem.

If you do it like this (as you did)
Code:
{if(is_empty(USER_EMAIL.NAOK),"<div class='error'>If you leave email empty, you don't get the report.</div>","")}
the HTML editor changes the single quotes into double quotes to
Code:
{if(is_empty(USER_EMAIL.NAOK),"<div class="error">If you leave email empty, you don't get the report.</div>","")}
Now you get the error.

So either you exchange the order of quotes to
Code:
{if(is_empty(USER_EMAIL.NAOK),'<div class="error">If you leave email empty, you don't get the report.</div>','')}

or - and that is my advice - you use the source code editor







Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: jonas.jau

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose