from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from . import models from .models import Constants #class Introduction(Page): # pass class Send(Page): form_model = models.Group form_fields = ['sent_amount'] def is_displayed(self): return self.player.id_in_group == 1 class WaitForP1(WaitPage): pass class SendBack(Page): form_model = models.Group form_fields = ['sent_back_amount'] def is_displayed(self): return self.player.id_in_group == 2 def vars_for_template(self): return { 'tripled_amount': self.group.sent_amount * self.group.multiplication_factor } def sent_back_amount_choices(self): return currency_range( c(0), self.group.sent_amount * self.group.multiplication_factor, c(10) ) class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Results(Page): def vars_for_template(self): return { 'tripled_amount': self.group.sent_amount * self.group.multiplication_factor, 'player_payoff': self.player.payoff.to_real_world_currency(self.session), 'participant_payoff': self.participant.payoff, 'participant_payoff_currency': self.participant.payoff_plus_participation_fee(), } page_sequence = [ # Introduction, Send, WaitForP1, SendBack, ResultsWaitPage, Results, ]