Change appearance of formfield_errors messages

72 views
Skip to first unread message

Nikki Maier

unread,
Sep 15, 2021, 6:39:30 AM9/15/21
to oTree help & discussion

Hello all,

for a comprehension test I want to use the built in error messages to show the participants which anwers are correct and which are incorrect.

Is it possible to change the appearance of the built in error_messages?
For correct answers, I want to show the paraticipant the error message "The answer is correct." in color green instead of red.

CSS did not work on the {{ formfield_errors 'quiz3' }} element. However, I could use CSS with the {{ form.quiz3.errors}} element but the output looked like this:
['The answer is correct.']

Many thanks,

Nikki Maier

unread,
Sep 15, 2021, 7:13:49 AM9/15/21
to oTree help & discussion
To be more precise:
I use the following function in _init_.py and I want that the error_meassage "The answer is correct." is displayed in green.

def quiz3_error_message(player, value):
      if value != 0:
          return 'The answer is correct.'
      else:
          return 'The answer is incorrect.'
Message has been deleted

Chris @ oTree

unread,
Sep 15, 2021, 6:41:46 PM9/15/21
to oTree help & discussion
Take a look at the quiz_with_explanation app in otree-snippets: https://www.otreehub.com/projects/otree-snippets/

Nikki Maier

unread,
Sep 16, 2021, 4:50:24 AM9/16/21
to oTree help & discussion
Thank you very much.

My comprehension test should look exactly like the quiz_with_explanation app. However, I think that the user must have already submitted his answers for that solution?
I am planning to combine the comprehension test that the user must pass to proceed with the design of the quiz_with_explanation because I have quite a lot of questions and the
information processing of the information in the comprehension test might be easier for the user if he sees which answers are correct and incorrect and not only the incorrect answers.

I thought that I have to use error_messages for that purpose.

However, it is not that important if it is to complicated to implement! Then I will simply use the comprehension_test to proceed solution.
Reply all
Reply to author
Forward
0 new messages