from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage class ProlificID(Page): form_model = 'player' form_fields = ['Prol'] class Instructions_1(Page): def vars_for_template(self): return{ 'treatment': self.session.config['treatment'] } pass #domande di controllo class Instructions_2(Page): pass form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4'] def error_message(self, values): if self.session.config["treatment"] ==1: if values['q1'] != 1: self.player.Errors += 1 return 'The answer to question n. 1 is wrong' else: if values['q1'] != 2: self.player.Errors += 1 return 'The answer to question n. 1 is wrong' #attention check if values['q2'] != 2: self.player.Errors += 1 return 'The answer to question n. 2 is wrong' if self.session.config['treatment'] == 1: if values['q3'] != 1: self.player.Errors += 1 return 'The answer to question n. 3 is wrong' else: if values['q3'] != 2: self.player.Errors += 1 return 'The answer to question n. 3 is wrong' if values['q4'] != 1: self.player.Errors += 1 return 'The answer to question n. 4 is wrong' #attention check def vars_for_template(self): return{ 'treatment': self.session.config['treatment'] } ## scelte L class choiceL2 (Page): form_model = 'player' form_fields = ['b1_choice', 'b2_choice'] def before_next_page(self): self.player.set_payoff() def vars_for_template(self): return{ 'treatment': self.session.config['treatment'] } class ResultsWaitPage(WaitPage): pass class Results(Page): def vars_for_template(self): return { 'b1_choice': self.player.b1_choice, 'b2_choice': self.player.b2_choice, 'L_total_payment': self.player.L_total_payment, 'L_total_payment_pounds':self.player.L_total_payment_pounds, 'B_total_payment': self.player.B_total_payment, 'B_total_payment_pounds': self.player.B_total_payment_pounds, } class Back_to_Prolific (Page): pass page_sequence = [ #ProlificID, Instructions_1, Instructions_2, choiceL2, Results, Back_to_Prolific ]