from otree.api import * import itertools doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'Introduction' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 TREATMENT_AI_AGENT = "AI Agent" TREATMENT_AI_DELEGATION = "AI Delegation" def timer(player, seconds): """Return seconds if timers are enabled, else None.""" return seconds if player.session.config.get('enable_timers', False) else None class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): agreementpart = models.BooleanField(choices=["Agree"], widget=widgets.RadioSelect) agreementdata = models.BooleanField(choices=["Agree"], widget=widgets.RadioSelect) prolificID = models.StringField() # PAGES class Information_Sheet(Page): @staticmethod def get_timeout_seconds(player): # Example: 120s normally return timer(player, 300) @staticmethod def vars_for_template(player): player.participant.dropout = False # Assign delegation here (page handlers are saved; creating_session is not) if player.participant.vars.get('delegation') is None: block_index = (player.id_in_subsession - 1) // 3 player.participant.delegation = ( C.TREATMENT_AI_AGENT if block_index % 2 == 0 else C.TREATMENT_AI_DELEGATION ) delegation = player.participant.vars.get('delegation') if delegation == C.TREATMENT_AI_AGENT: ai_group_clause = "who may include a different combination of human and AI agents" elif delegation == C.TREATMENT_AI_DELEGATION: ai_group_clause = ( 'who may include players labeled as "AI" because they delegated decisions to an AI system' ) else: ai_group_clause = None return dict(ai_group_clause=ai_group_clause, delegation=delegation) @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: player.participant.dropout = True @staticmethod def app_after_this_page(player, timeout_happened): if player.participant.dropout: return "End_Page" class Consent_Form(Page): form_model = "player" form_fields = ['agreementpart', 'agreementdata'] @staticmethod def get_timeout_seconds(player): # Example: 120s normally return timer(player, 240) @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: player.participant.dropout = True @staticmethod def app_after_this_page(player, timeout_happened): if player.participant.dropout: return "End_Page" def vars_for_template(player): delegation = player.participant.vars.get('delegation') return dict(delegation=delegation) class ProlificInfo(Page): form_model = "player" form_fields = ["prolificID"] @staticmethod def get_timeout_seconds(player): # Example: 120s normally return timer(player, 180) @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: player.participant.dropout = True @staticmethod def app_after_this_page(player, timeout_happened): if player.participant.dropout: return "End_Page" # All the pages of this app page_sequence = [Information_Sheet, Consent_Form, ProlificInfo]