from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Welcome(Page): pass class WorkingIntro(Page): pass class Working(Page): #form_model = 'player' #form_fields = ['performance', #'solutions', #'all_answers', #'mistakes', #'second_tries', #'third_tries'] timeout_seconds = 120 live_method = 'live_zeros' def before_next_page(self): self.player.participant.vars['performance'] = self.player.performance class Start(Page): def is_displayed(self): return self.round_number == 1 def vars_for_template(self): if self.player.participant.vars['treatment'] == "endo": endo = True else: endo = False if self.player.participant.vars['treatment'] == "exo": exo = True else: exo = False if self.player.participant.vars['treatment'] == "control": control = True else: control = False return dict( p1=c(4), p2=c(5), p3=c(6), p4=c(7), p5=c(8), p6=c(9), control=control, endo=endo, exo=exo ) class Quiz(Page): form_model = 'player' form_fields = ['quiz1', 'quiz2', 'quiz3', 'quiz4'] def is_displayed(self): return self.round_number == 1 def vars_for_template(self): if self.player.participant.vars['treatment'] == "endo": endo = True else: endo = False if self.player.participant.vars['treatment'] == "exo": exo = True else: exo = False if self.player.participant.vars['treatment'] == "control": control = True else: control = False return dict( p1=c(4), p2=c(5), p3=c(6), p4=c(7), p5=c(8), p6=c(9), control=control, endo=endo, exo=exo ) def error_message(self, values): ##adjust whenever payoffs change print('values is', values) if self.player.participant.vars['treatment'] == "control": if values['quiz1'] != c(20) or values['quiz2'] != c(48) or values['quiz3'] != c(80) or values['quiz4'] != c(32): return 'Check your answers again and refer to the instructions to find your mistake.' else: if values['quiz1'] != c(20) or values['quiz2'] != c(48) or values['quiz3'] != c(140) or values['quiz4'] != c(92): return 'Check your answers again and refer to the instructions to find your mistake.' page_sequence = [Welcome, WorkingIntro, Working, Start, Quiz]