from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class IntroWp(WaitPage): group_by_arrival_time = True def is_displayed(self): return self.subsession.round_number == 1 class CheatIntroduction(Page): def is_displayed(self): return self.participant.vars['cheat_treatment'] == 'have the possibility to cheat' class NoCheatIntroduction(Page): def is_displayed(self): return self.participant.vars['cheat_treatment'] == 'have no possibility to cheat' class Introduction(Page): """Description of the game: How to play and returns expected""" def vars_for_template(self): return { 'player_in_all_rounds': self.player.in_all_rounds(), } class DetermineVoteNumber(Page): form_model = 'player' form_fields = ['die_rolling'] class VoteNumberResultsWaitPage(WaitPage): pass class VoteNumberResults(Page): def vars_for_template(self): return { 'player_in_all_rounds': self.player.in_all_rounds(), } class Election(Page): form_model = 'player' form_fields = ['vote_p1', 'vote_p2', 'vote_p3', 'vote_p4'] class VoteCheck(Page): form_model = 'player' form_fields = ['vote_p1', 'vote_p2', 'vote_p3', 'vote_p4'] def is_displayed(self): return self.player.vote_check == 2 class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_roles() class VoteResults(Page): def vars_for_template(self): return { 'player_in_all_rounds': self.player.in_all_rounds(), 'total_vote_p1': self.group.total_vote_p1, 'total_vote_p2': self.group.total_vote_p2, 'total_vote_p3': self.group.total_vote_p3, 'total_vote_p4': self.group.total_vote_p4, } class DictatorInstruction(Page): pass class DictatorQuizCheck(Page): form_model = 'player' form_fields = ['practice_question1', 'practice_question2'] def is_displayed(self): return self.player.practice_question1 != 5 or self.player.practice_question2 != 45 class LeaderOffer(Page): form_model = 'player' form_fields = ['dictator_leader_offer'] class DictatorResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_dictator_payoffs() class DictatorResults(Page): def vars_for_template(self): return { 'kept': Constants.dictator_endowment - self.player.dictator_leader_offer - self.player.dictator_leader_offer - self.player.dictator_leader_offer, 'real_leader_offer': self.group.real_leader_offer, } class TrustGameInstruction(Page): pass class TrustGameExample(Page): form_model = 'player' form_fields = ['practice_question3', 'practice_question4'] class TrustQuizCheck(Page): form_model = 'player' form_fields = ['practice_question3', 'practice_question4'] def is_displayed(self): return self.player.practice_question3 != 13 or self.player.practice_question4 != 30 class SendEmployee(Page): form_model = 'player' form_fields = ['sent_amount'] def sent_back_amount_choices(self): return currency_range( c(0), self.player.sent_amount + self.player.sent_amount + self.player.sent_amount, c(1) ) def is_displayed(self): return self.player.is_winner != 1 class WaitForSender(WaitPage): pass class TrustSendBack(Page): form_model = 'group' form_fields = ['sent_back_amount1', 'sent_back_amount2', 'sent_back_amount3'] def vars_for_template(self): return { 'player_in_all_rounds': self.player.in_all_rounds(), } def is_displayed(self): return self.player.is_winner == 1 class TrustResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_trust_payoffs() class TrustResults(Page): def vars_for_template(self): return { 'player_in_all_rounds': self.player.in_all_rounds(), 'total_sent_amount': self.group.total_sent_amount, 'sent_back_amount1': self.group.sent_back_amount1, 'sent_back_amount2': self.group.sent_back_amount2, 'sent_back_amount3': self.group.sent_back_amount3, 'trust_payoff_leader': self.group.total_sent_amount + self.group.total_sent_amount + self.group.total_sent_amount - self.group.sent_back_amount1 - self.group.sent_back_amount2 - self.group.sent_back_amount3, } class PublicGoodInstruction(Page): def is_displayed(self): return self.round_number == 1 class PublicGoodExample(Page): form_model = 'player' form_fields = ['practice_question5', 'practice_question6', 'practice_question7'] class PublicGoodQuizCheck(Page): form_model = 'player' form_fields = ['practice_question5', 'practice_question6', 'practice_question7'] def is_displayed(self): return self.player.practice_question5 != 16 or self.player.practice_question6 != 16 or self.player.practice_question7 != 18 class PublicGoodLeaderTask(Page): """This page is only for Leader Leader sends message to employee Leader: send a message and choose how much to contribute""" form_model = 'group' form_fields = ['public_good_suggested_amount', 'message'] def is_displayed(self): return self.player.is_winner == 1 class PublicGoodEmployeeTask(Page): """This page is only for Employee Employee received the message from leader and make a contribution""" def is_displayed(self): return self.player.is_winner != 1 class PublicGoodContribute(Page): form_model = 'player' form_fields = ['contribution'] def vars_for_template(self): return { 'player_in_previous_rounds': self.player.in_previous_rounds(), } class PublicGoodLeaderMessageWaitPage(WaitPage): body_text = "Please wait for the leader to send a message." def is_displayed(self): return self.player.is_winner != 1 class PublicGoodResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_public_good_payoffs() body_text = "Waiting for other participants to contribute." class PublicGoodResultsSummary(Page): def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): return { 'total_payoffs_public_good': sum([p.public_good_payoffs for p in self.player.in_all_rounds()]), 'player_in_all_rounds': self.player.in_all_rounds(), } class ExperimentResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class ExperimentResultsSummary(Page): def vars_for_template(self): return { 'kept': Constants.dictator_endowment - self.player.dictator_leader_offer - self.player.dictator_leader_offer - self.player.dictator_leader_offer, 'real_leader_offer': self.group.real_leader_offer, 'total_sent_amount': self.group.total_sent_amount, 'sent_back_amount1': self.group.sent_back_amount1, 'sent_back_amount2': self.group.sent_back_amount2, 'sent_back_amount3': self.group.sent_back_amount3, 'player_in_all_rounds': self.player.in_all_rounds(), 'total_payoff': self.player.payoff } class ExperimentSummaryInstruction(Page): pass class Demographics(Page): form_model = 'player' form_fields = ['gender', 'age', 'ethnic', 'grade', 'major'] class Survey(Page): form_model = 'player' form_fields = ['crt_trust1', 'crt_trust2', 'crt_trust3'] page_sequence = [ IntroWp, DetermineVoteNumber, VoteNumberResultsWaitPage, VoteNumberResults, Election, VoteCheck, ResultsWaitPage, DictatorInstruction, LeaderOffer, DictatorResultsWaitPage, VoteResults, PublicGoodInstruction, PublicGoodLeaderTask, PublicGoodLeaderMessageWaitPage, PublicGoodEmployeeTask, PublicGoodContribute, PublicGoodResultsWaitPage, PublicGoodResultsSummary, ExperimentResultsWaitPage, ExperimentResultsSummary, Demographics, Survey, ]