from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants from otree.api import * class FirstPage(WaitPage): body_text = "Please wait, you are being assigned to a group of 6 players." class FirstFirstPage(Page): def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 15 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.notes = 'Dropout!' #Leadership Choice class LeadershipWaitPage(WaitPage): body_text = "Please wait for the other players." class Leadership(Page): def is_displayed(self): return self.session.config['color'] == 'green' def live_method(self, data): group = self.group # print('data is', data) if group.has_leader: return if data.get('leader'): group.has_leader = True # mark all other players as non-volunteers for p in self.get_others_in_group(): p.is_leader = False self.role_player = 'Follower' # mark myself as a volunteer self.is_leader = True self.role_player = 'Leader' # broadcast to the group that the game is finished. return {0: dict(finished=True)} def error_message(self, values): """Prevent users from proceeding before someone has volunteered.""" group = self.group if not group.has_leader: return "Can't move forward" class LeadershipResults(Page): def is_displayed(self): return self.session.config['color'] == 'green' #Pledge1 class Pledge1_Leader_static_Followerstep(Page): def is_displayed(self): return self.session.config['color'] == 'green' and self.player.role_player == 'Follower' def vars_for_template(self): return dict( amount_left=Constants.endowment ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 3 * 60 class Pledge1_Leader_static(Page): """You have been elected as the Leader of the Climate Protection Game. You can now decide whether you want to make a conditional contribution to the Climate Pot or not.""" """The pledge takes the following form: "I pledge to contribute (insert value1). However, if 4 out of the other 5 players contribute at least (insert value2), I pledge to contribute (insert value3). This pledge holds for time periods 1, 2, and 3.". Typically, (insert value3) will be larger than (insert value1) and (insert value2)""" def is_displayed(self): return self.session.config['color'] == 'green' and self.player.role_player == 'Leader' form_model = 'player' form_fields = ['pledge1leader_choice'] def vars_for_template(self): return dict( amount_left=Constants.endowment ) def pledge(self): group = self.group if self.player.pledge1leader_choice == True: group.pledge1leader = True for p in self.get_others_in_group(): p.leader_pledged1 = True p.pledge1leader_choiceAll = True else: self.session.config.update(color='black') group.pledge1leader = False for p in self.get_others_in_group(): p.leader_pledged1 = False p.pledge1leader_choiceAll = False #def nopledge(self): # group = self.group # if not self.player.pledge1leader_choice: # group.pledge1leader = False # self.session.vars.update(color='black') # for p in self.get_others_in_group(): # p.leader_pledged1 = False def update_groupdata(self): if self.player.pledge1leader_choice == True: self.session.vars.update(leader_pledges1=True) else: self.session.vars.update(leader_pledges1=False) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 3 * 60 class Pledge1_Leader_choice_static(Page): """You have chosen to make a conditional contribution to the Climate Pot. The pledge takes the following form: "I pledge to contribute (insert value1). However, if 4 out of the other 5 players contribute at least (insert value2), I pledge to contribute (insert value3). This pledge holds for time periods 1, 2, and 3.". Typically, (insert value3) will be larger than (insert value1) and (insert value2) """ def is_displayed(self): return self.session.config['color'] == 'green' and self.player.role_player == 'Leader' and self.player.pledge1leader_choice == True #try self.player.leader_choice1 == 'Pledge' form_model = 'player' form_fields = ['pledge1leader_choice1', 'pledge1leader_choice2', 'pledge1leader_choice3'] def vars_for_template(self): return dict( amount_left=Constants.endowment ) def update_leaderpledge1_choice1(self): if self.player.pledge1leader_choice1 == 0: self.session.vars.update(pledge1leader_choice1=0) for p in self.get_players(): return p.pledge1leader_choice1 == 0 elif self.player.pledge1leader_choice1 == 1: self.session.vars.update(pledge1leader_choice1=1) for p in self.get_players(): return p.pledge1leader_choice1 == 1 elif self.player.pledge1leader_choice1 == 2: self.session.vars.update(pledge1leader_choice1=2) for p in self.get_players(): return p.pledge1leader_choice1 == 2 elif self.player.pledge1leader_choice1 == 3: self.session.vars.update(pledge1leader_choice1=3) for p in self.get_players(): return p.pledge1leader_choice1 == 3 else: self.session.vars.update(pledge1leader_choice1=4) for p in self.get_players(): return p.pledge1leader_choice1 == 4 def update_leaderpledge1_choice2(self): if self.player.pledge1leader_choice2 == 0: self.session.vars.update(pledge1leader_choice2=0) for p in self.get_players(): return p.pledge1leader_choice2 == 0 elif self.player.pledge1leader_choice2 == 1: self.session.vars.update(pledge1leader_choice2=1) for p in self.get_players(): p.pledge1leader_choice2 = 1 elif self.player.pledge1leader_choice2 == 2: self.session.vars.update(pledge1leader_choice2=2) for p in self.get_players(): p.pledge1leader_choice2 = 2 elif self.player.pledge1leader_choice2 == 3: self.session.vars.update(pledge1leader_choice2=3) for p in self.get_players(): p.pledge1leader_choice2 = 3 else: self.session.vars.update(pledge1leader_choice2=4) for p in self.get_players(): p.pledge1leader_choice1 = 4 def update_leaderpledge1_choice3(self): if self.player.pledge1leader_choice3 == 0: self.session.vars.update(pledge1leader_choice3=0) for p in self.get_others_in_group(): p.pledge1leader_choice3 = 0 elif self.player.pledge1leader_choice3 == 1: self.session.vars.update(pledge1leader_choice3=1) for p in self.get_others_in_group(): p.pledge1leader_choice3 = 1 elif self.player.pledge1leader_choice3 == 2: self.session.vars.update(pledge1leader_choice3=2) for p in self.get_others_in_group(): p.pledge1leader_choice3 = 2 elif self.player.pledge1leader_choice3 == 3: self.session.vars.update(pledge1leader_choice3=3) for p in self.get_others_in_group(): p.pledge1leader_choice3 = 3 else: self.session.vars.update(pledge1leader_choice3=4) for p in self.get_others_in_group(): p.pledge1leader_choice3 = 4 def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 class Pledge1_1WaitPage(WaitPage): def is_displayed(self): return self.session.config['color'] == 'green' \ and self.player.role_player == 'Follower' def after_all_players_arrive(self): self.group.set_pledge1_payoff() self. group.pledge1leader() body_text = "Please wait for the other players." class Pledge1_Leader_static_Leaderstep(Page): def is_displayed(self): return self.session.config['color'] == 'green' \ and self.player.role_player == 'Leader' and self.group.pledge1leader == True def vars_for_template(self): return dict( amount_left=Constants.endowment ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 3 * 60 class Pledge1_Leader_static_overview(Page): """The leader has made a pledge to the Climate Pot for rounds 1, 2, 3. You can see his pledge for rounds 1, 2, 3 below. """ def is_displayed(self): return self.session.config['color'] == 'green' \ and self.player.role_player == 'Follower' and self.player.leader_pledged1 == True def vars_for_template(self): return dict( amount_left=Constants.endowment ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 class Pledge1_Follower_static(Page): """The leader has made a pledge to the Climate Pot for rounds 1, 2, 3. You too can now make a pledge for rounds 1, 2, 3. The pledge takes the following form: "I pledge to contribute (insert value)." """ def is_displayed(self): return self.session.config['color'] == 'green' \ and self.player.role_player == 'Follower' and self.player.leader_pledged1 == True form_model = 'player' form_fields = ['pledge1follower_choice'] def vars_for_template(self): return dict( amount_left=Constants.endowment ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 class Pledge1_ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_pledge1_payoff() body_text = "Please wait for the pledges of the other players." class Pledge1_Results_static(Page): """How much did every player pledge?""" def is_displayed(self): return self.session.config['color'] == 'green' and self.player.leader_pledged1 == True def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Pledge1_LastPage_static(Page): """How much did every player pledge?""" def is_displayed(self): return self.session.config['color'] == 'green' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True #Contribution Wait Pages class Contribution1WaitPage(WaitPage): body_text = "Please wait for the other players." class Contribution2WaitPage(WaitPage): body_text = "Please wait for the other players." class Contribution3WaitPage(WaitPage): body_text = "Please wait for the other players." class Contribution4WaitPage(WaitPage): body_text = "Please wait for the other players." class Contribution5WaitPage(WaitPage): body_text = "Please wait for the other players." class Contribution6WaitPage(WaitPage): body_text = "Please wait for the other players." class Contribution7WaitPage(WaitPage): body_text = "Please wait for the other players." class Contribution8WaitPage(WaitPage): body_text = "Please wait for the other players." class Contribution9WaitPage(WaitPage): body_text = "Please wait for the other players." #Contributions class Contribute1_static(Page): """This is the first of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution1'] def vars_for_template(self): return dict( amount_left=Constants.endowment ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution1 = c(0) class Contribute1_dynamic(Page): """This is the first of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot. Contributions made to the Climate pot are multiplied by 1.5. """ def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution1'] def vars_for_template(self): return dict( amount_left=Constants.endowment ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution1 = c(0) class Contribute2_static(Page): """This is the second of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution2'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution2 = c(0) class Contribute2_dynamic(Page): """This is the second of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the Climate Pot. Contributions made to the Climate Pot are multiplied by 1.5.""" def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution2'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution2 = c(0) class Contribute3_static(Page): """This is the third of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution3'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution3 = c(0) class Contribute3_dynamic(Page): """This is the third of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the Climate Pot. Contributions made to the Climate Pot are multiplied by 1.5.""" def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution3'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution3 = c(0) class Contribute4_static(Page): """This is the fourth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution4'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution4 = c(0) class Contribute4_dynamic(Page): """This is the fourth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the Climate Pot. Contributions made to the Climate Pot are multiplied by 1.0.""" def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution4'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution4 = c(0) class Contribute5_static(Page): """This is the fifth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution5'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution5 = c(0) class Contribute5_dynamic(Page): """This is the fifth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the Climate Pot. Contributions made to the Climate Pot are multiplied by 1.0.""" def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution5'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution5 = c(0) class Contribute6_static(Page): """This is the sixth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution6'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution6 = c(0) class Contribute6_dynamic(Page): """This is the sixth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the Climate Pot. Contributions made to the Climate Pot are multiplied by 1.0.""" def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution6'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution6 = c(0) class Contribute7_static(Page): """This is the seventh of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution7'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution7 = c(0) class Contribute7_dynamic(Page): """This is the seventh of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the Climate Pot. Contributions made to the Climate Pot are multiplied by 0.5.""" def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution7'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution7 = c(0) class Contribute8_static(Page): """This is the eighth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution8'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6- self.player.contribution7 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution8 = c(0) class Contribute8_dynamic(Page): """This is the eighth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the Climate Pot. Contributions made to the Climate Pot are multiplied by 0.5.""" def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution8'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6 - self.player.contribution7 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution8 = c(0) class Contribute9_static(Page): """This is the ninth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the climate pot.""" def is_displayed(self): return self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution9'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6 - self.player.contribution7 - self.player.contribution8 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution9 = c(0) class Contribute9_dynamic(Page): """This is the ninth of 9 rounds of the Climate Protection Game. You can now decide how much you want to contribute to the Climate Pot. Contributions made to the Climate Pot are multiplied by 0.5.""" def is_displayed(self): return self.session.config['color'] == 'red' form_model = 'player' form_fields = ['contribution9'] def vars_for_template(self): return dict( amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6 - self.player.contribution7 - self.player.contribution8 ) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution9 = c(0) class Contribute1ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution1_payoff() body_text = "Please wait for the contributions of the other players." class Contribute2ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution2_payoff() body_text = "Please wait for the contributions of the other players." class Contribute3ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution3_payoff() body_text = "Please wait for the contributions of the other players." class Contribute4ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution4_payoff() body_text = "Please wait for the contributions of the other players." class Contribute5ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution5_payoff() body_text = "Please wait for the contributions of the other players." class Contribute6ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution6_payoff() body_text = "Please wait for the contributions of the other players." class Contribute7ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution7_payoff() body_text = "Please wait for the contributions of the other players." class Contribute8ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution8_payoff() body_text = "Please wait for the contributions of the other players." class Contribute9ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution9_payoff() body_text = "Please wait for the contributions of the other players." class Contribute1Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute1Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute2Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute2Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute3Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute3Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute4Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute4Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute5Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute5Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute6Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute6Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute7Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute7Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute8Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute8Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute9Results_static(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Contribute9Results_dynamic(Page): """How much did every player contribute?""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 1 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True #Threshold and Group Results class Threshold(Page): """Threshold level""" def vars_for_template(self): return dict( total_earnings=self.group.total_contribution123456789_static, final_amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6 - self.player.contribution7 - self.player.contribution8 - self.player.contribution9) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 3 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class ResultsStatic(Page): """Players payoff: How much each has earned""" def is_displayed(self): return self.session.config['color'] == 'blue' def vars_for_template(self): return dict( total_earnings=self.group.total_contribution123456789_static, final_amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6 - self.player.contribution7 - self.player.contribution8 - self.player.contribution9) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 4 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class ResultsDynamic(Page): """Players payoff: How much each has earned""" def is_displayed(self): return self.session.config['color'] == 'red' def vars_for_template(self): return dict( total_aggregate_contributions=self.group.total_contribution123456789_dynamic, final_amount_left=Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3 - self.player.contribution4 - self.player.contribution5 - self.player.contribution6 - self.player.contribution7 - self.player.contribution8 - self.player.contribution9, own_final_contribution=self.player.contribution1 + self.player.contribution2 + self.player.contribution3 + self.player.contribution4 + self.player.contribution5 + self.player.contribution6 + self.player.contribution7 + self.player.contribution8+ self.player.contribution9) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 4 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class FinalPage(Page): form_model = 'player' form_fields = ['email', 'notes'] def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 15 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.notes = 'Dropout!' #Other class ResultsWaitPage(WaitPage): def is_displayed(self): return self.session.config['color'] == 'red' or self.session.config['color'] == 'blue' def after_all_players_arrive(self): self.group.set_threshold() self.group.set_payoffs() self.group.set_real_payoff() body_text = "Please wait for the contributions of the other players." #Sequence page_sequence = [FirstPage, FirstFirstPage, LeadershipWaitPage, Leadership, LeadershipResults, Pledge1_Leader_static_Followerstep, Pledge1_Leader_static, Pledge1_Leader_choice_static, Pledge1_1WaitPage, Pledge1_Leader_static_Leaderstep, Pledge1_Leader_static_overview, Pledge1_Follower_static, Pledge1_ResultsWaitPage, Pledge1_Results_static, Pledge1_LastPage_static, Contribution1WaitPage, Contribute1_static, Contribute1_dynamic, Contribute1ResultsWaitPage, Contribute1Results_static, Contribute1Results_dynamic, Contribution2WaitPage, Contribute2_static, Contribute2_dynamic, Contribute2ResultsWaitPage, Contribute2Results_static, Contribute2Results_dynamic, Contribution3WaitPage, Contribute3_static, Contribute3_dynamic, Contribute3ResultsWaitPage, Contribute3Results_static, Contribute3Results_dynamic, Contribution4WaitPage, Contribute4_static, Contribute4_dynamic, Contribute4ResultsWaitPage, Contribute4Results_static, Contribute4Results_dynamic, Contribution5WaitPage, Contribute5_static, Contribute5_dynamic, Contribute5ResultsWaitPage, Contribute5Results_static, Contribute5Results_dynamic, Contribution6WaitPage, Contribute6_static, Contribute6_dynamic, Contribute6ResultsWaitPage, Contribute6Results_static, Contribute6Results_dynamic, Contribution7WaitPage, Contribute7_static, Contribute7_dynamic, Contribute7ResultsWaitPage, Contribute7Results_static, Contribute7Results_dynamic, Contribution8WaitPage, Contribute8_static, Contribute8_dynamic, Contribute8ResultsWaitPage, Contribute8Results_static, Contribute8Results_dynamic, Contribution9WaitPage, Contribute9_static, Contribute9_dynamic, Contribute9ResultsWaitPage, Contribute9Results_static, Contribute9Results_dynamic, Threshold, ResultsWaitPage, ResultsStatic, ResultsDynamic, FinalPage]