from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'quiz' PLAYERS_PER_GROUP = None NUM_ROUNDS = 3 class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): round = subsession.round_number if round == 1: for p in subsession.get_players(): p.participant.quiz_done = False class Group(BaseGroup): pass class Player(BasePlayer): participant_label = models.StringField(initial="0") failed = models.BooleanField(initial=False) q1 = models.StringField(widget=widgets.RadioSelect, choices=["Yes", "No, but it is possible to play the same partner in two consecutive trials", "No, and it is not even possible to play the same partner in two consecutive trials."]) q2 = models.StringField(widget=widgets.RadioSelect, choices=["0 with certainty", "-5 with certainty", "+10 with certainty", "It depends on Player 2's choice"]) q3 = models.StringField(widget=widgets.RadioSelect, choices=["0 with certainty", "-5 with certainty", "+10 with certainty", "It is impossible to know"]) # PAGES class Quiz(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3'] @staticmethod def is_displayed(player): return player.participant.quiz_done == False @staticmethod def before_next_page(player, timeout_happened): player.participant_label = player.participant.label ## You write the correct answers here if (player.q1 == "No, and it is not even possible to play the same partner in two consecutive trials.") and (player.q2 == "-5 with certainty") and (player.q3 == "+10 with certainty"): player.participant.quiz_done = True else: player.participant.quiz_done = False if player.round_number == C.NUM_ROUNDS: player.failed = True player.participant.vars['failed'] = True class FailPage(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3'] @staticmethod def is_displayed(player): return player.failed == True page_sequence = [Quiz, FailPage]