from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random sys_random = random.SystemRandom() class instructions(Page): def is_displayed(self): return self.round_number == 1 class Vote_1(Page): def is_displayed(self): return self.round_number == 1 or self.round_number == 11 or self.round_number == 21 or self.round_number == 31 form_model = 'player' form_fields = ['vote_choice_A', 'vote_choice_B', 'vote_choice_C', 'vote_choice_D'] def vars_for_template(self): return { 'others_in_group': self.player.get_others_in_group(), } class Vote(Page): def is_displayed(self): return self.round_number != 1 and self.round_number != 11 and self.round_number != 21 and self.round_number != 31 form_model = 'player' form_fields = ['vote_choice_A', 'vote_choice_B', 'vote_choice_C', 'vote_choice_D'] def vars_for_template(self): return { 'player_in_previous_round': self.player.in_round(self.round_number - 1), 'others_in_group': self.player.get_others_in_group(), } class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): runoff_cands = self.group.get_runoff() self.group.determine_winner(runoff_cands) self.group.get_payoffs() class StartingWaitPage(WaitPage): def is_displayed(self): return self.round_number == 1 class Results(Page): def vars_for_template(self): return { 'others_in_group': self.player.get_others_in_group(), } class FinalResultsWait(WaitPage): def is_displayed(self): return self.round_number == 40 class FinalResults(Page): def vars_for_template(self): return { 'player_in_all_rounds': self.player.in_all_rounds(), 'total_payoff': sum([p.payoff for p in self.player.in_all_rounds()]), 'total_dollars': self.participant.payoff_plus_participation_fee(), } def is_displayed(self): return self.round_number == 40 page_sequence = [ instructions, StartingWaitPage, Vote_1, Vote, ResultsWaitPage, Results, FinalResultsWait, FinalResults, ]