from otree.api import * import time from otree import settings doc = """ Standard Intro Screen interchangable first pages ( C.WELCOME_PAGE link With or W/o Partner find page """ class C(BaseConstants): NAME_IN_URL = 'exp_welcome' PLAYERS_PER_GROUP = None ## es braucht keine Gruppen NUM_ROUNDS = 1 ## Eine Runde reicht WELCOME_TEMPLATE = __name__ + "/welcome_text_basic.html" PARTNER_TEMPLATE = __name__ + "/partner_text_basic.html" INSTRUCTIONS_TEMPLATE = __name__ + "/instruction_basic.html" WELCOME_HEADER = "Welcome" PARTNER_HEADER = "Assign Team Partner" INSTRUCTIONS_FINISHED = "Next" INSTRUCTION_READ_TIME = 360 # ändern auf gewünschte Zeit jetzt 6 Minuten ### Todo: Sabrina Klären wie wb_norm_app_2 TREATMENTS = ['none', 'wb', 'corruption','sp','wb_norm_app', 'wb_norm_app_2'] ## hinten erweitern , erstes item sollte immer 'none' sien def creating_session(subsession): MSG_TREATMENT_MISSING = """ FAILURE: The Session Config has a not specified Treatment, please check if Constant TREATMENTS has the given config-treatment in its list """ if 'treatment' in subsession.session.config: subsession.Treatment = subsession.session.config['treatment'] if subsession.Treatment not in C.TREATMENTS: raise SystemExit(MSG_TREATMENT_MISSING) else: subsession.Treatment = C.TREATMENTS[0] ### Control std if 'show_partner_page' in subsession.session.config: subsession.SHOW_PARTNER = subsession.session.config['show_partner_page'] if subsession.Treatment == C.TREATMENTS[5]: ### Hier dann jeweils die Seite definieren subsession.WELCOME_TEMPLATE = __name__ + "/welcome_text_norm_app_2.html" #for the whole session: do this config; change participation fee and currency #or do it in the settings.py #subsession.session.config['participation_fee'] = 2.50 #subsession.session.config['real_world_currency_per_point'] = 0.5 def group_by_arrival_time_method(subsession, waiting_players): if subsession.Treatment == C.TREATMENTS[5]: ##wb_norm_app_2 if len(waiting_players) >= 2: return [waiting_players[0],waiting_players[1]] else: if len(waiting_players) >= 4: return [waiting_players[0], waiting_players[1], waiting_players[2], waiting_players[3]] print('not enough players yet to create a group') class Subsession(BaseSubsession): Treatment = models.StringField(initial=C.TREATMENTS[0])##none SHOW_PARTNER = models.BooleanField(initial=False) ### über Parameter von session config setzen INSTRUCTIONS_TEMPLATE = models.StringField(initial=C.INSTRUCTIONS_TEMPLATE) WELCOME_TEMPLATE = models.StringField(initial=C.WELCOME_TEMPLATE) class Group(BaseGroup): pass class Player(BasePlayer): ProlificID = models.StringField(label="Type in your Prolific ID:", blank=False, initial=101 if settings.DEBUG else None) ''' Employed = models.BooleanField(initial=False, choices=[ [1, "I am currently employed"], ], widget=widgets.RadioSelect, ) FluentEnglish = models.BooleanField(initial=False, choices=[ [1, "I am fluent in English"], ], widget=widgets.RadioSelect, ) ''' Employed = models.BooleanField( label="", choices=[ [True, "I am currently employed"] ], widgets=widgets.CheckboxInput, initial=True if settings.DEBUG else None ) FluentEnglish = models.BooleanField( label="", choices=[ [True, "I am fluent in English"] ], widgets=widgets.CheckboxInput, initial=True if settings.DEBUG else None ) UnderstoodRules = models.BooleanField( label="", choices=[ [True, "I have read and understood this consent form and wish to continue the study"] ], widgets=widgets.CheckboxInput, initial=True if settings.DEBUG else None ) # PAGES class Welcome(Page): form_model = 'player' form_fields = [ 'ProlificID', 'Employed', 'FluentEnglish', ] def vars_for_template(player): return dict( page=player.subsession.WELCOME_TEMPLATE ) class ExperimentWaitPage (WaitPage): group_by_arrival_time = True body_text = "Please wait, the experiment will shortly continue." class Instructions(Page): @staticmethod def get_timeout_seconds(player): return C.INSTRUCTION_READ_TIME if not settings.DEBUG else 10 class Partner(Page): @staticmethod def is_displayed(player: Player): #zeige die Seite mit Teilnehmer zuordnen ja/nein: bei wb experimenten ja, bei corruption #und tax evasion experiment nein return player.subsession.SHOW_PARTNER @staticmethod def before_next_page(player: Player, timeout_happened): if player.subsession.Treatment == 'wb' or 'wb_norm_app': ## only in the whistleblowing case player.participant.count_numbers_together = True player.session.second_time_counting = False if player.subsession.Treatment == 'corruption': ## corruption specifics pass ### Add Treatment specifics like above class Partner_Match_Waitpage(WaitPage): ## warten bis alle fertig sind. Dann matching in Intro von count numbers_group @staticmethod #def after_all_players_arrive(group: Group): def vars_for_template(player: Player): return dict (body_text= "Please wait until a group member is assigned to you.") @staticmethod def after_all_players_arrive(group): group.subsession.session.second_time_counting = False #page_sequence = [Welcome,Instructions,Partner, Partner_Match_Waitpage] #wenn man keine Instruktionen braucht/hat page_sequence = [ExperimentWaitPage,Welcome,Instructions, Partner, Partner_Match_Waitpage]