from otree.api import * doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'quizMultiplayer' players_per_group = 2 num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): num_failed_attempts = models.IntegerField(initial=0) failed_too_many = models.BooleanField(initial=False) quiz1 = models.BooleanField( label="You value this activity at 10 ECU and your counteroffer is 9 ECU. Are you going to participate in the activity?", choices=[ [True, "Yes"], [False, "No"] ] ) quiz2 = models.BooleanField( label="You value this activity at 25 ECU and your counteroffer is 27 ECU. Are you going to participate in the activity??", choices=[ [True, "Yes"], [False, "No"] ] ) # PAGES class MyPage(Page): form_model = 'player' form_fields = [ 'quiz1', 'quiz2'] @staticmethod def error_message(player: Player, values): # alternatively, you could make quiz1_error_message, quiz2_error_message, etc. # but if you have many similar fields, this is more efficient. solutions = dict(quiz1=False, quiz2=True) errors = {f: 'Wrong' for f in solutions if values[f] != solutions[f]} # if you don't care about failed attempts, just put: # return errors # otherwise, do this: if errors: player.num_failed_attempts += 1 if player.num_failed_attempts >= 2: player.failed_too_many = True else: return errors class Failed(Page): @staticmethod def is_displayed(player: Player): return player.failed_too_many class Results(Page): pass page_sequence = [MyPage, Failed, Results]