from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Introduction(Page): """Description of the game: How to play and returns expected""" pass class Q2(Page): #The questions on this page are all about decision making task in each round form_model = 'player' form_fields = ['Problem_Q2A', 'Problem_Q2B'] def error_message(self, values): if values['Problem_Q2A'] != 375 or values['Problem_Q2B'] != '1': return '回答に少なくとも1つ誤りがあります。ヒント:【ルール説明を表示する/しない】を押して、マッチング寄付または「当選・落選制度」に関する項目を確認してください。' class Q2_A(Page): pass class Article(Page): pass class Donation_decision(Page): """Player: Choose how much to contribute""" form_model = 'player' form_fields = ['donate'] class Notcontribute(Page): def is_displayed(self): return self.player.donate == "寄付しない" def before_next_page(self): self.player.contribution = 0 class Contribute(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.player.donate == "寄付する" form_model = 'player' form_fields = ['contribution'] class ResultsWaitPage(WaitPage): body_text = "他のプレーヤーが寄付金額を入力するまで待ってください." class Results(Page): """Players payoff: How much each has earned""" def vars_for_template(self): return dict( total_earnings = Constants.endowment-self.player.contribution, future = round((1 + (int(self.player.matching_rate)* 0.01)) *self.player.contribution, 0) ) page_sequence = [Introduction, Q2, Q2_A, Article, Donation_decision, Notcontribute, Contribute, ResultsWaitPage, Results]