from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Welcome(Page): def is_displayed(self): return self.round_number == 1 class PartIIIIntro(Page): def is_displayed(self): return self.round_number == 1 class StartRoll(Page): def is_displayed(self): return self.round_number == 1 class IntroductionDieroll(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6'] def is_displayed(self): return self.round_number == 1 def vars_for_template(self): return dict( image_path1='part3dierolling/3.mp4', image_path2='part3dierolling/5.mp4' ) def error_message(self, value): if value["q1"] != 0: return 'The first question is not answered correctly. Consult the instructions and try again.' if value["q2"] != 500: return 'The second question is not answered correctly. Consult the instructions and try again.' if value["q3"] != 0: return 'The third question is not answered correctly. Consult the instructions and try again.' if value["q4"] != 0: return 'The fourth question is not answered correctly. Consult the instructions and try again.' if value["q5"] != 500: return 'The fifth question is not answered correctly. Consult the instructions and try again.' if value["q6"] != 0: return 'The sixth question is not answered correctly. Consult the instructions and try again.' class StartPart(Page): def is_displayed(self): return self.round_number == 1 class Roll(Page): def vars_for_template(self): return dict( image_path='part3dierolling/{}.mp4'.format(self.player.actual_roll) ) class ReportDieroll(Page): form_model = 'player' form_fields = ['reported_roll'] def before_next_page(self): self.player.set_payoffs() if self.round_number == Constants.num_rounds: self.player.set_results_dieroll() page_sequence = [ Welcome, PartIIIIntro, StartRoll, IntroductionDieroll, StartPart, Roll, ReportDieroll ]