Expression Manager - style/html

More
5 years 10 months ago #112907 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.
LimeSurvey Partners
More
5 years 10 months ago #112913 by DenisChenu
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 , plugin development . I don't answer to private message.
The following user(s) said Thank You: karencheah
The topic has been locked.
More
5 years 10 months ago #112917 by karencheah
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
5 years 10 months ago - 5 years 10 months ago #112919 by steve_81
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: 5 years 10 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.
More
5 years 10 months ago #112929 by karencheah
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.

Start now!

Just create your account and start using Limesurvey today.

Register now