from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage class ProlificID(Page): form_model = 'player' form_fields = ['Prol'] class Stop(Page): def is_displayed(self): return self.player.Errors > 2 class Instructions_1(Page): def vars_for_template(self): return{ 'treatment': self.session.config['treatment'] } #domande di controllo class Instructions_2(Page): pass form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6','q7'] def error_message(self, values): if values['q1'] != 1: 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 values['q3'] != 1: 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 if values['q5'] != 1: self.player.Errors += 1 return 'The answer to question n. 5 is wrong' if self.session.config['treatment'] == 1: if values['q6'] != 1: self.player.Errors += 1 return 'The answer to question n. 6 is wrong' else: if values['q6'] != 2: self.player.Errors += 1 return 'The answer to question n. 6 is wrong' if values['q7'] != 2: self.player.Errors += 1 return 'The answer to question n. 7 is wrong' 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 is_displayed(self): return self.player.Errors <= 2 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 is_displayed(self): return self.player.Errors <= 2 def vars_for_template(self): return { 'b1_choice': self.player.b1_choice, 'b2_choice': self.player.b2_choice, 'L_total_payment_F': self.player.L_total_payment_F, 'L_total_payment_F_pounds':self.player.L_total_payment_pounds_F, 'L_total_payment_NF': self.player.L_total_payment_NF, 'L_total_payment_NF_pounds':self.player.L_total_payment_pounds_NF, 'B_total_payment': self.player.B_total_payment, 'B_total_payment_pounds': self.player.B_total_payment_pounds, 'F_total_payment': self.player.F_total_payment, 'F_total_payment_pounds': self.player.F_total_payment_pounds, 'treatment': self.session.config['treatment'], } class Questionario(Page): form_model = 'player' def is_displayed(self): return self.player.Errors <= 2 def get_form_fields(self): rt = ['L_beliefs'] return rt class Back_to_Prolific (Page): def is_displayed(self): return self.player.Errors <= 2 page_sequence = [ #ProlificID, Instructions_1, Instructions_2, Stop, choiceL2, Results, Questionario, Back_to_Prolific ]