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 Q1(Page): #The questions on this page are all about matching protocol and number of repetitions form_model = 'player' form_fields = ['Problem_Q1A','Problem_Q1B'] def error_message(self, values): if values['Problem_Q1A'] != 550 or values['Problem_Q1B'] != 1000: return '回答に少なくとも1つ誤りがあります。ヒント:【ルール説明を表示する/しない】を押して、利得計算の内容を確認してください。' class Q1_A(Page): pass class Article(Page): pass class Donation_decision(Page): """Player: Choose how much to contribute""" form_model = 'player' form_fields = ['donate'] class Notcontribution(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) page_sequence = [Introduction, Q1, Q1_A, Article, Donation_decision,Notcontribution ,Contribute, ResultsWaitPage, Results]