Expression Manager - style/html

More
4 years 11 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

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
4 years 11 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 .
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: karencheah

Please Log in or Create an account to join the conversation.

More
4 years 11 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).

Please Log in or Create an account to join the conversation.

More
4 years 11 months ago - 4 years 11 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: 4 years 11 months ago by steve_81. Reason: Underlining doesn't work within qodes.
The following user(s) said Thank You: karencheah

Please Log in or Create an account to join the conversation.

More
4 years 11 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

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!