from . import models from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class welcome(Page): pass class leadership_questionnaire(Page): form_model = models.Player form_fields = ['question_1', 'question_2', 'question_3', 'question_4', 'question_5', 'question_6', 'question_7', 'question_8', 'question_9', 'question_10', 'question_11', 'question_12', 'question_13', 'question_14', 'question_15', 'question_16', 'question_17', 'question_18', 'question_19', 'question_20', 'question_21', 'question_22', 'question_23', 'question_24', 'question_25', 'question_26', 'question_27', 'question_28', 'question_29', 'question_30', 'question_31', 'question_32', 'question_33', 'question_34', 'question_35'] class end_of_questionnaire(Page): def before_next_page(self): self.player.order = self.participant.vars['order'] self.player.statuscondition = self.participant.vars['statuscondition'] self.player.leadershipscore = (self.player.question_1 + self.player.question_2 + self.player.question_3 + self.player.question_4 + self.player.question_5 + self.player.question_6 + self.player.question_7 + self.player.question_8 + self.player.question_9 + self.player.question_10 + self.player.question_11 + self.player.question_12 + self.player.question_13 + self.player.question_14 + self.player.question_15 + self.player.question_16 + self.player.question_17 + self.player.question_18 + self.player.question_19 + self.player.question_20 + self.player.question_21 + self.player.question_22 + self.player.question_23 + self.player.question_24 + self.player.question_25 + self.player.question_26 + self.player.question_27 + self.player.question_28 + self.player.question_29 + self.player.question_30 + self.player.question_31 + self.player.question_32 + self.player.question_33 + self.player.question_34 + self.player.question_35) class wait_after_questionnaire(WaitPage): def after_all_players_arrive(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) if p1.statuscondition == 'status': if p1.leadershipscore > p2.leadershipscore: p1.role_saved = 'manager' p2.role_saved = 'subordinate' if p1.leadershipscore < p2.leadershipscore: p1.role_saved = 'subordinate' p2.role_saved = 'manager' if p1.leadershipscore == p2.leadershipscore: p1.statuscondition = 'control' p2.statuscondition = 'control' p1.role_saved = 'Person 1' p2.role_saved = 'Person 2' else: p1.role_saved = 'Person 1' p2.role_saved = 'Person 2' class Introduction(Page): pass class quiz(Page): form_model = models.Player form_fields = ['quiz_1', 'quiz_2', 'quiz_3', 'quiz_4'] def quiz_1_error_message(self, value): if not (value == "2 participants"): return 'That is an incorrect answer. Please try again.' def quiz_2_error_message(self, value): if not (value == "3 rounds"): return 'That is an incorrect answer. Please try again.' def quiz_3_error_message(self, value): if not (value == "I will earn the number of points I took then"): return 'That is an incorrect answer. Please try again.' def quiz_4_error_message(self, value): if not (value == "I will earn zero points then"): return 'That is an incorrect answer. Please try again.' class wait_after_intro(WaitPage): pass class role_assignment_status(Page): def is_displayed(self): return self.player.statuscondition == "status" def vars_for_template(self): if self.player.role_saved == "manager": scoredlowerorhigher = "higher" ownrole = "manager" othersrole = "subordinate" else: scoredlowerorhigher = "lower" ownrole = "subordinate" othersrole = "manager" return {'scoredlowerorhigher': scoredlowerorhigher, 'ownrole': ownrole, 'othersrole': othersrole} class role_assignment_control(Page): def is_displayed(self): return self.player.statuscondition == "control" def vars_for_template(self): if self.player.id_in_group == 1: ownrole = "Person 1" othersrole = "Person 2" else: ownrole = "Person 2" othersrole = "Person 1" return {'ownrole': ownrole, 'othersrole': othersrole} class certainty_harvest_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 2 form_model = models.Player form_fields = ['certainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class lowuncertainty_harvest_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 3 or self.player.participant.vars['order'] == 4 form_model = models.Player form_fields = ['lowuncertainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class highuncertainty_harvest_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 5 or self.player.participant.vars['order'] == 6 form_model = models.Player form_fields = ['highuncertainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class certainty_estimate_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 2 form_model = models.Player form_fields = ['certainty_check'] class lowuncertainty_estimate_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 3 or self.player.participant.vars['order'] == 4 form_model = models.Player form_fields = ['lowuncertainty_estimate', 'lowuncertainty_check'] class highuncertainty_estimate_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 5 or self.player.participant.vars['order'] == 6 form_model = models.Player form_fields = ['highuncertainty_estimate', 'highuncertainty_check'] class wait_after_r1(WaitPage): pass class certainty_harvest_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 3 or self.player.participant.vars['order'] == 5 form_model = models.Player form_fields = ['certainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class lowuncertainty_harvest_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 6 form_model = models.Player form_fields = ['lowuncertainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class highuncertainty_harvest_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 2 or self.player.participant.vars['order'] == 4 form_model = models.Player form_fields = ['highuncertainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class certainty_estimate_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 3 or self.player.participant.vars['order'] == 5 form_model = models.Player form_fields = ['certainty_check'] class lowuncertainty_estimate_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 6 form_model = models.Player form_fields = ['lowuncertainty_estimate', 'lowuncertainty_check'] class highuncertainty_estimate_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 2 or self.player.participant.vars['order'] == 4 form_model = models.Player form_fields = ['highuncertainty_estimate', 'highuncertainty_check'] class wait_after_r2(WaitPage): pass class certainty_harvest_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 4 or self.player.participant.vars['order'] == 6 form_model = models.Player form_fields = ['certainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class lowuncertainty_harvest_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 2 or self.player.participant.vars['order'] == 5 form_model = models.Player form_fields = ['lowuncertainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class highuncertainty_harvest_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 3 form_model = models.Player form_fields = ['highuncertainty_harvest'] def vars_for_template(self): ownrole = self.player.role_saved return {'ownrole': ownrole} class certainty_estimate_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 4 or self.player.participant.vars['order'] == 6 form_model = models.Player form_fields = ['certainty_check'] class lowuncertainty_estimate_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 2 or self.player.participant.vars['order'] == 5 form_model = models.Player form_fields = ['lowuncertainty_estimate', 'lowuncertainty_check'] class highuncertainty_estimate_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 3 form_model = models.Player form_fields = ['highuncertainty_estimate', 'highuncertainty_check'] class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Results_certainty_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 2 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_certainty_harvest = p1.certainty_harvest p2_certainty_harvest = p2.certainty_harvest p1_certainty_payoff = p1.certainty_payoff p2_certainty_payoff = p2.certainty_payoff p1_value_certainty = p1.value_certainty certainty_total_harvest = p1.certainty_total_harvest if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.certainty_overharvest == True: certainty_outcome = "exceeded" else: certainty_outcome = "did not exceed" return {'p1_certainty_harvest': p1_certainty_harvest, 'p2_certainty_harvest': p2_certainty_harvest, 'p1_certainty_payoff': p1_certainty_payoff, 'p2_certainty_payoff': p2_certainty_payoff, 'p1_value_certainty': p1_value_certainty, 'certainty_total_harvest': certainty_total_harvest , 'certainty_outcome': certainty_outcome, 'p1_role': p1_role, 'p2_role': p2_role} class Results_lowuncertainty_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 3 or self.player.participant.vars['order'] == 4 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_lowuncertainty_harvest = p1.lowuncertainty_harvest p2_lowuncertainty_harvest = p2.lowuncertainty_harvest p1_lowuncertainty_payoff = p1.lowuncertainty_payoff p2_lowuncertainty_payoff = p2.lowuncertainty_payoff p1_value_lowuncertainty = p1.value_lowuncertainty lowuncertainty_total_harvest = p1.lowuncertainty_total_harvest min_value_lowuncertainty = Constants.min_value_lowuncertainty max_value_lowuncertainty = Constants.max_value_lowuncertainty if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.lowuncertainty_overharvest == True: lowuncertainty_outcome = "exceeded" else: lowuncertainty_outcome = "did not exceed" return {'p1_lowuncertainty_harvest': p1_lowuncertainty_harvest, 'p2_lowuncertainty_harvest': p2_lowuncertainty_harvest, 'p2_lowuncertainty_payoff': p2_lowuncertainty_payoff, 'p1_value_lowuncertainty': p1_value_lowuncertainty, 'p1_lowuncertainty_payoff': p1_lowuncertainty_payoff, 'lowuncertainty_total_harvest': lowuncertainty_total_harvest, 'lowuncertainty_outcome': lowuncertainty_outcome, 'min_value_lowuncertainty': min_value_lowuncertainty, 'max_value_lowuncertainty': max_value_lowuncertainty, 'p1_role': p1_role, 'p2_role': p2_role} class Results_highuncertainty_r1(Page): def is_displayed(self): return self.player.participant.vars['order'] == 5 or self.player.participant.vars['order'] == 6 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_highuncertainty_harvest = p1.highuncertainty_harvest p2_highuncertainty_harvest = p2.highuncertainty_harvest p1_highuncertainty_payoff = p1.highuncertainty_payoff p2_highuncertainty_payoff = p2.highuncertainty_payoff p1_value_highuncertainty = p1.value_highuncertainty highuncertainty_total_harvest = p1.highuncertainty_total_harvest min_value_highuncertainty = Constants.min_value_highuncertainty max_value_highuncertainty = Constants.max_value_highuncertainty if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.highuncertainty_overharvest == True: highuncertainty_outcome = "exceeded" else: highuncertainty_outcome = "did not exceed" return {'p1_highuncertainty_harvest': p1_highuncertainty_harvest, 'p2_highuncertainty_harvest': p2_highuncertainty_harvest, 'p1_highuncertainty_payoff': p1_highuncertainty_payoff, 'p2_highuncertainty_payoff': p2_highuncertainty_payoff, 'p1_value_highuncertainty': p1_value_highuncertainty, 'highuncertainty_total_harvest': highuncertainty_total_harvest, 'highuncertainty_outcome': highuncertainty_outcome, 'min_value_highuncertainty': min_value_highuncertainty, 'max_value_highuncertainty': max_value_highuncertainty, 'p1_role': p1_role, 'p2_role': p2_role} class Results_certainty_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 3 or self.player.participant.vars['order'] == 5 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_certainty_harvest = p1.certainty_harvest p2_certainty_harvest = p2.certainty_harvest p1_certainty_payoff = p1.certainty_payoff p2_certainty_payoff = p2.certainty_payoff p1_value_certainty = p1.value_certainty certainty_total_harvest = p1.certainty_total_harvest if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.certainty_overharvest == True: certainty_outcome = "exceeded" else: certainty_outcome = "did not exceed" return {'p1_certainty_harvest': p1_certainty_harvest, 'p2_certainty_harvest': p2_certainty_harvest, 'p1_certainty_payoff': p1_certainty_payoff, 'p2_certainty_payoff': p2_certainty_payoff, 'p1_value_certainty': p1_value_certainty, 'certainty_total_harvest': certainty_total_harvest, 'certainty_outcome': certainty_outcome, 'p1_role': p1_role, 'p2_role': p2_role} class Results_lowuncertainty_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 6 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_lowuncertainty_harvest = p1.lowuncertainty_harvest p2_lowuncertainty_harvest = p2.lowuncertainty_harvest p1_lowuncertainty_payoff = p1.lowuncertainty_payoff p2_lowuncertainty_payoff = p2.lowuncertainty_payoff p1_value_lowuncertainty = p1.value_lowuncertainty lowuncertainty_total_harvest = p1.lowuncertainty_total_harvest min_value_lowuncertainty = Constants.min_value_lowuncertainty max_value_lowuncertainty = Constants.max_value_lowuncertainty if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.lowuncertainty_overharvest == True: lowuncertainty_outcome = "exceeded" else: lowuncertainty_outcome = "did not exceed" return {'p1_lowuncertainty_harvest': p1_lowuncertainty_harvest, 'p2_lowuncertainty_harvest': p2_lowuncertainty_harvest, 'p2_lowuncertainty_payoff': p2_lowuncertainty_payoff, 'p1_value_lowuncertainty': p1_value_lowuncertainty, 'p1_lowuncertainty_payoff': p1_lowuncertainty_payoff, 'lowuncertainty_total_harvest': lowuncertainty_total_harvest, 'lowuncertainty_outcome': lowuncertainty_outcome, 'min_value_lowuncertainty': min_value_lowuncertainty, 'max_value_lowuncertainty': max_value_lowuncertainty, 'p1_role': p1_role, 'p2_role': p2_role} class Results_highuncertainty_r2(Page): def is_displayed(self): return self.player.participant.vars['order'] == 2 or self.player.participant.vars['order'] == 4 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_highuncertainty_harvest = p1.highuncertainty_harvest p2_highuncertainty_harvest = p2.highuncertainty_harvest p1_highuncertainty_payoff = p1.highuncertainty_payoff p2_highuncertainty_payoff = p2.highuncertainty_payoff p1_value_highuncertainty = p1.value_highuncertainty highuncertainty_total_harvest = p1.highuncertainty_total_harvest min_value_highuncertainty = Constants.min_value_highuncertainty max_value_highuncertainty = Constants.max_value_highuncertainty if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.highuncertainty_overharvest == True: highuncertainty_outcome = "exceeded" else: highuncertainty_outcome = "did not exceed" return {'p1_highuncertainty_harvest': p1_highuncertainty_harvest, 'p2_highuncertainty_harvest': p2_highuncertainty_harvest, 'p1_highuncertainty_payoff': p1_highuncertainty_payoff, 'p2_highuncertainty_payoff': p2_highuncertainty_payoff, 'p1_value_highuncertainty': p1_value_highuncertainty, 'highuncertainty_total_harvest': highuncertainty_total_harvest, 'highuncertainty_outcome': highuncertainty_outcome, 'min_value_highuncertainty': min_value_highuncertainty, 'max_value_highuncertainty': max_value_highuncertainty, 'p1_role': p1_role, 'p2_role': p2_role} class Results_certainty_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 4 or self.player.participant.vars['order'] == 6 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_certainty_harvest = p1.certainty_harvest p2_certainty_harvest = p2.certainty_harvest p1_certainty_payoff = p1.certainty_payoff p2_certainty_payoff = p2.certainty_payoff p1_value_certainty = p1.value_certainty certainty_total_harvest = p1.certainty_total_harvest if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.certainty_overharvest == True: certainty_outcome = "exceeded" else: certainty_outcome = "did not exceed" return {'p1_certainty_harvest': p1_certainty_harvest, 'p2_certainty_harvest': p2_certainty_harvest, 'p1_certainty_payoff': p1_certainty_payoff, 'p2_certainty_payoff': p2_certainty_payoff, 'p1_value_certainty': p1_value_certainty, 'certainty_total_harvest': certainty_total_harvest, 'certainty_outcome': certainty_outcome, 'p1_role': p1_role, 'p2_role': p2_role} class Results_lowuncertainty_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 2 or self.player.participant.vars['order'] == 5 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_lowuncertainty_harvest = p1.lowuncertainty_harvest p2_lowuncertainty_harvest = p2.lowuncertainty_harvest p1_lowuncertainty_payoff = p1.lowuncertainty_payoff p2_lowuncertainty_payoff = p2.lowuncertainty_payoff p1_value_lowuncertainty = p1.value_lowuncertainty lowuncertainty_total_harvest = p1.lowuncertainty_total_harvest min_value_lowuncertainty = Constants.min_value_lowuncertainty max_value_lowuncertainty = Constants.max_value_lowuncertainty if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.lowuncertainty_overharvest == True: lowuncertainty_outcome = "exceeded" else: lowuncertainty_outcome = "did not exceed" return {'p1_lowuncertainty_harvest': p1_lowuncertainty_harvest, 'p2_lowuncertainty_harvest': p2_lowuncertainty_harvest, 'p2_lowuncertainty_payoff': p2_lowuncertainty_payoff, 'p1_value_lowuncertainty': p1_value_lowuncertainty, 'p1_lowuncertainty_payoff': p1_lowuncertainty_payoff, 'lowuncertainty_total_harvest': lowuncertainty_total_harvest, 'lowuncertainty_outcome': lowuncertainty_outcome, 'min_value_lowuncertainty': min_value_lowuncertainty, 'max_value_lowuncertainty': max_value_lowuncertainty, 'p1_role': p1_role, 'p2_role': p2_role} class Results_highuncertainty_r3(Page): def is_displayed(self): return self.player.participant.vars['order'] == 1 or self.player.participant.vars['order'] == 3 def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p1_highuncertainty_harvest = p1.highuncertainty_harvest p2_highuncertainty_harvest = p2.highuncertainty_harvest p1_highuncertainty_payoff = p1.highuncertainty_payoff p2_highuncertainty_payoff = p2.highuncertainty_payoff p1_value_highuncertainty = p1.value_highuncertainty highuncertainty_total_harvest = p1.highuncertainty_total_harvest min_value_highuncertainty = Constants.min_value_highuncertainty max_value_highuncertainty = Constants.max_value_highuncertainty if p1.statuscondition == "status": p1_role = "the " + p1.role_saved p2_role = "the " + p2.role_saved else: p1_role = p1.role_saved p2_role = p2.role_saved if self.player.highuncertainty_overharvest == True: highuncertainty_outcome = "exceeded" else: highuncertainty_outcome = "did not exceed" return {'p1_highuncertainty_harvest': p1_highuncertainty_harvest, 'p2_highuncertainty_harvest': p2_highuncertainty_harvest, 'p1_highuncertainty_payoff': p1_highuncertainty_payoff, 'p2_highuncertainty_payoff': p2_highuncertainty_payoff, 'p1_value_highuncertainty': p1_value_highuncertainty, 'highuncertainty_total_harvest': highuncertainty_total_harvest, 'highuncertainty_outcome': highuncertainty_outcome, 'min_value_highuncertainty': min_value_highuncertainty, 'max_value_highuncertainty': max_value_highuncertainty, 'p1_role': p1_role, 'p2_role': p2_role} page_sequence = [ welcome, leadership_questionnaire, end_of_questionnaire, wait_after_questionnaire, Introduction, quiz, wait_after_intro, role_assignment_control, role_assignment_status, certainty_harvest_r1, lowuncertainty_harvest_r1, highuncertainty_harvest_r1, certainty_estimate_r1, lowuncertainty_estimate_r1, highuncertainty_estimate_r1, wait_after_r1, certainty_harvest_r2, lowuncertainty_harvest_r2, highuncertainty_harvest_r2, certainty_estimate_r2, lowuncertainty_estimate_r2, highuncertainty_estimate_r2, wait_after_r2, certainty_harvest_r3, lowuncertainty_harvest_r3, highuncertainty_harvest_r3, certainty_estimate_r3, lowuncertainty_estimate_r3, highuncertainty_estimate_r3, ResultsWaitPage, Results_certainty_r1, Results_lowuncertainty_r1, Results_highuncertainty_r1, Results_certainty_r2, Results_lowuncertainty_r2, Results_highuncertainty_r2, Results_certainty_r3, Results_lowuncertainty_r3, Results_highuncertainty_r3 ]