from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'intro' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 minutes_parts_123 = 6 timers = dict(consent=60 * 4, workerid=60 * 2, welcome=60 * 2) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): consent = models.BooleanField(label="Selezioni 'Si' se intende accettare il consenso infomato e proseguire con l'esperimento. Altrimenti selezioni 'No' se non intende partecipare all'esperimento.") workerid = models.StringField(label="") timeout = models.BooleanField(initial=False) # FUNCTIONS def creating_session(subsession: Subsession): for p in subsession.session.get_participants(): pvars = p.vars p.excluded, p.dropout = False, False pvars['num_timeouts'] = 0 pvars['lottery_choice'], pvars['lottery_win'], p.lottery_payoff = None, None, 0 p.svo_ego_selected, p.svo_payoff = False, 0 p.ee_payoff, p.ne_payoff, p.cc_payoff, p.ee_ne_cc_payoff, p.tax_game_payoff, p.audited = 0, 0, 0, 0, 0, False # PAGES class Consent(Page): form_model = 'player' form_fields = ['consent'] timeout_seconds = C.timers['consent'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.timeout = True player.participant.dropout = True @staticmethod def app_after_this_page(player: Player, upcoming_apps): participant = player.participant if participant.dropout: return upcoming_apps[-1] class Disagree(Page): # Display this page only if paricipant disagrees with the terms. @staticmethod def is_displayed(player: Player): return player.consent == 0 class Prolific_id(Page): form_model = 'player' form_fields = ['workerid'] timeout_seconds = C.timers['workerid'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.timeout = True player.participant.dropout = True @staticmethod def app_after_this_page(player: Player, upcoming_apps): participant = player.participant if participant.dropout: return upcoming_apps[-1] class Welcome(Page): timeout_seconds = C.timers['welcome'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.timeout = True player.participant.dropout = True @staticmethod def app_after_this_page(player: Player, upcoming_apps): participant = player.participant if participant.dropout: return upcoming_apps[-1] page_sequence = [Consent, Disagree, Prolific_id ]