from otree.api import * doc = """ One player decides how much of the other player's endowment to destroy. Akdeniz & Mathew, 2022, Normative versus prosocial underpinnings of human decision making. """ class Constants(BaseConstants): name_in_url = 'part1task7' players_per_group = None num_rounds = 1 endowment = 250 destruction_strength = 10 sit = 7 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): jod = models.IntegerField( min=1, max=Constants.endowment/Constants.destruction_strength, label='How many points do you want to spend on reducing the earnings of Participant B?', ) jod_request = models.IntegerField( min=1, max=Constants.endowment/Constants.destruction_strength, label='How many points do you want to spend on reducing the earnings of Participant B in this case?', ) ex1 = models.CurrencyField( doc="""Answer to first example""", min=0, max=Constants.endowment, label="", ) ex2 = models.CurrencyField( doc="""Answer to second example""", min=0, max=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"] != 238: return 'The first question is not answered correctly. Consult the instructions and try again.' elif value["ex2"] != 130: 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 = ['jod'] class Round1Request(Page): form_model = 'player' form_fields = ['jod_request'] class Round2(Page): @staticmethod def app_after_this_page(player, upcoming_apps): print('upcoming_apps is', upcoming_apps) participant = player.participant if participant.tog_order == 1: return "part1task6eq_2" # elif participant.tog_order == 2: # return "part1task6eff_2" page_sequence = [Start, Instructions, StartTask, Round1, Round1Request, Round2]