from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Introduction(Page): def is_displayed(self): return self.round_number == 1 class Decision(Page): form_model = 'player' form_fields = ['decision'] class Signal(Page): form_model = 'player' form_fields = ['signals'] def vars_for_template(self): button_list = self.player.buttons_table() return { 'button1': button_list[0], 'button2': button_list[1], } class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): for p in self.group.get_players(): p.set_payoff() class Results(Page): def vars_for_template(self): me = self.player opponent = me.other_player() return { 'my_decision': me.decision, 'opponent_decision': opponent.decision, 'same_choice': me.decision == opponent.decision, 'player_in_all_rounds': self.player.in_all_rounds(), 'total_payoff': self.participant.payoff, } class SignalWaitPage(WaitPage): def after_all_players_arrive(self): pass body_text = "Waiting for other participant." class SignalResults(Page): def vars_for_template(self): me = self.player opponent = me.other_player() return { 'my_signal': me.signals, 'opponent_signal': opponent.signals, } class End(Page): def is_displayed(self): return self.round_number == 20 def vars_for_template(self): return { 'participation_fee': self.session.config['participation_fee'], 'experiment_payoff': self.participant.payoff, 'payment': self.participant.payoff_plus_participation_fee() - self.session.config['participation_fee'], 'final_payment': self.participant.payoff_plus_participation_fee(), } class SkillTest(Page): def is_displayed(self): return self.round_number == 10 form_model = 'player' form_fields = ['skill_answer'] page_sequence = [ Introduction, Signal, SignalWaitPage, SignalResults, Decision, ResultsWaitPage, Results, SkillTest, End ]