import random import math from otree.api import ( BaseConstants, BaseSubsession, BaseGroup, BasePlayer, WaitPage, Page, models, widgets ) doc = """ Your app description """ choice_options = [ [1, 'Below Expectations'], [2, 'Meets Expectations '], [3, 'Exceeds Expectations'], ] ratings = [ 'p1_obj1_rating', 'p1_obj2_rating', 'p1_obj3_rating', 'p1_obj4_rating', 'p1_obj5_rating', 'p2_obj1_rating', 'p2_obj2_rating', 'p2_obj3_rating', 'p2_obj4_rating', 'p2_obj5_rating' ] ratings_final = [ 'p1_obj1_rating_final', 'p1_obj2_rating_final', 'p1_obj3_rating_final', 'p1_obj4_rating_final', 'p1_obj5_rating_final', 'p2_obj1_rating_final', 'p2_obj2_rating_final', 'p2_obj3_rating_final', 'p2_obj4_rating_final', 'p2_obj5_rating_final' ] accepted = [ 'p1_obj1_accepted', 'p1_obj2_accepted', 'p1_obj3_accepted', 'p1_obj4_accepted', 'p1_obj5_accepted', 'p2_obj1_accepted', 'p2_obj2_accepted', 'p2_obj3_accepted', 'p2_obj4_accepted', 'p2_obj5_accepted' ] label_response = "Select Yes if you want to keep the current rating." p1_obj1_rating_label = label_response p1_obj2_rating_label = label_response p1_obj3_rating_label = label_response p1_obj4_rating_label = label_response p1_obj5_rating_label = label_response p2_obj1_rating_label = label_response p2_obj2_rating_label = label_response p2_obj3_rating_label = label_response p2_obj4_rating_label = label_response p2_obj5_rating_label = label_response choices_dict = { 0: 'No Rating', 1: 'Below Expectations', 2: 'Meets Expectations', 3: 'Exceeds Expectations' } class C(BaseConstants): NAME_IN_URL = 'llo' PLAYERS_PER_GROUP = 3 NUM_ROUNDS = 5 EMPLOYEE_1_ROLE = 'Manager A' EMPLOYEE_2_ROLE = 'Manager B' MANAGER_ROLE = 'Director' Manager_Fixed = 75 Manager_Piece = 15 Manager_Group = 100 Director_Fixed = 150 Show_Up = 5 class Subsession(BaseSubsession): pass class Group(BaseGroup): # Player and rated objects p1_obj1_rating = models.IntegerField(label=p1_obj1_rating_label, choices=choice_options) p1_obj2_rating = models.IntegerField(label=p1_obj2_rating_label, choices=choice_options) p1_obj3_rating = models.IntegerField(label=p1_obj3_rating_label, choices=choice_options) p1_obj4_rating = models.IntegerField(label=p1_obj4_rating_label, choices=choice_options) p1_obj5_rating = models.IntegerField(label=p1_obj5_rating_label, choices=choice_options) p2_obj1_rating = models.IntegerField(label=p2_obj1_rating_label, choices=choice_options) p2_obj2_rating = models.IntegerField(label=p2_obj2_rating_label, choices=choice_options) p2_obj3_rating = models.IntegerField(label=p2_obj3_rating_label, choices=choice_options) p2_obj4_rating = models.IntegerField(label=p2_obj4_rating_label, choices=choice_options) p2_obj5_rating = models.IntegerField(label=p2_obj5_rating_label, choices=choice_options) # Rating accepted p1_obj1_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p1_obj2_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p1_obj3_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p1_obj4_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p1_obj5_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p2_obj1_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p2_obj2_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p2_obj3_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p2_obj4_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p2_obj5_accepted = models.BooleanField(initial=False, label="Do you accept the current rating for this Employee?") p1_obj1_rating_final = models.IntegerField(label="Your Rating for Manager A Employee 1", choices=choice_options) p1_obj2_rating_final = models.IntegerField(label="Your Rating for Manager A Employee 2", choices=choice_options) p1_obj3_rating_final = models.IntegerField(label="Your Rating for Manager A Employee 3", choices=choice_options) p1_obj4_rating_final = models.IntegerField(label="Your Rating for Manager A Employee 4", choices=choice_options) p1_obj5_rating_final = models.IntegerField(label="Your Rating for Manager A Employee 5", choices=choice_options) p2_obj1_rating_final = models.IntegerField(label="Your Rating for Manager B Employee 1", choices=choice_options) p2_obj2_rating_final = models.IntegerField(label="Your Rating for Manager B Employee 2", choices=choice_options) p2_obj3_rating_final = models.IntegerField(label="Your Rating for Manager B Employee 3", choices=choice_options) p2_obj4_rating_final = models.IntegerField(label="Your Rating for Manager B Employee 4", choices=choice_options) p2_obj5_rating_final = models.IntegerField(label="Your Rating for Manager B Employee 5", choices=choice_options) p1_p1_obj1_rating_initial = models.IntegerField(initial=0) p1_p1_obj2_rating_initial = models.IntegerField(initial=0) p1_p1_obj3_rating_initial = models.IntegerField(initial=0) p1_p1_obj4_rating_initial = models.IntegerField(initial=0) p1_p1_obj5_rating_initial = models.IntegerField(initial=0) # p1_p2_obj1_rating_initial = models.IntegerField(initial=0) # p1_p2_obj2_rating_initial = models.IntegerField(initial=0) # p1_p2_obj3_rating_initial = models.IntegerField(initial=0) # p1_p2_obj4_rating_initial = models.IntegerField(initial=0) # p1_p2_obj5_rating_initial = models.IntegerField(initial=0) # p2_p1_obj1_rating_initial = models.IntegerField(initial=0) # p2_p1_obj2_rating_initial = models.IntegerField(initial=0) # p2_p1_obj3_rating_initial = models.IntegerField(initial=0) # p2_p1_obj4_rating_initial = models.IntegerField(initial=0) # p2_p1_obj5_rating_initial = models.IntegerField(initial=0) p2_p2_obj1_rating_initial = models.IntegerField(initial=0) p2_p2_obj2_rating_initial = models.IntegerField(initial=0) p2_p2_obj3_rating_initial = models.IntegerField(initial=0) p2_p2_obj4_rating_initial = models.IntegerField(initial=0) p2_p2_obj5_rating_initial = models.IntegerField(initial=0) total_BelowNr = models.IntegerField() total_BelowPer = models.FloatField() total_MeetsNr = models.IntegerField() total_MeetsPer = models.FloatField() total_ExceedsNr = models.IntegerField() total_ExceedsPer = models.FloatField() final_total_BelowNr = models.IntegerField() final_total_BelowPer = models.FloatField() final_total_MeetsNr = models.IntegerField() final_total_MeetsPer = models.FloatField() final_total_ExceedsNr = models.IntegerField() final_total_ExceedsPer = models.FloatField() final_M1_Below = models.IntegerField() final_M1_Meets = models.IntegerField() final_M1_Exceeds = models.IntegerField() final_M2_Below = models.IntegerField() final_M2_Meets = models.IntegerField() final_M2_Exceeds = models.IntegerField() # final_group_dis = models.IntegerField() # Negotiation: n1 is their first rating; n2 is their second rating for Player X and object = picture # p1_p1_obj1_n1_rating = models.IntegerField(initial=0) p1_p1_obj2_n1_rating = models.IntegerField(initial=0) p1_p1_obj3_n1_rating = models.IntegerField(initial=0) p1_p1_obj4_n1_rating = models.IntegerField(initial=0) p1_p1_obj5_n1_rating = models.IntegerField(initial=0) p1_p2_obj1_n1_rating = models.IntegerField(initial=0) p1_p2_obj2_n1_rating = models.IntegerField(initial=0) p1_p2_obj3_n1_rating = models.IntegerField(initial=0) p1_p2_obj4_n1_rating = models.IntegerField(initial=0) p1_p2_obj5_n1_rating = models.IntegerField(initial=0) p2_p1_obj1_n1_rating = models.IntegerField(initial=0) p2_p1_obj2_n1_rating = models.IntegerField(initial=0) p2_p1_obj3_n1_rating = models.IntegerField(initial=0) p2_p1_obj4_n1_rating = models.IntegerField(initial=0) p2_p1_obj5_n1_rating = models.IntegerField(initial=0) p2_p2_obj1_n1_rating = models.IntegerField(initial=0) p2_p2_obj2_n1_rating = models.IntegerField(initial=0) p2_p2_obj3_n1_rating = models.IntegerField(initial=0) p2_p2_obj4_n1_rating = models.IntegerField(initial=0) p2_p2_obj5_n1_rating = models.IntegerField(initial=0) p1_p1_obj1_n2_rating = models.IntegerField(initial=0) p1_p1_obj2_n2_rating = models.IntegerField(initial=0) p1_p1_obj3_n2_rating = models.IntegerField(initial=0) p1_p1_obj4_n2_rating = models.IntegerField(initial=0) p1_p1_obj5_n2_rating = models.IntegerField(initial=0) p1_p2_obj1_n2_rating = models.IntegerField(initial=0) p1_p2_obj2_n2_rating = models.IntegerField(initial=0) p1_p2_obj3_n2_rating = models.IntegerField(initial=0) p1_p2_obj4_n2_rating = models.IntegerField(initial=0) p1_p2_obj5_n2_rating = models.IntegerField(initial=0) p2_p1_obj1_n2_rating = models.IntegerField(initial=0) p2_p1_obj2_n2_rating = models.IntegerField(initial=0) p2_p1_obj3_n2_rating = models.IntegerField(initial=0) p2_p1_obj4_n2_rating = models.IntegerField(initial=0) p2_p1_obj5_n2_rating = models.IntegerField(initial=0) p2_p2_obj1_n2_rating = models.IntegerField(initial=0) p2_p2_obj2_n2_rating = models.IntegerField(initial=0) p2_p2_obj3_n2_rating = models.IntegerField(initial=0) p2_p2_obj4_n2_rating = models.IntegerField(initial=0) p2_p2_obj5_n2_rating = models.IntegerField(initial=0) class Player(BasePlayer): condition = models.StringField() KUID = models.StringField( label = "Please enter your KUID." ) Name = models.StringField( label = "Please enter your full name. We will only use this to compensate you for the survey." ) Email = models.StringField( label = "Please enter your email address. We require this to send you the payment via gift card." ) compensation = models.IntegerField() total_compensation = models.FloatField(initial=0) group_bonus = models.IntegerField() final_payoff = models.FloatField(initial=0) first_mover = models.BooleanField(initial=False) obj1_rating_initial = models.IntegerField(label = "Employee 1 Rating", choices=choice_options) obj2_rating_initial = models.IntegerField(label = "Employee 2 Rating", choices=choice_options) obj3_rating_initial = models.IntegerField(label = "Employee 3 Rating", choices=choice_options) obj4_rating_initial = models.IntegerField(label = "Employee 4 Rating", choices=choice_options) obj5_rating_initial = models.IntegerField(label = "Employee 5 Rating", choices=choice_options) p1_obj1_rating_n1 = models.IntegerField() p1_obj2_rating_n1 = models.IntegerField() p1_obj3_rating_n1 = models.IntegerField() p1_obj4_rating_n1 = models.IntegerField() p1_obj5_rating_n1 = models.IntegerField() p2_obj1_rating_n1 = models.IntegerField() p2_obj2_rating_n1 = models.IntegerField() p2_obj3_rating_n1 = models.IntegerField() p2_obj4_rating_n1 = models.IntegerField() p2_obj5_rating_n1 = models.IntegerField() p1_obj1_rating_n2 = models.IntegerField() p1_obj2_rating_n2 = models.IntegerField() p1_obj3_rating_n2 = models.IntegerField() p1_obj4_rating_n2 = models.IntegerField() p1_obj5_rating_n2 = models.IntegerField() p2_obj1_rating_n2 = models.IntegerField() p2_obj2_rating_n2 = models.IntegerField() p2_obj3_rating_n2 = models.IntegerField() p2_obj4_rating_n2 = models.IntegerField() p2_obj5_rating_n2 = models.IntegerField() # Additional task related question Task = models.LongStringField(label = 'Please write your response below:') #Comprehension Check Questions def make_field1(label): return models.IntegerField( choices=[[1, "True",], [2, "False"]], label=label, widget=widgets.RadioSelect, ) C1 = make_field1('You will perform the task today for 5 rounds.') C2 = make_field1('Your role will change in each round.') C3 = make_field1('Participants in today’s session will be assigned to the director role or manager role.') C4 = make_field1('Each director will be matched to 2 managers to form a three-person group.') C5 = make_field1('Each manager oversees 5 employees for a total of 10 employees in the business unit.') C6 = make_field1('The three-person group of two managers and one director will remain the same for all 5 rounds.') C7 = make_field1('For the performance evaluation, managers place each of their 5 employees into one of three categories: Below Expectations, Meets Expectations, or Exceeds Expectations') C9 = make_field1('Managers will provide initial ratings by assigning each of their 5 employees to one of the three performance categories.') C10a = make_field1('The business unit’s initial ratings are determined by combining both managers’ initial ratings.') C11a = make_field1('The director reviews but cannot adjust the business unit’s initial ratings.') C12a = make_field1('The business unit’s initial ratings are approved by the director to become the business unit’s finalized ratings.') C10b = make_field1('The business unit’s initial ratings are determined by combining both managers’ initial ratings.') C11b = make_field1('The director reviews but cannot adjust the business unit’s initial ratings.') C12b = make_field1('Once approved, the business unit’s adjusted initial ratings become the business unit’s finalized ratings.') C10c = make_field1('The business unit’s initial ratings are determined by combining both managers’ initial ratings.') C11c = make_field1('If both managers agree to an adjustment, then the initial rating category is revised for that employee.') C12c = make_field1('The director then approves but cannot adjust the business unit’s revised initial ratings.') C13c = make_field1('Once approved, the business unit’s revised initial ratings become the business unit’s finalized ratings.') C13d = make_field1('Managers have five rounds to agree on an adjustment.') C13e = make_field1('If both managers do not agree to the adjustments, then the initial rating assigned by that manager is used.') C7b = models.IntegerField( label='Which category would employees most prefer being rated?', choices=choice_options, widget=widgets.RadioSelect) C8a = models.IntegerField( label = 'Below Expectations', min = 0, max = 10 ) C8b = models.IntegerField( label = 'Meets Expectations', min = 0, max = 10 ) C8c = models.IntegerField( label = 'Exceeds Expectations', min = 0, max = 10 ) C14 = models.IntegerField( label = 'For this round, what is Manager A’s payoff?', ) C15 = models.IntegerField( label = 'For this round, what is Manager B’s payoff?', ) C16 = models.IntegerField( label = 'For this round, what is Manager C’s payoff?', ) C17 = models.IntegerField( label = 'For this round, what is Manager D’s payoff?', ) C18 = models.IntegerField( label = 'For this round, how many points would the director of this business unit earn?', ) C19 = models.IntegerField( label = 'For this round, how many points would the director of this business unit earn?', ) incorrect_C1 = models.IntegerField(initial=0) incorrect_C2 = models.IntegerField(initial=0) incorrect_C3 = models.IntegerField(initial=0) incorrect_C4 = models.IntegerField(initial=0) incorrect_C5 = models.IntegerField(initial=0) incorrect_C6 = models.IntegerField(initial=0) incorrect_C7 = models.IntegerField(initial=0) incorrect_C7b = models.IntegerField(initial=0) incorrect_C8a = models.IntegerField(initial=0) incorrect_C8b = models.IntegerField(initial=0) incorrect_C8c = models.IntegerField(initial=0) incorrect_C9 = models.IntegerField(initial=0) incorrect_C10a = models.IntegerField(initial=0) incorrect_C11a = models.IntegerField(initial=0) incorrect_C12a = models.IntegerField(initial=0) incorrect_C10b = models.IntegerField(initial=0) incorrect_C11b = models.IntegerField(initial=0) incorrect_C12b = models.IntegerField(initial=0) incorrect_C10c = models.IntegerField(initial=0) incorrect_C11c = models.IntegerField(initial=0) incorrect_C12c = models.IntegerField(initial=0) incorrect_C13c = models.IntegerField(initial=0) incorrect_C13d = models.IntegerField(initial=0) incorrect_C13e = models.IntegerField(initial=0) incorrect_C14 = models.IntegerField(initial=0) incorrect_C15 = models.IntegerField(initial=0) incorrect_C16 = models.IntegerField(initial=0) incorrect_C17 = models.IntegerField(initial=0) incorrect_C18 = models.IntegerField(initial=0) incorrect_C19 = models.IntegerField(initial=0) #PEQs def make_field2(label): return models.IntegerField( choices=[[1, "Strongly Disagree",], [2, "Disagree"], [3, "Somewhat Disagree"], [4, "Neither Agree nor Disagree"], [5, "Somewhat Agree"], [6, "Agree"], [7, "Strongly Agree"] ], label=label, widget=widgets.RadioSelect, ) # Manager/Director PEQs peq1 = make_field2('The performance evaluation process was fair. ') peq2 = make_field2('The performance evaluation process was effective. ') peq3 = make_field2('The performance evaluation process would be motivating to employees.') peq4 = make_field2('The finalized ratings given to all employees were accurate. ') peq5 = make_field2('I had a strong impact on the finalized ratings given to all employees.') # Manager PEQs peq6 = make_field2('I initially rated my employees high to earn the individual bonus. ') peq7 = make_field2('I initially rated my employees high to avoid the individual penalty for each employee I rated as Below Expectations. ') peq8 = make_field2('I was motivated to initially rate my employees to match the business unit’s suggested distribution and earn the group distribution bonus.') peq9 = make_field2('I initially rated my employees high because I wouldn’t want to be perceived as too harsh of an evaluator. ') peq10 = make_field2('I initially rated my employees high because I did not want to deliver low performance scores to my employees. ') peq11 = make_field2('I initially rated my employees high because I did not want them to be demotivated in the future after receiving low performance scores. ') peq12a = make_field2('I initially rated my employees high because I worried the other manager would adjust my employees downward. ') peq12b = make_field2('I initially rated my employees high because I worried the director would adjust my employees downward.') peq13 = make_field2('I initially rated my employees low to be fair to the other manager. ') peq14 = make_field2('I initially rated my employees low to be fair to the director. ') peq15 = make_field2('I initially rated my employees low because I was concerned the other manager would perceive me negatively if I didn’t. ') peq16 = make_field2('I initially rated my employees low because I was concerned the director would perceive me negatively if I didn’t. ') peq17 = make_field2('I assigned similar ratings for all my employees because I did not want to have some employees positively evaluated and others negatively evaluated. ') peq18 = make_field2('I assigned initial ratings based on the quality of the proposed lighting solution.') peq19 = make_field2('I am confident that the initial ratings I provided were accurate.') peq20 = make_field2('I revised my initial ratings because I was concerned the other manager would perceive me negatively if I didn’t. ') peq21 = make_field2('I revised the other manager’s ratings to earn the group distribution bonus. ') peq22 = make_field2('I revised the other manager’s ratings because the other manager was being too harsh with their evaluations.') peq23 = make_field2('I revised the other manager’s ratings because the other manager was being too easy with their evaluations.') peq24 = make_field2('I was more willing to accept the other manager’s initial ratings toward the end of the study. ') # Director PEQs peq25 = make_field2('I revised the ratings to meet the suggested distribution so I can earn the group bonus. ') peq26 = make_field2('I revised the ratings because I worried the managers were more concerned about maximizing their own wealth. ') peq27 = make_field2('I revised the ratings because I felt one manager was being too harsh with their evaluations.') peq28 = make_field2('I revised the ratings because I felt one manager was being too easy with their evaluations.') peq29 = make_field2('I felt responsible for the business unit achieving the suggested distribution. ') peq30 = make_field2('The task was interesting.') peq31 = make_field2('The task was difficult.') peq32 = make_field2('The task was fun.') #Demographic Questions age = models.IntegerField(min = 18, max = 99, label = 'What is your age?') gender = models.StringField( label = 'What is your gender?', choices = ['Male', 'Female', 'Non-Binary', 'Prefer not to answer'], widget=widgets.RadioSelect) graduation = models.IntegerField( label = 'What is your expected graduation year?' ) experience = models.IntegerField(max = 90, label = 'How many years of working experience do you have?',) major = models.StringField( label = "What is your major?") english = models.StringField( label = 'Is English your first language?', choices = ['Yes', 'No'], widget=widgets.RadioSelect) # PAGES class Consent(Page): form_model = 'player' form_fields = [ 'KUID'] @staticmethod def is_displayed(player): # Shift to first page player.condition = player.session.config['vars']['condition'] return player.round_number == 1 class ConsentViolet(Page): form_model = 'player' form_fields = [ 'Name', 'Email'] @staticmethod def is_displayed(player): # Shift to first page player.condition = player.session.config['vars']['condition'] return player.round_number == 1 class Instructions(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Role1(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Quiz1(Page): form_model = 'player' form_fields = ['C1','C2'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): solutions = dict( C1=1, C2=2 ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C1': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C1 += 1 if values[field_name] != solutions[field_name] and field_name == 'C2': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C2 += 1 return error_messages class Instructions2(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Quiz2(Page): form_model = 'player' form_fields = ['C3','C4','C5','C6'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): solutions = dict( C3=1, C4=1, C5=1, C6=1 ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C3': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C3 += 1 if values[field_name] != solutions[field_name] and field_name == 'C4': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C4 += 1 if values[field_name] != solutions[field_name] and field_name == 'C5': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C5 += 1 if values[field_name] != solutions[field_name] and field_name == 'C6': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C6 += 1 return error_messages class Instructions3(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Instructions4(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Quiz3(Page): form_model = 'player' form_fields = ['C7','C7b'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): solutions = dict( C7=1, C7b=3, ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C7': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C7 += 1 if values[field_name] != solutions[field_name] and field_name == 'C7b': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C7b += 1 return error_messages class Instructions5(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Quiz4(Page): form_model = 'player' form_fields = ['C8a','C8b','C8c'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): solutions = dict( C8a=1, C8b=8, C8c=1 ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C8a': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C8a += 1 if values[field_name] != solutions[field_name] and field_name == 'C8b': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C8b += 1 if values[field_name] != solutions[field_name] and field_name == 'C8c': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C8c += 1 return error_messages class Instructions6(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Instructions7(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Quiz5(Page): form_model = 'player' form_fields = ['C9'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): solutions = dict( C9=1, ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C9': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C9 += 1 return error_messages class Instructions8(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Quiz6(Page): form_model = 'player' def get_form_fields(player: Player): if player.condition == 'no_calibration': return ["C10a", "C11a", "C12a"] elif player.condition == 'director_calibration': return ["C10b", "C11b", "C12b"] elif player.condition == 'peer_calibration': return ["C10c", "C13d", "C11c", "C13e", "C12c","C13c"] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): if player.condition == 'no_calibration': solutions = dict( C10a=1, C11a=1, C12a=1, ) if player.condition == 'director_calibration': solutions = dict( C10b=1, C11b=2, C12b=1, ) if player.condition == 'peer_calibration': solutions = dict( C10c=1, C13d=2, C11c=1, C13e=1, C12c=1, C13c=1 ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C10a': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C10a += 1 if values[field_name] != solutions[field_name] and field_name == 'C11a': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C11a += 1 if values[field_name] != solutions[field_name] and field_name == 'C12a': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C12a+= 1 if values[field_name] != solutions[field_name] and field_name == 'C10b': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C10b += 1 if values[field_name] != solutions[field_name] and field_name == 'C11b': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C11b += 1 if values[field_name] != solutions[field_name] and field_name == 'C12b': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C12b+= 1 if values[field_name] != solutions[field_name] and field_name == 'C10c': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C10c += 1 if values[field_name] != solutions[field_name] and field_name == 'C11c': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C11c += 1 if values[field_name] != solutions[field_name] and field_name == 'C12c': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C12c+= 1 if values[field_name] != solutions[field_name] and field_name == 'C13c': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C13c+= 1 if values[field_name] != solutions[field_name] and field_name == 'C13d': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C13c+= 1 if values[field_name] != solutions[field_name] and field_name == 'C13e': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C13c+= 1 return error_messages class Instructions9(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Instructions10(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Instructions11(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Quiz7(Page): form_model = 'player' form_fields = ['C14', 'C15'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): solutions = dict( C14=175, C15=175, ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C14': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C14 += 1 for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C15': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C15 += 1 return error_messages class Quiz7P2(Page): form_model = 'player' form_fields = ['C16', 'C17'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): solutions = dict( C16=105, C17=75, ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C16': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C16 += 1 for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C17': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C17 += 1 return error_messages class Instructions12(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class Quiz8(Page): form_model = 'player' form_fields = ['C18', 'C19'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): solutions = dict( C18=250, C19=150, ) error_messages = dict() for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C18': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C18 += 1 for field_name in solutions: if values[field_name] != solutions[field_name] and field_name == 'C19': error_messages[field_name] = 'INCORRECT! Please try it again.' player.incorrect_C19 += 1 return error_messages class Role2(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 1 class AllWait(WaitPage): body_text = "Once everyone finishes reading the instructions, the task will start. Please wait patiently until everyone else has finished with the instructions. " wait_for_player_in_group = True @staticmethod def is_displayed(player): return player.round_number == 1 class Task(Page): form_model = 'player' form_fields = ['obj1_rating_initial', 'obj2_rating_initial', 'obj3_rating_initial', 'obj4_rating_initial', 'obj5_rating_initial'] @staticmethod def is_displayed(player): return player.role != "Director" class Task2(Page): form_model = 'player' form_fields = ['Task'] class WPRI(WaitPage): @staticmethod def after_all_players_arrive(group: Group): random_rater = random.choice([1, 2]) group.session.p1_obj1_raters_agreed = 0 group.session.p1_obj2_raters_agreed = 0 group.session.p1_obj3_raters_agreed = 0 group.session.p1_obj4_raters_agreed = 0 group.session.p1_obj5_raters_agreed = 0 group.session.p2_obj1_raters_agreed = 0 group.session.p2_obj2_raters_agreed = 0 group.session.p2_obj3_raters_agreed = 0 group.session.p2_obj4_raters_agreed = 0 group.session.p2_obj5_raters_agreed = 0 below_total, meets_total, exceeds_total = 0, 0, 0 for player in group.get_players(): player.participant.rater = False player.participant.rater_n = 0 if player.id_in_group == random_rater: player.participant.rater = True player.first_mover = True if player.id_in_group != 3: p_prefix = f'p{player.id_in_group}_' for n in range(1, 6): initial_rating = getattr(player, f'obj{n}_rating_initial') setattr(player.group, f'p{player.id_in_group}_obj{n}_rating', initial_rating) setattr(player.group, f'{p_prefix}p{player.id_in_group}_obj{n}_rating_initial', initial_rating) for player in group.get_players(): if player.id_in_group == 1: for x in ratings: player_rating = getattr(group, x) if player_rating == 1: below_total += 1 elif player_rating == 2: meets_total += 1 elif player_rating == 3: exceeds_total += 1 group.total_BelowNr = below_total group.total_MeetsNr = meets_total group.total_ExceedsNr = exceeds_total group.total_BelowPer = (group.total_BelowNr/ 10 *100) group.total_MeetsPer = (group.total_MeetsNr / 10 * 100) group.total_ExceedsPer = (group.total_ExceedsNr / 10 * 100) class TaskOutcome(Page): form_model = 'player' @staticmethod def is_displayed(player): if player.role == "Director" and player.condition == 'peer_calibration': return False else: return True @staticmethod def vars_for_template(player: Player): other_player = player.get_others_in_group() others = player.get_others_in_group() for x in other_player: return dict( p1_obj1_rating=choices_dict[player.group.p1_obj1_rating], p1_obj2_rating=choices_dict[player.group.p1_obj2_rating], p1_obj3_rating=choices_dict[player.group.p1_obj3_rating], p1_obj4_rating=choices_dict[player.group.p1_obj4_rating], p1_obj5_rating=choices_dict[player.group.p1_obj5_rating], p2_obj1_rating=choices_dict[player.group.p2_obj1_rating], p2_obj2_rating=choices_dict[player.group.p2_obj2_rating], p2_obj3_rating=choices_dict[player.group.p2_obj3_rating], p2_obj4_rating=choices_dict[player.group.p2_obj4_rating], p2_obj5_rating=choices_dict[player.group.p2_obj5_rating] ) class Director(Page): form_model = 'group' form_fields = ['p1_obj1_rating_final', 'p1_obj2_rating_final', 'p1_obj3_rating_final', 'p1_obj4_rating_final', 'p1_obj5_rating_final', 'p2_obj1_rating_final', 'p2_obj2_rating_final', 'p2_obj3_rating_final', 'p2_obj4_rating_final', 'p2_obj5_rating_final'] @staticmethod def is_displayed(player): return player.role == "Director" and player.condition == 'director_calibration' @staticmethod def vars_for_template(player: Player): other_player = player.get_others_in_group() others = player.get_others_in_group() for x in other_player: return dict( p1_obj1_rating=choices_dict[player.group.p1_obj1_rating], p1_obj2_rating=choices_dict[player.group.p1_obj2_rating], p1_obj3_rating=choices_dict[player.group.p1_obj3_rating], p1_obj4_rating=choices_dict[player.group.p1_obj4_rating], p1_obj5_rating=choices_dict[player.group.p1_obj5_rating], p2_obj1_rating=choices_dict[player.group.p2_obj1_rating], p2_obj2_rating=choices_dict[player.group.p2_obj2_rating], p2_obj3_rating=choices_dict[player.group.p2_obj3_rating], p2_obj4_rating=choices_dict[player.group.p2_obj4_rating], p2_obj5_rating=choices_dict[player.group.p2_obj5_rating] ) class NP(Page): form_model = 'group' @staticmethod def get_form_fields(player): accepting = [] for obj_check in accepted: accepted_obj = getattr(player.group, obj_check) if not accepted_obj: accepting.append(obj_check.replace('accepted', 'rating')) accepting.append(obj_check) return accepting # @staticmethod # def error_message(player, values): # for k, v in values.items(): # if 'accepted' in k and values[k] is False: # rating = k.replace('accepted', 'rating') # previous_rating = getattr(player.group, rating) # if values[rating] == previous_rating: # label_var = f'{rating}_label' # label = globals().get(label_var) # return f''' # {label} to a value other than {choices_dict[previous_rating]} # or Accept the rating. # ''' @staticmethod def is_displayed(player: Player): if player.condition == 'peer_calibration': all_accepted = [] all_accepts = [ 'p1_obj1_accepted', 'p1_obj2_accepted', 'p1_obj3_accepted', 'p1_obj4_accepted', 'p1_obj5_accepted', 'p2_obj1_accepted', 'p2_obj2_accepted', 'p2_obj3_accepted', 'p2_obj4_accepted', 'p2_obj5_accepted' ] for i in all_accepts: accepted = getattr(player.group, i) all_accepted.append(accepted) if all(all_accepted): return False return player.participant.rater @staticmethod def before_next_page(player: Player, timeout_happened): player.participant.rater_n += 1 print(player.id_in_group, player.participant.rater_n) p_prefix = f'p{player.id_in_group}_' all_objects = ['p1_obj1', 'p1_obj2', 'p1_obj3', 'p1_obj4', 'p1_obj5', 'p2_obj1', 'p2_obj2', 'p2_obj3', 'p2_obj4', 'p2_obj5'] for each_obj in all_objects: rating = getattr(player.group, f'{each_obj}_rating') setattr(player, f'{each_obj}_rating_n{player.participant.rater_n}', rating) setattr(player.group, f'{p_prefix}{each_obj}_n{player.participant.rater_n}_rating', rating) accepted = getattr(player.group, f'{each_obj}_accepted') agreed = getattr(player.session, f'{each_obj}_raters_agreed') if accepted: agreed += 1 else: agreed = 1 setattr(player.session, f'{each_obj}_raters_agreed', agreed) if agreed >= 2: setattr(player.group, f'{each_obj}_accepted', True) setattr(player.group, f'{each_obj}_rating_final', rating) else: setattr(player.group, f'{each_obj}_accepted', False) if p_prefix in each_obj: player_initial_rating = getattr(player, f'{each_obj.replace(p_prefix, "")}_rating_initial') setattr(player.group, f'{each_obj}_rating_final', player_initial_rating) @staticmethod def vars_for_template(player: Player): if (player.role == 'Manager A' and player.first_mover) or (player.role == 'Manager B' and not player.first_mover): first_mover = 'p1' else: first_mover = 'p2' return dict( first_mover=first_mover, p1_p1_obj1_n1_rating=choices_dict[player.group.p1_p1_obj1_n1_rating], p1_p1_obj2_n1_rating=choices_dict[player.group.p1_p1_obj2_n1_rating], p1_p1_obj3_n1_rating=choices_dict[player.group.p1_p1_obj3_n1_rating], p1_p1_obj4_n1_rating=choices_dict[player.group.p1_p1_obj4_n1_rating], p1_p1_obj5_n1_rating=choices_dict[player.group.p1_p1_obj5_n1_rating], p1_p2_obj1_n1_rating=choices_dict[player.group.p1_p2_obj1_n1_rating], p1_p2_obj2_n1_rating=choices_dict[player.group.p1_p2_obj2_n1_rating], p1_p2_obj3_n1_rating=choices_dict[player.group.p1_p2_obj3_n1_rating], p1_p2_obj4_n1_rating=choices_dict[player.group.p1_p2_obj4_n1_rating], p1_p2_obj5_n1_rating=choices_dict[player.group.p1_p2_obj5_n1_rating], p2_p1_obj1_n1_rating=choices_dict[player.group.p2_p1_obj1_n1_rating], p2_p1_obj2_n1_rating=choices_dict[player.group.p2_p1_obj2_n1_rating], p2_p1_obj3_n1_rating=choices_dict[player.group.p2_p1_obj3_n1_rating], p2_p1_obj4_n1_rating=choices_dict[player.group.p2_p1_obj4_n1_rating], p2_p1_obj5_n1_rating=choices_dict[player.group.p2_p1_obj5_n1_rating], p2_p2_obj1_n1_rating=choices_dict[player.group.p2_p2_obj1_n1_rating], p2_p2_obj2_n1_rating=choices_dict[player.group.p2_p2_obj2_n1_rating], p2_p2_obj3_n1_rating=choices_dict[player.group.p2_p2_obj3_n1_rating], p2_p2_obj4_n1_rating=choices_dict[player.group.p2_p2_obj4_n1_rating], p2_p2_obj5_n1_rating=choices_dict[player.group.p2_p2_obj5_n1_rating], p1_p1_obj1_n2_rating=choices_dict[player.group.p1_p1_obj1_n2_rating], p1_p1_obj2_n2_rating=choices_dict[player.group.p1_p1_obj2_n2_rating], p1_p1_obj3_n2_rating=choices_dict[player.group.p1_p1_obj3_n2_rating], p1_p1_obj4_n2_rating=choices_dict[player.group.p1_p1_obj4_n2_rating], p1_p1_obj5_n2_rating=choices_dict[player.group.p1_p1_obj5_n2_rating], p1_p2_obj1_n2_rating=choices_dict[player.group.p1_p2_obj1_n2_rating], p1_p2_obj2_n2_rating=choices_dict[player.group.p1_p2_obj2_n2_rating], p1_p2_obj3_n2_rating=choices_dict[player.group.p1_p2_obj3_n2_rating], p1_p2_obj4_n2_rating=choices_dict[player.group.p1_p2_obj4_n2_rating], p1_p2_obj5_n2_rating=choices_dict[player.group.p1_p2_obj5_n2_rating], p2_p1_obj1_n2_rating=choices_dict[player.group.p2_p1_obj1_n2_rating], p2_p1_obj2_n2_rating=choices_dict[player.group.p2_p1_obj2_n2_rating], p2_p1_obj3_n2_rating=choices_dict[player.group.p2_p1_obj3_n2_rating], p2_p1_obj4_n2_rating=choices_dict[player.group.p2_p1_obj4_n2_rating], p2_p1_obj5_n2_rating=choices_dict[player.group.p2_p1_obj5_n2_rating], p2_p2_obj1_n2_rating=choices_dict[player.group.p2_p2_obj1_n2_rating], p2_p2_obj2_n2_rating=choices_dict[player.group.p2_p2_obj2_n2_rating], p2_p2_obj3_n2_rating=choices_dict[player.group.p2_p2_obj3_n2_rating], p2_p2_obj4_n2_rating=choices_dict[player.group.p2_p2_obj4_n2_rating], p2_p2_obj5_n2_rating=choices_dict[player.group.p2_p2_obj5_n2_rating], p1_obj1_rating_initial=choices_dict[player.group.p1_p1_obj1_rating_initial], p1_obj2_rating_initial=choices_dict[player.group.p1_p1_obj2_rating_initial], p1_obj3_rating_initial=choices_dict[player.group.p1_p1_obj3_rating_initial], p1_obj4_rating_initial=choices_dict[player.group.p1_p1_obj4_rating_initial], p1_obj5_rating_initial=choices_dict[player.group.p1_p1_obj5_rating_initial], p2_obj1_rating_initial=choices_dict[player.group.p2_p2_obj1_rating_initial], p2_obj2_rating_initial=choices_dict[player.group.p2_p2_obj2_rating_initial], p2_obj3_rating_initial=choices_dict[player.group.p2_p2_obj3_rating_initial], p2_obj4_rating_initial=choices_dict[player.group.p2_p2_obj4_rating_initial], p2_obj5_rating_initial=choices_dict[player.group.p2_p2_obj5_rating_initial], p1_obj1_rating=choices_dict[player.group.p1_obj1_rating], p1_obj2_rating=choices_dict[player.group.p1_obj2_rating], p1_obj3_rating=choices_dict[player.group.p1_obj3_rating], p1_obj4_rating=choices_dict[player.group.p1_obj4_rating], p1_obj5_rating=choices_dict[player.group.p1_obj5_rating], p2_obj1_rating=choices_dict[player.group.p2_obj1_rating], p2_obj2_rating=choices_dict[player.group.p2_obj2_rating], p2_obj3_rating=choices_dict[player.group.p2_obj3_rating], p2_obj4_rating=choices_dict[player.group.p2_obj4_rating], p2_obj5_rating=choices_dict[player.group.p2_obj5_rating] ) class WP(WaitPage): @staticmethod def is_displayed(player): return player.condition == 'peer_calibration' @staticmethod def after_all_players_arrive(group: Group): managers = ('Manager A', 'Manager B') for p in group.get_players(): if p.role in managers: p.participant.rater = False if p.participant.rater else True class FP(WaitPage): # @staticmethod # def is_displayed(player): # return player.condition == 'peer_calibration' @staticmethod def after_all_players_arrive(group: Group): final_below_total, final_meets_total, final_exceeds_total = 0, 0, 0 final_M1_Below, final_M1_Meets, final_M1_Exceeds = 0, 0, 0 final_M2_Below, final_M2_Meets, final_M2_Exceeds = 0, 0, 0 for player in group.get_players(): if player.id_in_group != 3 and player.condition == 'peer_calibration': for n in range(1, 6): final_rating = getattr(group, f'p{player.id_in_group}_obj{n}_rating_final') setattr(player.group, f'p{player.id_in_group}_obj{n}_rating', final_rating) if player.id_in_group == 1 and player.condition == 'no_calibration': group.p1_obj1_rating_final = group.p1_obj1_rating group.p1_obj2_rating_final = group.p1_obj2_rating group.p1_obj3_rating_final = group.p1_obj3_rating group.p1_obj4_rating_final = group.p1_obj4_rating group.p1_obj5_rating_final = group.p1_obj5_rating group.p2_obj1_rating_final = group.p2_obj1_rating group.p2_obj2_rating_final = group.p2_obj2_rating group.p2_obj3_rating_final = group.p2_obj3_rating group.p2_obj4_rating_final = group.p2_obj4_rating group.p2_obj5_rating_final = group.p2_obj5_rating if player.id_in_group == 1: for x in ratings_final: player_rating = getattr(group, x) if player_rating == 1: final_below_total += 1 elif player_rating == 2: final_meets_total += 1 elif player_rating == 3: final_exceeds_total += 1 group.final_total_BelowNr = final_below_total group.final_total_MeetsNr = final_meets_total group.final_total_ExceedsNr = final_exceeds_total group.final_total_BelowPer = (group.final_total_BelowNr / 10 * 100) group.final_total_MeetsPer = (group.final_total_MeetsNr / 10 * 100) group.final_total_ExceedsPer = (group.final_total_ExceedsNr / 10 * 100) if x.startswith('p1'): if player_rating == 1: final_M1_Below += 1 elif player_rating == 2: final_M1_Meets += 1 elif player_rating == 3: final_M1_Exceeds += 1 elif x.startswith('p2'): if player_rating == 1: final_M2_Below += 1 elif player_rating == 2: final_M2_Meets += 1 elif player_rating == 3: final_M2_Exceeds += 1 group.final_M1_Below = final_M1_Below group.final_M1_Meets = final_M1_Meets group.final_M1_Exceeds = final_M1_Exceeds group.final_M2_Below = final_M2_Below group.final_M2_Meets = final_M2_Meets group.final_M2_Exceeds = final_M2_Exceeds class TaskOutcome2(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.condition != 'no_calibration' @staticmethod def vars_for_template(player: Player): if player.condition != 'director_calibration': return dict( p1_obj1_rating_final=choices_dict[player.group.p1_obj1_rating], p1_obj2_rating_final=choices_dict[player.group.p1_obj2_rating], p1_obj3_rating_final=choices_dict[player.group.p1_obj3_rating], p1_obj4_rating_final=choices_dict[player.group.p1_obj4_rating], p1_obj5_rating_final=choices_dict[player.group.p1_obj5_rating], p2_obj1_rating_final=choices_dict[player.group.p2_obj1_rating], p2_obj2_rating_final=choices_dict[player.group.p2_obj2_rating], p2_obj3_rating_final=choices_dict[player.group.p2_obj3_rating], p2_obj4_rating_final=choices_dict[player.group.p2_obj4_rating], p2_obj5_rating_final=choices_dict[player.group.p2_obj5_rating] ) @staticmethod def before_next_page(player: Player, timeout_happened): if player.group.final_total_BelowNr == 1 and player.group.final_total_ExceedsNr == 1: if player.id_in_group == 1: player.compensation = C.Manager_Fixed + (C.Manager_Piece * player.group.final_M1_Exceeds) - (C.Manager_Piece * player.group.final_M1_Below) + C.Manager_Group player.group_bonus = 100 elif player.id_in_group == 2: player.compensation = C.Manager_Fixed + (C.Manager_Piece * player.group.final_M2_Exceeds) - (C.Manager_Piece * player.group.final_M2_Below) + C.Manager_Group player.group_bonus = 100 elif player.id_in_group == 3: player.compensation = C.Director_Fixed + C.Manager_Group player.group_bonus = 100 else: if player.id_in_group == 1: player.compensation = C.Manager_Fixed + (C.Manager_Piece * player.group.final_M1_Exceeds) - (C.Manager_Piece * player.group.final_M1_Below) player.group_bonus = 0 elif player.id_in_group == 2: player.compensation = C.Manager_Fixed + (C.Manager_Piece * player.group.final_M2_Exceeds) - (C.Manager_Piece * player.group.final_M2_Below) player.group_bonus = 0 elif player.id_in_group == 3: player.compensation = C.Director_Fixed player.group_bonus = 0 class TaskOutcomeNoCal(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.condition == 'no_calibration' @staticmethod def vars_for_template(player: Player): return dict( p1_obj1_rating_final=choices_dict[player.group.p1_obj1_rating], p1_obj2_rating_final=choices_dict[player.group.p1_obj2_rating], p1_obj3_rating_final=choices_dict[player.group.p1_obj3_rating], p1_obj4_rating_final=choices_dict[player.group.p1_obj4_rating], p1_obj5_rating_final=choices_dict[player.group.p1_obj5_rating], p2_obj1_rating_final=choices_dict[player.group.p2_obj1_rating], p2_obj2_rating_final=choices_dict[player.group.p2_obj2_rating], p2_obj3_rating_final=choices_dict[player.group.p2_obj3_rating], p2_obj4_rating_final=choices_dict[player.group.p2_obj4_rating], p2_obj5_rating_final=choices_dict[player.group.p2_obj5_rating] ) @staticmethod def before_next_page(player: Player, timeout_happened): if player.group.final_total_BelowNr == 1 and player.group.final_total_ExceedsNr == 1: if player.id_in_group == 1: player.compensation = C.Manager_Fixed + (C.Manager_Piece * player.group.final_M1_Exceeds) - (C.Manager_Piece * player.group.final_M1_Below) + C.Manager_Group player.group_bonus = 100 elif player.id_in_group == 2: player.compensation = C.Manager_Fixed + (C.Manager_Piece * player.group.final_M2_Exceeds) - (C.Manager_Piece * player.group.final_M2_Below) + C.Manager_Group player.group_bonus = 100 elif player.id_in_group == 3: player.compensation = C.Director_Fixed + C.Manager_Group player.group_bonus = 100 else: if player.id_in_group == 1: player.compensation = C.Manager_Fixed + (C.Manager_Piece * player.group.final_M1_Exceeds) - (C.Manager_Piece * player.group.final_M1_Below) player.group_bonus = 0 elif player.id_in_group == 2: player.compensation = C.Manager_Fixed + (C.Manager_Piece * player.group.final_M2_Exceeds) - (C.Manager_Piece * player.group.final_M2_Below) player.group_bonus = 0 elif player.id_in_group == 3: player.compensation = C.Director_Fixed player.group_bonus = 0 class TaskOutcome2Dir(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.condition == 'director_calibration' @staticmethod def vars_for_template(player: Player): other_player = player.get_others_in_group() others = player.get_others_in_group() for x in other_player: return dict( p1_obj1_rating=choices_dict[player.group.p1_obj1_rating], p1_obj2_rating=choices_dict[player.group.p1_obj2_rating], p1_obj3_rating=choices_dict[player.group.p1_obj3_rating], p1_obj4_rating=choices_dict[player.group.p1_obj4_rating], p1_obj5_rating=choices_dict[player.group.p1_obj5_rating], p2_obj1_rating=choices_dict[player.group.p2_obj1_rating], p2_obj2_rating=choices_dict[player.group.p2_obj2_rating], p2_obj3_rating=choices_dict[player.group.p2_obj3_rating], p2_obj4_rating=choices_dict[player.group.p2_obj4_rating], p2_obj5_rating=choices_dict[player.group.p2_obj5_rating], p1_obj1_rating_final=choices_dict[player.group.p1_obj1_rating_final], p1_obj2_rating_final=choices_dict[player.group.p1_obj2_rating_final], p1_obj3_rating_final=choices_dict[player.group.p1_obj3_rating_final], p1_obj4_rating_final=choices_dict[player.group.p1_obj4_rating_final], p1_obj5_rating_final=choices_dict[player.group.p1_obj5_rating_final], p2_obj1_rating_final=choices_dict[player.group.p2_obj1_rating_final], p2_obj2_rating_final=choices_dict[player.group.p2_obj2_rating_final], p2_obj3_rating_final=choices_dict[player.group.p2_obj3_rating_final], p2_obj4_rating_final=choices_dict[player.group.p2_obj4_rating_final], p2_obj5_rating_final=choices_dict[player.group.p2_obj5_rating_final] ) class Compensation(Page): form_model = 'player' class Transition(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number < 5 class Transition2(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 5 class PEQ1(Page): form_model = 'player' form_fields = ['peq1', 'peq2', 'peq3', 'peq4', 'peq5'] @staticmethod def is_displayed(player): return player.round_number == 5 class PEQ2(Page): form_model = 'player' form_fields = ['peq6', 'peq7', 'peq8'] @staticmethod def is_displayed(player): return player.round_number == 5 and player.id_in_group != 3 class PEQ3(Page): form_model = 'player' @staticmethod def get_form_fields(player: Player): if player.condition == 'peer_calibration': return ['peq9', 'peq10', 'peq11', 'peq12a'] elif player.condition == 'director_calibration': return ['peq9', 'peq10', 'peq11', 'peq12b'] elif player.condition == 'no_calibration': return ['peq9', 'peq10', 'peq11'] @staticmethod def is_displayed(player): return player.round_number == 5 and player.id_in_group != 3 class PEQ4(Page): form_model = 'player' form_fields = ['peq13', 'peq14', 'peq15', 'peq16', 'peq17', 'peq18', 'peq19'] @staticmethod def is_displayed(player): return player.round_number == 5 and player.id_in_group != 3 class PEQ5(Page): form_model = 'player' form_fields = ['peq20', 'peq21', 'peq22', 'peq23', 'peq24'] @staticmethod def is_displayed(player): return player.round_number == 5 and player.id_in_group != 3 and player.condition == 'peer_calibration' class PEQ6(Page): form_model = 'player' form_fields = ['peq25', 'peq26', 'peq27', 'peq28', 'peq29'] @staticmethod def is_displayed(player): return player.round_number == 5 and player.id_in_group == 3 and player.condition == 'director_calibration' class PEQ7(Page): form_model = 'player' form_fields = ['peq30', 'peq31', 'peq32'] @staticmethod def is_displayed(player): return player.round_number == 5 class Demo(Page): form_model = 'player' form_fields = ['age', 'gender', 'graduation', 'experience', 'major', 'english'] @staticmethod def is_displayed(player): return player.round_number == 5 # Create list to append all compensation across rounds and then sum up @staticmethod def before_next_page(player: Player, timeout_happened): total_compensation = [] for x in player.in_all_rounds(): total_compensation.append(x.compensation) player.total_compensation = round(sum(total_compensation), 2) player.final_payoff = math.ceil((player.total_compensation / 50) + C.Show_Up) class Final(Page): form_model = 'player' @staticmethod def is_displayed(player): return player.round_number == 5 # Create dictionary to capture all compensation across rounds and give it a name: r1_compensation @staticmethod def vars_for_template(player: Player): round_compensation = {} for x in player.in_all_rounds(): round_compensation[f'r{x.round_number}_compensation'] = x.compensation return round_compensation # class Negotiation(Page): # @staticmethod # def vars_for_template(player: Player): # return dict(other_role=player.get_others_in_group()[0].role) # @staticmethod # def js_vars(player: Player): # return dict(my_id=player.id_in_group) # @staticmethod # def live_method(player: Player, data): # group = player.group # [other] = player.get_others_in_group() # if 'amount' in data: # try: # amount = int(data['amount']) # except Exception: # print('Invalid message received', data) # return # if data['type'] == 'accept': # if amount == other.rating_proposed: # player.rating_accepted = amount # group.deal_price = amount # group.is_finished = True # return {0: dict(finished=True)} # if data['type'] == 'propose': # player.rating_proposed = amount # proposals = [] # for p in [player, other]: # rating_proposed = p.field_maybe_none('rating_proposed') # if rating_proposed is not None: # proposals.append([p.id_in_group, rating_proposed]) # return {0: dict(proposals=proposals)} # @staticmethod # def error_message(player: Player, values): # group = player.group # if not group.is_finished: # return "Game not finished yet" # # # Full Instructions - When Violet runs data (consent is changed) # page_sequence = [ConsentViolet, Instructions, Role1, Quiz1, Instructions2, Quiz2, Instructions3, Instructions4, Quiz3, Instructions5, Quiz4, Instructions6, Instructions7, Quiz5, Instructions8, Quiz6, Instructions9, Instructions10, Instructions11, Quiz7, Quiz7P2, Instructions12, Quiz8, Role2, AllWait,Task, Task2, WPRI, TaskOutcome, Director, NP, WP, NP, WP, NP, WP, NP, FP, TaskOutcome2, TaskOutcomeNoCal, TaskOutcome2Dir, Compensation, Transition, Transition2, PEQ1, PEQ2, PEQ3, PEQ4, PEQ5, PEQ6, PEQ7, Demo, Final] # Full Instructions - When Jeremy runs data (consent is changed) page_sequence = [Consent, Instructions, Role1, Quiz1, Instructions2, Quiz2, Instructions3, Instructions4, Quiz3, Instructions5, Quiz4, Instructions6, Instructions7, Quiz5, Instructions8, Quiz6, Instructions9, Instructions10, Instructions11, Quiz7, Quiz7P2, Instructions12, Quiz8, Role2, AllWait,Task, Task2, WPRI, TaskOutcome, Director, NP, WP, NP, WP, NP, WP, NP, FP, TaskOutcome2, TaskOutcomeNoCal, TaskOutcome2Dir, Compensation, Transition, Transition2, PEQ1, PEQ2, PEQ3, PEQ4, PEQ5, PEQ6, PEQ7, Demo, Final] # # # Only some instructions # page_sequence = [Consent, Task, Task2, WPRI, TaskOutcome, Director, NP, WP, NP, WP, NP, WP, NP, FP, TaskOutcome2, TaskOutcomeNoCal, TaskOutcome2Dir, Compensation, Transition, Transition2, PEQ1, PEQ2, PEQ3, PEQ4, PEQ5, PEQ6, PEQ7, Demo, Final]