from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Choice(Page): form_model = 'player' form_fields = ['winning_side'] def is_displayed(self): return self.player.participant.vars['treatment'] == "endo" class Answer(Page): form_model = 'player' form_fields = ['dice_report'] def vars_for_template(self): if self.player.participant.vars['treatment'] == "endo": endo = True if self.player.winning_side == self.player.coin_outcome: winning = True else: winning = False else: endo = False if self.player.participant.vars['treatment'] == "exo": exo = True if self.player.coin_outcome: winning = True else: winning = False else: exo = False if self.player.participant.vars['treatment'] == "control": control = True winning = True else: control = False return dict( exo=exo, endo=endo, control=control, perform=self.player.participant.vars['performance'], winning=winning ) def before_next_page(self): self.player.set_payoff() class End(Page): pass class Final(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [Choice, Answer, End, Final]