from otree.api import * author = 'Your name here.' doc = """ Decision Study """ # Models class C(BaseConstants): NAME_IN_URL = 'ControlAversion' PLAYERS_PER_GROUP = 9 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.FloatField(initial=0) p3_decision = models.FloatField(initial=0) p4_decision = models.FloatField(initial=0) p5_decision = models.IntegerField(initial=0) p6_decision = models.IntegerField(initial=0) p7_decision = models.IntegerField(initial=0) p8_decision = models.IntegerField(initial=0) p9_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) # Employee 1 p2 = self.get_player_by_id(2) # Employee 2 p3 = self.get_player_by_id(3) # Employee 3 p4 = self.get_player_by_id(4) # Employee 4 p5 = self.get_player_by_id(5) # Supervisor 1 p6 = self.get_player_by_id(6) # Supervisor 2 p7 = self.get_player_by_id(7) # Supervisor 3 p8 = self.get_player_by_id(8) # Supervisor 4 p9 = self.get_player_by_id(9) # CEO 1 if p9.Decision3 == 1: p1.payoff = (C.ENDOWMENT - p1.Decision13) self.p1_decision = float(p1.Decision13) self.p5_decision = p5.Decision2 if p9.Decision3 == 1: self.p9_decision = 1 if p9.Decision3 == 2: self.p9_decision = 2 if p9.Decision3 == 1: p2.payoff = (C.ENDOWMENT - p2.Decision13) self.p2_decision = float(p2.Decision13) self.p6_decision = p6.Decision2 if p9.Decision3 == 1: p3.payoff = (C.ENDOWMENT - p3.Decision13) self.p3_decision = float(p3.Decision13) self.p7_decision = p7.Decision2 if p9.Decision3 == 1: p4.payoff = (C.ENDOWMENT - p4.Decision13) self.p4_decision = float(p4.Decision13) self.p8_decision = p8.Decision2 if p9.Decision3 == 2 and p5.Decision2 == 2: p1.payoff = (C.ENDOWMENT - p1.Decision12) self.p5_decision = 2 self.p1_decision = float(p1.Decision12) if p9.Decision3 == 2 and p6.Decision2 == 2: p2.payoff = (C.ENDOWMENT - p2.Decision12) self.p6_decision = 2 self.p2_decision = float(p2.Decision12) if p9.Decision3 == 2 and p7.Decision2 == 2: p3.payoff = (C.ENDOWMENT - p1.Decision12) self.p7_decision = 2 self.p3_decision = float(p3.Decision12) if p9.Decision3 == 2 and p8.Decision2 == 2: p4.payoff = (C.ENDOWMENT - p4.Decision12) self.p8_decision = 2 self.p4_decision = float(p4.Decision12) if p9.Decision3 == 2 and p5.Decision2 == 1: p1.payoff = (C.ENDOWMENT - p1.Decision11) self.p1_decision = float(p1.Decision11) self.p5_decision = 1 if p9.Decision3 == 2 and p6.Decision2 == 1: p2.payoff = (C.ENDOWMENT - p2.Decision11) self.p2_decision = float(p2.Decision11) self.p6_decision = 1 if p9.Decision3 == 2 and p7.Decision2 == 1: p3.payoff = (C.ENDOWMENT - p3.Decision11) self.p3_decision = float(p3.Decision11) self.p7_decision = 1 if p9.Decision3 == 2 and p8.Decision2 == 1: p4.payoff = (C.ENDOWMENT - p4.Decision11) self.p4_decision = float(p4.Decision11) self.p8_decision = 1 p5.payoff = float(self.p1_decision * C.MULTIPLIER) p6.payoff = float(self.p2_decision * C.MULTIPLIER) p7.payoff = float(self.p3_decision * C.MULTIPLIER) p8.payoff = float(self.p4_decision * C.MULTIPLIER) p9.payoff = float(self.p1_decision + self.p2_decision + self.p3_decision + self.p4_decision) # Payoff Agent = 120 - Überweisung des Angestellten # Payoff Manager = 2 * Überweisung des zugeteilten Angestellten # Payoff CEO = Summe der Überweisungen der vier 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 supervisors free in their 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_fields = ["Decision2"] form_model = Player 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", "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 player.participant.vars['p4_decision_from_part2'] = player.group.p4_decision player.participant.vars['p5_decision_from_part2'] = player.group.p5_decision player.participant.vars['p6_decision_from_part2'] = player.group.p6_decision player.participant.vars['p7_decision_from_part2'] = player.group.p7_decision player.participant.vars['p8_decision_from_part2'] = player.group.p8_decision player.participant.vars['p9_decision_from_part2'] = player.group.p9_decision page_sequence = [IntroPart1, Decision11, Decision12, Decision13, Decision1, ActionSupervisor, EndPart1, IntroPart2, Decision2, EndPart2, IntroPart3, Decision3, EndPart3, Survey, EndOfPart2] # page_sequence = [Decision1, Decision2, Decision3, EndOfPart2]