from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Introduction(Page): """Description of the game: How to play and returns expected""" form_model = 'player' def is_displayed(self): print("round", self.round_number) print("player", self.player.participant.vars['treatment']) print("treatment group:", self.group.treatment_group) print("id in group", self.player.id_in_group) return self.round_number == 1 class NGO(Page): def is_displayed(self): return self.player.participant.vars['treatment'] == 'meaning' and self.round_number == 1 form_model = 'player' form_fields = ['ngo'] class Manipulation_Check(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = ['manipulation_check'] class Contribute(Page): """Player: Choose how much to contribute""" form_model = 'player' form_fields = ['contribution'] class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' body_text = "Waiting for other participants to contribute." class Results(Page): """Players payoff: How much each has earned""" def is_displayed(self): print("total payoff", self.player.participant.vars['total_payoff']) return self.player.participant.vars['treatment'] == 'control' def vars_for_template(self): return dict(total_earnings=self.group.total_contribution * Constants.multiplier, aggregated_player_earnings=self.player.participant.vars['total_payoff'], id=self.player.id_in_group) class Results_Meaningful(Page): """Players payoff: How much each has earned""" def is_displayed(self): print("total payoff", self.player.participant.vars['total_payoff']) return self.player.participant.vars['treatment'] == 'meaning' def vars_for_template(self): return dict(total_earnings=self.group.total_contribution * Constants.multiplier, total_donation=self.group.total_contribution * Constants.donation_multiplier, aggregated_player_earnings=self.player.participant.vars['total_payoff'], aggregated_donation_earnings=self.player.participant.vars['total_donation']) class WAMI(Page): def is_displayed(self): return self.round_number == Constants.num_rounds form_model = 'player' form_fields = ["meaningful_career", "contribute_life_meaning", "sense_of_meaning", "satisfying_purpose", "personal_growth", "understand_myself", "make_sense_world", "no_difference", "positive_difference", "greater_purpose" ] class Demographics(Page): def is_displayed(self): return self.round_number == Constants.num_rounds form_model = 'player' form_fields = ['birth_year', 'gender', 'nationality', 'work_experience', 'comment'] class Payment(Page): form_model = 'player' form_fields = ['email'] def is_displayed(self): return self.round_number == Constants.num_rounds class Welcome(Page): def is_displayed(self): return self.round_number == 1 page_sequence = [Welcome, Introduction, NGO, Manipulation_Check, Contribute, ResultsWaitPage, Results, Results_Meaningful, WAMI, Demographics, Payment]