Expression Manager - style/html

More
3 years 2 months ago #112907 by karencheah
karencheah created the topic: Expression Manager - style/html
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

Please Log in to join the conversation.

More
3 years 2 months ago #112913 by DenisChenu
DenisChenu replied the topic: Expression Manager - style/html
Hi,

Only with the td:
<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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: karencheah

Please Log in to join the conversation.

More
3 years 2 months ago #112917 by karencheah
karencheah replied the 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).

Please Log in to join the conversation.

More
3 years 2 months ago - 3 years 2 months ago #112919 by steve_81
steve_81 replied the 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.
.error_customer{color:red;}
.

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

Best regards
Stefan
Last Edit: 3 years 2 months ago by steve_81. Reason: Underlining doesn't work within qodes.
The following user(s) said Thank You: karencheah

Please Log in to join the conversation.

More
3 years 2 months ago #112929 by karencheah
karencheah replied the 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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!