from otree.api import * doc = """ Standard Intro Screen interchangable first pages ( C.WELCOME_PAGE link With or W/o Partner find page """ class C(BaseConstants): NAME_IN_URL = 'welcome' PLAYERS_PER_GROUP = None ## es braucht keine Gruppen NUM_ROUNDS = 1 ## Eine Runde reicht #todo: pcds - austauschbar von aussen machen WELCOME_TEMPLATE = __name__ + "/welcome_text_basic.html" PARTNER_TEMPLATE = __name__ + "/partner_text_basic.html" INSTRUCTIONS_TEMPLATE = __name__ + "/instruction_basic.html" WELCOME_HEADER = "Willkommen zum Experiment" PARTNER_HEADER = "Teampartner*in zuordnen" INSTRUCTIONS = "Gelesen / weiter" TREATMENTS = ['none', 'wb', 'corruption','sp'] ## 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'] #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 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): pass # PAGES class Welcome(Page): pass class Instructions(Page): @staticmethod def vars_for_template(player: Player): return dict( HTML_SEITE = player.subsession.INSTRUCTIONS_TEMPLATE, HEADER = "Instruktionen" ) 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': ## 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= "Bitte warten Sie, bis alle Teilnehmenden die vorherige Seite beendet haben") #page_sequence = [Welcome,Instructions,Partner, Partner_Match_Waitpage] #wenn man keine Instruktionen braucht/hat page_sequence = [Welcome,Partner, Partner_Match_Waitpage]