from otree.api import * doc = """ News Prosumers experiment. Part 1. """ class C(BaseConstants): NAME_IN_URL = 'news_prosumers_1' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 fee = cu(3.00) timeout = 0.5 def creating_session(subsession): if subsession.round_number == 1: for player in subsession.get_players(): participant = player.participant participant.showup = C.fee # In session configs you set treatment # [consumer, prosumer, secondgeneration, secondgenerationidentity] participant.treatment = subsession.session.config['TREATMENT'] # p.treatment = "secondgeneration" class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): consent_1 = models.IntegerField(choices=[[1, "Yes"]], widget=widgets.RadioSelect) consent_2 = models.IntegerField(choices=[[1, "Yes"], [0, "No"]], widget=widgets.RadioSelect) prolific_id = models.StringField(max_length=24) showup = models.IntegerField() UQattempt_1_answer = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, "$0.30 overall payment"], [2, "$0.30 per coin correctly identified in the two-minute period"], [3, "$0.30 per coin correctly identified in the 30-seconds practice period"]]) UQattempt_1 = models.IntegerField(initial=0) leavescreen_1 = models.IntegerField(blank=True) leavescreen_2 = models.IntegerField(blank=True) leavescreen_3 = models.IntegerField(blank=True) leavescreen_4 = models.IntegerField(blank=True) leavescreen_5 = models.IntegerField(blank=True) leavescreen_6 = models.IntegerField(blank=True) leavescreen_7 = models.IntegerField(blank=True) is_mobile = models.BooleanField() # PAGES class Consent(Page): form_model = 'player' form_fields = ['consent_1', 'consent_2', 'leavescreen_1', 'is_mobile'] class Prolific_ID(Page): form_model = 'player' form_fields = ['prolific_id', 'leavescreen_2'] class Overview_Instructions(Page): form_model = 'player' form_fields = ['leavescreen_3'] class Part_1(Page): form_model = 'player' form_fields = ['leavescreen_4'] class Part_1_instructions(Page): form_model = 'player' form_fields = ['UQattempt_1_answer', 'leavescreen_5'] @staticmethod def error_message(player: Player, values): if values['UQattempt_1_answer'] != 2: player.UQattempt_1 += 1 return "Answer is wrong. Try again" class Part_1_instructions_2(Page): timeout_seconds = 5 form_model = 'player' form_fields = ['leavescreen_6'] class Pre_Practice(Page): form_model = 'player' form_fields = ['leavescreen_7'] @staticmethod def before_next_page(player, timeout_happened): participant = player.participant import time participant.expiry_1 = time.time() + C.timeout*60 page_sequence = [ Consent, Prolific_ID, Overview_Instructions, Part_1, Part_1_instructions, Part_1_instructions_2, Pre_Practice ]