Welcome to the LimeSurvey Community Forum

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

Expression Manager - style/html

  • karencheah
  • karencheah's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 5 months ago #112907 by karencheah
Expression Manager - style/html was created by karencheah
I'm getting into learning how to use Expression Manager and I'm wondering if it's able to conditionally format the output.

I'm creating a table of selected vs correct answers for a quiz type survey, to be displayed at the end. In this table, I would like to highlight (using font colour) the question(s) if the selected answer(s) is incorrect. (Please see table below). I am able to test the condition but I'm not sure how to format to get the red colour. I've tried just putting the html tags around the variable but that doesn't work; ends up displaying the whole thing as html.

Thanks for any advice.
QuestionSelected AnswerCorrect Answer
Q1A1A4
Q2A2A2
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 5 months ago #112913 by DenisChenu
Replied by DenisChenu on topic Expression Manager - style/html
Hi,

Only with the td:
Code:
<td class="{if(Q1!='A4','error','')}">Q1</td>

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: karencheah
The topic has been locked.
  • karencheah
  • karencheah's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 5 months ago #112917 by karencheah
Replied by karencheah on topic Expression Manager - style/html
Thanks. Where do I define the class? I've tried to define it just before the table (in source) between <style></style> but that doesn't work (turns up as syntax error).
The topic has been locked.
More
9 years 5 months ago - 9 years 5 months ago #112919 by steve_81
Replied by steve_81 on topic Expression Manager - style/html
Hi,
recently I had a same problem, so I try to help.

The style of 'error' should be still defined in the template.css so there is no need for declarate it again.

You could look for it in the template editor in the template.css file. If there is not such a definition you can create one there: e.g.
Code:
.error_customer{color:red;}
.

Then you can adress this directly with the solution of DenisChenu:
Code:
<td class="{if(Q1!='A4','error_customer','')}">Q1</td>
But I think it should work without an own class.

Best regards
Stefan
Last edit: 9 years 5 months ago by steve_81. Reason: Underlining doesn't work within qodes.
The following user(s) said Thank You: karencheah
The topic has been locked.
  • karencheah
  • karencheah's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 5 months ago #112929 by karencheah
Replied by karencheah on topic Expression Manager - style/html
Thanks so much! You and DenisChenu are the heroes! It is working as it should now and I've learned something.

Cheers,
Karen
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose