from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = '' doc = """ """ class Constants(BaseConstants): name_in_url = 'G1G2' players_per_group = 3 num_rounds = 1 answers_G1 = ['b', 'a', 'a'] answers_G2 = ['b', 'c', 'a'] answers_other_R = ['b', 'b', 'a'] answers_other_NS = ['b', 'd', 'a'] answers_Base = ['b', 'b', 'a'] pre_pilot = False # True for pilot for incentivizing Player C 2nd order and emp expectations, False otherwise base_pilot = False excluded_payoff = 6 # 10 for other_R, 6 otherwise other_NS = True # False for other and other_R, True for other_NS class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for p in self.get_players(): # p.random_role = random.randint(1, 3) # p.random_game = random.randint(1, 2) p.random_part = random.randint(1, 2) p.random_parameters = random.randint(1, 2) p.random_order = random.randint(1, 2) for group in self.get_groups(): # group.random_game = random.randint(1, 2) # group.random_game = 2 # manually set game 1 or 2 if Constants.excluded_payoff == 10: group.follow_up = 'other_R' elif Constants.other_NS: group.follow_up = 'other_NS' else: group.follow_up = 'other' # new_structure_a = [[1, 13, 14], [2, 15, 16], [3, 17, 18], [4, 19, 20], # [5, 21, 22], [6, 23, 24], [7, 25, 26], [8, 27, 28], # [9, 29, 30], [10, 31, 32], [11, 33, 34], [12, 35, 36]] # new_structure_b = [[13, 1, 14], [15, 2, 16], [17, 3, 18], [19, 4, 20], # [21, 5, 22], [23, 6, 24], [25, 7, 26], [27, 8, 28], # [29, 9, 30], [31, 10, 32], [33, 11, 34], [35, 12, 36]] new_structure_c = [[14, 13, 1], [16, 15, 2], [18, 17, 3], [20, 19, 4], [22, 21, 5], [24, 23, 6], [26, 25, 7], [28, 27, 8], [30, 29, 9], [32, 31, 10], [34, 33, 11], [36, 35, 12]] # self.set_group_matrix(new_structure_a) # self.set_group_matrix(new_structure_b) self.set_group_matrix(new_structure_c) class Group(BaseGroup): random_game = models.IntegerField(initial=2) # set to 1 or 2 if manually choosing game follow_up = models.StringField() # other_R, other_NS or other class Player(BasePlayer): accept = models.BooleanField() ProlificID = models.StringField() # random_role = models.IntegerField() # player a, b , c random_part = models.IntegerField() # part 1 or 2 to be paid paid = models.BooleanField() # selected to be paid random_parameters = models.IntegerField() # 1 = 12-12-4, 2 = 12-12-6 random_order = models.IntegerField() # Comprehension questions: q1 = models.StringField( label='', choices=[['a', 'The Communal Project'], ['b', 'The Exclusive Project']], widget=widgets.RadioSelect) q2 = models.StringField( label='', choices=[['a', 'Player A: £6, Player B: £10, and Player C: £10'], # ['b', 'All three players earn £10'], ['b', 'Player A: £10, Player B: £10, and Player C: £10'], ['c', 'Player A: £10, Player B: £10, and Player C: £6'], ['d', 'Player A: £12, Player B: £10, and Player C: £6']], widget=widgets.RadioSelect) q3 = models.StringField( label='', choices=[['a', 'True'], ['b', 'False']], widget=widgets.RadioSelect) q1a = models.StringField( label='', choices=[['a', 'The Communal Project'], ['b', 'The Exclusive Project']], widget=widgets.RadioSelect) q2a = models.StringField( label='', choices=[['a', 'Player A: £6, Player B: £10, and Player C: £10'], # ['b', 'All three players earn £10'], ['b', 'Player A: £10, Player B: £10, and Player C: £10'], ['c', 'Player A: £10, Player B: £10, and Player C: £6'], ['d', 'Player A: £12, Player B: £10, and Player C: £6']], widget=widgets.RadioSelect) q3a = models.StringField( label='', choices=[['a', 'True'], ['b', 'False']], widget=widgets.RadioSelect) # baseline Q2 q2_base = models.StringField( label='', choices=[['a', 'Player A'], ['b', 'Player B'], ['c', 'Player C']], widget=widgets.RadioSelect) # baseline Q2 q2_base_a = models.StringField( label='', choices=[['a', 'Player A'], ['b', 'Player B'], ['c', 'Player C']], widget=widgets.RadioSelect) answers_correct = models.IntegerField(initial=0) answers_correct_a = models.IntegerField(initial=0) # game 1 comprehension questions def check_answers_g1(self): answers_given = [self.q1, self.q2, self.q3] for i in range(1, 4): self.answers_correct += (answers_given[i - 1] or "") == Constants.answers_G1[i - 1] def check_answers_g1a(self): answers_given = [self.q1a, self.q2a, self.q3a] for i in range(1, 4): self.answers_correct_a += (answers_given[i - 1] or "") == Constants.answers_G1[i - 1] # game 2 comprehension questions def check_answers_g2(self): answers_given = [self.q1, self.q2, self.q3] for i in range(1, 4): self.answers_correct += (answers_given[i - 1] or "") == Constants.answers_G2[i - 1] def check_answers_g2a(self): answers_given = [self.q1a, self.q2a, self.q3a] for i in range(1, 4): self.answers_correct_a += (answers_given[i - 1] or "") == Constants.answers_G2[i - 1] # other_R comp questions def check_answers_other_r(self): answers_given = [self.q1, self.q2, self.q3] for i in range(1, 4): self.answers_correct += (answers_given[i - 1] or "") == Constants.answers_other_R[i - 1] def check_answers_other_ra(self): answers_given = [self.q1a, self.q2a, self.q3a] for i in range(1, 4): self.answers_correct_a += (answers_given[i - 1] or "") == Constants.answers_other_R[i - 1] # other_NS comp questions def check_answers_other_ns(self): answers_given = [self.q1, self.q2, self.q3] for i in range(1, 4): self.answers_correct += (answers_given[i - 1] or "") == Constants.answers_other_NS[i - 1] def check_answers_other_nsa(self): answers_given = [self.q1a, self.q2a, self.q3a] for i in range(1, 4): self.answers_correct_a += (answers_given[i - 1] or "") == Constants.answers_other_NS[i - 1] # baseline comprehension questions def check_answers_base(self): answers_given = [self.q1, self.q2_base, self.q3] for i in range(1, 4): self.answers_correct += (answers_given[i - 1] or "") == Constants.answers_Base[i - 1] def check_answers_base_a(self): answers_given = [self.q1a, self.q2_base_a, self.q3a] for i in range(1, 4): self.answers_correct_a += (answers_given[i - 1] or "") == Constants.answers_Base[i - 1] # Norms norm1_pun_EP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) norm1_nopun_EP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) norm1_pun_CP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) norm1_nopun_CP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) norm2_pun_EP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) norm2_nopun_EP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) norm2_pun_CP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) norm2_nopun_CP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) emp_norm_pun_EP = models.IntegerField(label='', min=0, max=100) emp_norm_nopun_EP = models.IntegerField(label='', min=0, max=100) confirm = models.BooleanField(label='', choices=[['yes', 'Yes'], ['no', 'No, I wish to revise my answer']]) more_info_norm = models.BooleanField(label='') more_info_norm_report = models.BooleanField(label='') # Baseline pilot norms base_norm1_EP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) base_norm1_CP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) base_norm2_EP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) base_norm2_CP = models.IntegerField(label='', choices=[[1, 'Very inappropriate'], [2, 'Somewhat inappropriate'], [3, 'Neither inappropriate nor appropriate'], [4, 'Somewhat appropriate'], [5, 'Very appropriate']]) base_emp_norm_EP = models.IntegerField(label='', min=0, max=100) base_norm1_min = models.IntegerField(label='', min=0) # Task decisions impose_fee = models.BooleanField(label='') project_choice_pun = models.StringField(label='Suppose Player A decided to impose a fee ' 'against you for choosing the Exclusive Project. ' 'Please select a project.', choices=[['CP', 'Communal Project'], ['EP', 'Exclusive Project']]) project_choice_nopun = models.StringField(label='Suppose Player A decided NOT to impose a fee ' 'against you for choosing the Exclusive Project. ' 'Please select a project.', choices=[['CP', 'Communal Project'], ['EP', 'Exclusive Project']]) # Survey questions gender = models.StringField(label='What is your gender?', choices=[['male', 'Male'], ['female', 'Female'], ['non-binary', 'Non-binary'], ['gender-diverse', 'Gender Diverse'], ['na', 'My gender is not listed'], ['not-say', 'Prefer not to say']]) age = models.IntegerField(label='What is your age?') education = models.StringField(label='What is the highest level of education you have completed?', choices=[['none', 'No formal qualifications'], ['highschool', 'High school diploma'], ['communitycollege', 'Technical/community college'], ['undergrad', 'Undergraduate degree'], ['graduate', 'Graduate degree'], ['NA', 'Not applicable'], ['not-say', 'Prefer not to say']]) religiosity = models.StringField(label='My religion is very important to me', choices=[['SD', 'Strongly disagree'], ['D', 'Disagree'], ['N', 'Neither agree nor disagree'], ['A', 'Agree'], ['SA', 'Strongly agree'], ['not-say', 'Prefer not to say']]) income = models.StringField(label='What is your average household income per year?', choices=[['<20k', 'Less than £20,000'], ['<40>k', '£20,000 - £39,000'], ['<60>k', '£40,000 - £59,000'], ['<80>k', '£60,000 - £79,000'], ['<100k', '£80,000 - £99,000'], ['>100k', 'More than £100,000'], ['not-say', 'Prefer not to say']]) political = models.StringField(label='What is your political orientation?', choices=['Left', 'Centre-Left', 'Centre-Right', 'Right', 'Other', 'Prefer not to say']) open_ended = models.LongStringField(label='') feedback = models.LongStringField(label='Any general comments or feedback (e.g. anything we can improve in ' 'the instructions)?', blank=True)