from otree.api import * doc = """ One player decides how to divide a certain amount between themself and another player. A third player decides how much to punish the dictator, depending on the dictator's decision. Akdeniz & Mathew, 2022, Normative versus prosocial underpinnings of human decision making. """ class Constants(BaseConstants): name_in_url = 'part1task2_1' players_per_group = None num_rounds = 1 endowment_dictator = 500 endowment_not_dictator = 0 endowment_punisher = 100 rate_punishment = 5 sit = 2 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): dg_third = models.IntegerField( label='How many points do you want to give to Participant B?', min=0, max=Constants.endowment_dictator, ) ex1 = models.CurrencyField( doc="""Answer to first example""", min=0, max=Constants.endowment_dictator, label="", ) ex2 = models.CurrencyField( doc="""Answer to second example""", min=0, max=Constants.endowment_dictator, label="", ) ex3 = models.CurrencyField( doc="""Answer to third example""", min=0, max=Constants.endowment_dictator, label="", ) ex4 = models.CurrencyField( doc="""Answer to fourth example""", min=0, max=Constants.endowment_punisher, label="", ) punishment1 = models.IntegerField(min=0, label='Participant A sent 0 points to Participant B and kept 500 points to themself.') punishment2 = models.IntegerField(min=0, label='Participant A sent 50 points to Participant B and kept 450 points to themself.') punishment3 = models.IntegerField(min=0, label='Participant A sent 100 points to Participant B and kept 400 points to themself.') punishment4 = models.IntegerField(min=0, label='Participant A sent 150 points to Participant B and kept 350 points to themself.') punishment5 = models.IntegerField(min=0, label='Participant A sent 200 points to Participant B and kept 300 points to themself.') punishment6 = models.IntegerField(min=0, label='Participant A sent 250 points to Participant B and kept 250 points to themself.') punishment7 = models.IntegerField(min=0, label='Participant A sent 300 points to Participant B and kept 200 points to themself.') punishment8 = models.IntegerField(min=0, label='Participant A sent 350 points to Participant B and kept 150 points to themself.') punishment9 = models.IntegerField(min=0, label='Participant A sent 400 points to Participant B and kept 100 points to themself.') punishment10 = models.IntegerField(min=0, label='Participant A sent 450 points to Participant B and kept 50 points to themself.') # PAGES class Start(Page): pass class Instructions(Page): form_model = 'player' form_fields = ['ex1', 'ex2', 'ex3', 'ex4'] def error_message(self, value): if value["ex1"] != 240: return 'The first question is not answered correctly. Consult the instructions and try again.' elif value["ex2"] != 150: return 'The second question is not answered correctly. Consult the instructions and try again.' elif value["ex3"] != 78: return 'The third question is not answered correctly. Consult the instructions and try again.' elif value["ex4"] != 60: return 'The fourth question is not answered correctly. Consult the instructions and try again.' class StartTask(Page): pass class Round1(Page): form_model = 'player' form_fields = ['dg_third'] def error_message(self, value): if value["dg_third"] % 50 != 0: return 'You can only send points in a multiple of 50 (0, 50, 100, ..., 450, or 500 points).' class Round2(Page): pass class Round3(Page): form_model = 'player' form_fields = ['punishment1', 'punishment2', 'punishment3', 'punishment4', 'punishment5', 'punishment6', 'punishment7', 'punishment8', 'punishment9', 'punishment10'] def error_message(self, value): if value["punishment1"] > 100: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment2"] > 90: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment3"] > 80: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment4"] > 70: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment5"] > 60: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment6"] > 50: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment7"] > 40: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment8"] > 30: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment9"] > 20: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' elif value["punishment10"] > 10: return 'You can transfer deduction points up to the point where the remaining earnings of Participant A become zero.' @staticmethod def app_after_this_page(player, upcoming_apps): print('upcoming_apps is', upcoming_apps) return "part1task3" page_sequence = [Start, Instructions, StartTask, Round1, Round2, Round3]