from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): def is_displayed(self): return self.round_number == 1 class Investment(Page): form_model = 'player' form_fields = ['invest_bond','invest_point'] def error_message(self, values): print('values is', values) if values['invest_bond'] + values['invest_point'] > self.player.income: return '合計投資額が固定収入額を超えています。再度、入力しなおしてください。' class Results(Page): def vars_for_template(self): self.player.invest_return() class ResultsSummary(Page): def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): self.player.final_payment() player_in_all_rounds = self.player.in_all_rounds() return dict( total_payoff = sum([p.total_payment for p in player_in_all_rounds]), player_in_all_rounds = player_in_all_rounds, real_gain = sum([p.total_payment - self.player.income for p in player_in_all_rounds]) ) page_sequence = [Introduction, Investment, Results, ResultsSummary]