from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class FirstPage(WaitPage): group_by_arrival_time = True body_text = "Bitte haben Sie etwas Geduld. Sie werden nun einer Gruppe von" \ " 5 Spieler:innen zugeordnet." class Contribute(Page): """Jetzt entscheidet sich, wie viel Sie tatsächlich beitragen möchten. Erinnern Sie sich: Sie haben zwei Mal die Möglichkeit, einen Betrag an Lünecoins beizusteuern. Jetzt und nachdem Sie gesehen haben, wie viel die Anderen in dieser Runde beitragen.""" form_model = 'player' form_fields = ['contribution1'] 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 self.player.contribution1 = c(10) class Contribute2(Page): """Dies ist die zweite und letzte Beitragsphase. Entscheiden Sie sich, ob Sie zusätzlich zum ersten Beitrag noch mehr beisteuern möchten.""" def is_displayed(self): return self.session.config['color'] == 'red' or self.session.config['color'] == 'blue' form_model = 'player' form_fields = ['contribution2'] def contribution2_max(self): return Constants.endowment - self.player.contribution1 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 4 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution2 = c(10) class Pledge(Page): """Wählen Sie, wie viel Sie dem Projekt zusagen. Hinweis: diese Zusage ist nicht bindend.""" form_model = 'player' form_fields = ['pledge'] 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 self.player.pledge = c(20) class PledgeWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_pledge_payoffs() body_text = "Bitte warten Sie auf die Zusagen der anderen Spieler:innen." class PledgeResults(Page): """Players payoff: How much each has pledged""" def vars_for_template(self): return dict(total_earnings=self.group.total_pledge * Constants.multiplier, 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 3 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Target(Page): """Schlagen Sie ein Gruppenziel vor. Was ist die Menge, die Sie als Gruppe erreichen sollten?""" form_model = 'player' form_fields = ['target'] 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 self.player.target = c(75) class TargetWaitPage(WaitPage): after_all_players_arrive = 'set_group_targets' body_text = "Bitte warten Sie auf die Vorschläge der anderen Spieler:innen." class TargetResults(Page): """Gruppenziel: Der Mittelwert Ihrer Vorschläge für ein Gruppenziel.""" 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 3 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True 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 = "Bitte warten Sie auf die Beitragszusagen der anderen Spieler:innen." class Contribute1ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_contribution1_payoff() body_text = "Bitte warten Sie auf die Beitragszusagen der anderen Spieler:innen." class Threshold(Page): """Bestimmung des Schwellenwerts""" 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 Contribute1Results(Page): """Wie viel hat jede:r in der ersten Beitragsphase beigesteuert?""" 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 3 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class ReviewTreatment(Page): def is_displayed(self): return self.session.config['color'] == 'red' # return self.player.color == 'red' def vars_for_template(self): return dict(name=self.player.id_in_group) form_model = 'player' form_fields = ['mp1', 'mp2', 'mp3', 'mp4', 'mp5'] def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 5 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.mp1 = 2 self.player.mp2 = 2 self.player.mp3 = 2 self.player.mp4 = 2 self.player.mp5 = 2 class ReviewResultsWaitPage(WaitPage): def is_displayed(self): return self.session.config['color'] == 'red' def after_all_players_arrive(self): self.group.set_marks() body_text = "Bitte warten Sie auf die Notenvergabe der anderen Spieler:innen." class ReviewResults(Page): 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 3 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Results(Page): """Players payoff: How much each has earned""" def is_displayed(self): return self.session.config['color'] == 'red' or self.session.config['color'] == 'blue' def vars_for_template(self): return dict( total_earnings=self.group.total_both_contributions * Constants.multiplier, final_amount_left=Constants.endowment - self.player.contribution_sum) 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 Survey2(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7'] def is_displayed(self): return self.session.config['color'] == 'blue' def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 2 # instant timeout, 1 second else: return 5 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Survey2Club(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7', 'q8c'] def is_displayed(self): return self.session.config['color'] == 'green' def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 2 # instant timeout, 1 second else: return 5 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Survey2Review(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7', 'q8r'] def is_displayed(self): return self.session.config['color'] == 'red' def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 2 # instant timeout, 1 second else: return 5 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class Club(Page): def is_displayed(self): return self.session.config['color'] == 'green' form_model = 'player' form_fields = ['club'] def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 5 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.club = True class ClubWaitPage(WaitPage): def is_displayed(self): return self.session.config['color'] == 'green' def after_all_players_arrive(self): self.group.set_threshold() self.group.count_no_of_members() # self.group.set_payoffs() body_text = "Bitte warten Sie auf die Entscheidung der anderen Spieler:innen." class ClubResults(Page): def is_displayed(self): return self.session.config[ 'color'] == 'green' and self.player.club == True and self.group.no_of_club_members > 1 def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 5 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True class ClubResultsFail(Page): def is_displayed(self): return self.session.config[ 'color'] == 'green' and self.player.club == True and self.group.no_of_club_members == 1 form_model = 'player' form_fields = ['contribution2'] def contribution2_max(self): return Constants.endowment - self.player.contribution1 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 4 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution2 = c(10) class Punish(Page): form_model = 'player' form_fields = ['punish', 'contribution2'] def is_displayed(self): return self.session.config[ 'color'] == 'green' and self.player.club == False and self.group.no_of_club_members > 1 def contribution2_max(self): return Constants.endowment - self.player.contribution1 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 5 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.punish = True self.player.contribution2 = c(10) class PunishFail(Page): form_model = 'player' form_fields = ['contribution2'] def is_displayed(self): return self.session.config[ 'color'] == 'green' and self.player.club == False and self.group.no_of_club_members < 2 def contribution2_max(self): return Constants.endowment - self.player.contribution1 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 3 * 60 def before_next_page(self): if self.timeout_happened: self.participant.vars['is_dropout'] = True self.player.contribution2 = c(10) class PunishWaitPage(WaitPage): def is_displayed(self): return self.session.config['color'] == 'green' body_text = "Bitte warten Sie auf die Entscheidung der anderen Spieler:innen." def after_all_players_arrive(self): self.group.count_no_of_punishers() self.group.set_contribution_sum_club() self.group.set_payoffs_club() self.group.set_real_payoff() self.group.set_punish_amounts() class FinalResultsClub(Page): def is_displayed(self): return self.session.config['color'] == 'green' def vars_for_template(self): return dict( total_earnings=self.group.total_both_contributions * Constants.multiplier, final_amount_left=Constants.endowment - self.player.contribution_sum) def get_timeout_seconds(self): if self.participant.vars.get('is_dropout'): return 1 # instant timeout, 1 second else: return 5 * 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!' page_sequence = [FirstPage, Target, TargetWaitPage, TargetResults, Pledge, PledgeWaitPage, PledgeResults, Contribute, Contribute1ResultsWaitPage, Contribute1Results, Club, ClubWaitPage, ClubResults, ClubResultsFail, Punish, PunishFail, PunishWaitPage, ReviewTreatment, ReviewResultsWaitPage, ReviewResults, Contribute2, ResultsWaitPage, Threshold, Results, FinalResultsClub, Survey2, Survey2Club, Survey2Review, FinalPage]