oTree Forum >

Display all errors made in quiz part of an experiment

#1 by carooo

Hi everyone!

I have the following (standard) code that displays error messages when participants fill out a comprehension quiz:

    @staticmethod
    def error_message(player, values):
        solutions = dict(Frage1='3', Frage2='2', Frage3=True,
                         Frage4='wachsen auf das Anderthalbfache an und werden dann auf beide Teams aufgeteilt.',
                         Frage5='Bei Teams, die keinen Konsens finden, wird der Durchschnitt der individuellen Entscheidungen gebildet und 1 Taler von der Auszahlung abgezogen.',
                         Frage6='20', Frage7='30', Frage8='15', Frage9='35')

        error_messages = dict()
        for field_name in solutions:
            if values[field_name] != solutions[field_name]:
                error_messages[field_name] = 'Diese Antwort war nicht richtig.'
                return error_messages

Currently, it only shows one error message per complete field submission (there's a total of nine questions on that page). Is there a way this code can be altered so that all mistakes are displayed at once? I understand why this is happening. But if anyone has a solution, I'd appreciate your input!

Thanks a lot!

Greetings,
Caro

#2 by carooo (edited )

This error is fixed. The "return error_messages" was not aligned correctly. It had two indents that should not be there.

Write a reply

Set forum username