from otree.api import * doc = """ One player decides whether to give to or take from the other player. Akdeniz & Mathew, 2022, Normative versus prosocial underpinnings of human decision making. """ class Constants(BaseConstants): name_in_url = 'part1task1t_2' players_per_group = None num_rounds = 1 endowment = 250 sit = 4 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): dg_amount_give = models.IntegerField( label='How many points do you want to give to Participant B?', min=0, max=Constants.endowment, ) dg_amount_take = models.IntegerField( label='How many points do you want to take from Participant B?', min=0, max=Constants.endowment, ) dg_take = models.IntegerField( choices=[[0, 'I want to give points to Participant B.'], [1, 'I do not want to give points to or take points from Participant B.'], [2, 'I want to take points from Participant B.']], label='What would you like to do?', widget=widgets.RadioSelect, ) ex1 = models.CurrencyField( doc="""Answer to first example""", min=0, max=2*Constants.endowment, label="", ) ex2 = models.CurrencyField( doc="""Answer to second example""", min=0, max=2*Constants.endowment, label="", ) # PAGES class Start(Page): pass class Instructions(Page): form_model = 'player' form_fields = ['ex1', 'ex2'] def error_message(self, value): if value["ex1"] != 100: return 'The first question is not answered correctly. Consult the instructions and try again.' elif value["ex2"] != 200: return 'The second question is not answered correctly. Consult the instructions and try again.' class StartTask(Page): pass class Round1(Page): form_model = 'player' form_fields = ['dg_take'] class Round1Amount(Page): form_model = 'player' @staticmethod def get_form_fields(self): if self.dg_take == 0: return ['dg_amount_give'] elif self.dg_take == 2: return ['dg_amount_take'] def is_displayed(player: Player): return player.dg_take != 1 class Round2(Page): @staticmethod def app_after_this_page(player, upcoming_apps): print('upcoming_apps is', upcoming_apps) participant = player.participant if participant.dg3pp_order == 1: return "part1task2j_2" # elif participant.dg3pp_order == 2: # return "part1task2_2" page_sequence = [Start, Instructions, StartTask, Round1, Round1Amount, Round2]