from otree.api import * author = 'Your name here.' doc = """ Decision Study """ # Models class C(BaseConstants): NAME_IN_URL = 'ControlAversion' PLAYERS_PER_GROUP = 3 NUM_ROUNDS = 1 ENDOWMENT = cu(120.00) MULTIPLIER = 2.00 PARTICIPATION_FEE = 10 class Subsession(BaseSubsession): pass class Group(BaseGroup): p1_decision = models.FloatField(initial=0) p2_decision = models.IntegerField(initial=0) p3_decision = models.IntegerField(initial=0) def is_displayed(self): return self.round_number == C.NUM_ROUNDS def set_payoffs(self): p1 = self.get_player_by_id(1) p2 = self.get_player_by_id(2) p3 = self.get_player_by_id(3) if p3.Decision3 == 1: p1.payoff = (C.ENDOWMENT - p1.Decision13) self.p1_decision = float(p1.Decision13) self.p2_decision = p2.Decision2 self.p2_decision = float(p2.Decision13) if p3.Decision3 == 1: self.p3_decision = 1 if p3.Decision3 == 2: self.p3_decision = 2 if p3.Decision3 == 2 and p2.Decision2 == 2: p1.payoff = (C.ENDOWMENT - p1.Decision12) self.p2_decision = 2 self.p1_decision = float(p1.Decision12) if p3.Decision3 == 2 and p2.Decision2 == 1: p1.payoff = (C.ENDOWMENT - p1.Decision11) self.p1_decision = float(p1.Decision11) self.p2_decision = 1 p2.payoff = float(self.p1_decision * C.MULTIPLIER) p3.payoff = float(self.p1_decision) # Payoff Agent = 120 - Überweisung des Angestellten # Payoff Manager = 2 * Überweisung des zugeteilten Angestellten # Payoff CEO = Summe der Überweisungen des Angestellten class Player(BasePlayer): ActionSupervisor = models.IntegerField( min=0, max=10, label="Out of 10 supervisors, how many do you think chose to set the minimum transfer of 5 points for their " "employee?", ) Decision11 = models.IntegerField( min=0, max=C.ENDOWMENT, label=" How many points do you transfer to the organization (you can enter between 0 and 120 points)? ", ) Decision12 = models.IntegerField( min=5, max=C.ENDOWMENT, label=" How many points do you transfer to the organization (you can enter between 5 and 120 points)? ", ) Decision13 = models.IntegerField( min=5, max=C.ENDOWMENT, label=" How many points do you transfer to the organization (you can enter between 5 and 120 points)? ", ) Decision2 = models.IntegerField( widget=widgets.RadioSelect, choices=[ [1, "Let the employee decide completely freely about her/his transfer."], [2, "Set the minimum transfer of 5 points."] ], label='' ) Decision3 = models.IntegerField( widget=widgets.RadioSelect, choices=[ [1, "Yes, I want to set a minimum transfer requirement of 5."], [2, "No, I want to leave the supervisor free in her/his decision."] ], label='' ) Age = models.IntegerField( choices=[(i, str(i)) for i in range(16, 101)], verbose_name='What is your age?' ) Gender = models.IntegerField( widget=widgets.RadioSelect, choices=[ [0, "Female"], [1, "Male"], [2, "Other"] ] ) Country_of_Residence = models.StringField( choices=sorted([ 'United States', 'Mexico', 'Canada', 'China', 'India', 'Philippines', 'El Salvador', 'Vietnam', 'Cuba', 'Dominican Republic', 'Korea', 'Guatemala', 'Honduras', ' OTHER' ]), verbose_name='What is your country of residence?' ) Main_Language = models.StringField(choices=sorted([ 'English', 'Chinese', 'Hindi', 'Spanish', 'French', 'Arabic', 'Bengali', 'Russian', 'Portuguese', 'Indonesian', 'Japanese', ' OTHER' ]), verbose_name='What is your main language?' ) English_Skills = models.IntegerField(choices=[ (i, f"{i} {'(Fluent)' if i == 10 else '(Bad)' if i == 0 else ''}") for i in range(11) ], verbose_name="" ) # income = models.IntegerField(choices=[ # [1, 'Less than 9,999£'], [2, 'Between 10,000£ and 19,999£'], [3, 'Between 20,000£ and 29,999£'], # [4, 'Between 30,000£ and 39,999£'], # [5, 'Between 40,000£ and 49,999£'], [6, 'Between 50,000£ and 59,999£'], # [7, 'Between 60,000£ and 69,999£'], [8, 'Between 70,000£ and 79,999£'], # [9, 'Between 80,000£ and 89,999£'], [10, 'Between 90,000£ and 99,999£'], # [11, 'Between 100,000£ and 109,999£'], # [12, 'Between 110,000£ and 119,999£'], [13, 'Between 120,000£ and 129,999£'], # [14, 'Between 130,000£ and 139,999£'], [15, 'Between 140,000£ and 149,999£'], # [16, 'More than 150,000£'], # ], verbose_name="What category represents your total household income?" # ) education = models.IntegerField(choices=[ [1, 'Less than High School'], [2, 'High School Diploma'], [3, 'Some college or associate degree'], [4, '4-year college degree'], [5, 'More than 4-year college degree'] ], verbose_name="What is the highest level of education that you have achieved?" ) employmentstatus = models.IntegerField(choices=[ [1, 'Employed'], [6, 'Retired'], [2, 'Self-employed'], [5, 'Stay-at-home mother/father'], [4, 'Student'], [3, 'Unemployed'] ], verbose_name='What is your employment status?' ) # Pages class IntroPart1(Page): pass class Decision1(Page): form_model = Player form_fields = ["Decision11", "Decision12", "Decision13"] class ActionSupervisor(Page): form_model = Player form_fields = ["ActionSupervisor"] class EndPart1(Page): pass class IntroPart2(Page): pass class Decision2(Page): form_model = Player form_fields = ["Decision2"] class EndPart2(Page): pass class IntroPart3(Page): pass class Decision3(Page): form_model = Player form_fields = ["Decision3"] class EndPart3(Page): pass class Decision11(Page): form_model = Player form_fields = ["Decision11"] class Decision12(Page): form_model = Player form_fields = ["Decision12"] class Decision13(Page): form_model = Player form_fields = ["Decision13"] class Survey(Page): form_model = Player form_fields = ["Age", "Gender", "Country_of_Residence", "Main_Language", "English_Skills", "education", "employmentstatus"] # in Part2's pages.py class EndOfPart2(Page): timeout_seconds = 0 # This makes the page auto-submit immediately @staticmethod def before_next_page(player, timeout_happened): player.participant.vars['decision11_from_part2'] = player.Decision11 player.participant.vars['decision12_from_part2'] = player.Decision12 player.participant.vars['decision13_from_part2'] = player.Decision13 player.participant.vars['decision2_from_part2'] = player.Decision2 player.participant.vars['decision3_from_part2'] = player.Decision3 player.participant.vars['p1_decision_from_part2'] = player.group.p1_decision player.participant.vars['p2_decision_from_part2'] = player.group.p2_decision player.participant.vars['p3_decision_from_part2'] = player.group.p3_decision page_sequence = [IntroPart1, Decision11, Decision12, Decision13, Decision1, ActionSupervisor, EndPart1, IntroPart2, Decision2, EndPart2, IntroPart3, Decision3, EndPart3, Survey, EndOfPart2] # page_sequence = [Decision1, Decision2, Decision3, EndOfPart2]