from otree.api import * doc = """ Your app description """ class Constants(BaseConstants): name_in_url = "subtraction" players_per_group = None num_rounds = 5 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): number = models.IntegerField(label=""" """) notes = models.StringField( label=""" Did you take notes while completing this task?""", choices=["Yes", "No"], ) # PAGES class SubtractionPage(Page): form_model = "player" form_fields = ["number"] timeout_seconds = 600 @staticmethod def app_after_this_page(player, upcoming_apps): participant = player.participant if participant.timeout: return "kick" @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant if timeout_happened: participant.timeout = True if participant.nr_correct_answers_subtractions is None: participant.nr_correct_answers_subtractions = 0 if player.number == 100 - 7 * player.round_number: participant.nr_correct_answers_subtractions += 1 @staticmethod def vars_for_template(player: Player): round = player.round_number return dict( round=round, subtraction_points=player.session.config["subtraction_points"] ) class Notes(Page): form_model = "player" form_fields = ["notes"] timeout_seconds = 600 @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.participant.timeout = True @staticmethod def app_after_this_page(player, upcoming_apps): participant = player.participant if participant.timeout: return "kick" @staticmethod def is_displayed(player: Player): return player.round_number == Constants.num_rounds page_sequence = [SubtractionPage, Notes]