from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from ._builtin import Page, WaitPage from .models import Constants class Fail(Page): def is_displayed(self): return self.participant.vars['passed_screening'] == 0 def vars_for_template(self): self.player.set_fail_payment() class BeliefElicitation(Page): form_model = 'player' def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] def vars_for_template(self): return { 'payment_belief_elicitation': c(self.session.config['payment_belief_elicitation']) } def before_next_page(self): self.player.set_type() self.player.set_signal() class BeliefExample(Page): form_model = 'player' def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] def vars_for_template(self): return { 'payment_belief_elicitation': c(self.session.config['payment_belief_elicitation']) } class BeliefSummary(Page): form_model = 'player' def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] class ControlQuestions1(Page): form_model = 'player' form_fields = ['C1', 'C2', 'instr_1'] def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] def vars_for_template(self): return { 'payment_belief_elicitation': c(self.session.config['payment_belief_elicitation']) } class ControlQuestions2(Page): form_model = 'player' form_fields = ['UQ1', 'UQ2', 'UQ3', 'UQ4Control', 'UQ4SG', 'UQ5Control', 'UQ5SG', 'UQ6', 'instr_2'] def vars_for_template(self): return { 'treatment': self.participant.vars['treatment'] } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] class PerformanceFeedback1(Page): form_model = 'player' def vars_for_template(self): return { 'treatment': self.participant.vars['treatment'] } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] and self.participant.vars['treatment'] != 'Control' class PerformanceFeedback2(Page): form_model = 'player' def vars_for_template(self): return { 'treatment': self.participant.vars['treatment'] } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] class Results(Page): def vars_for_template(self): return { 'total_earnings': self.participant.payoff, 'redemption_code': self.participant.label or self.participant.code, } class Demographics(Page): form_model = 'player' form_fields = ['gender','ethnic','ethnic2','mumbirthplace','dadbirthplace','mumocc','dadocc','householdincome','age','percentMTurk','education','marital','income','occup','state'] def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] class Belief(Page): form_model = 'player' form_fields = ['Belief_0'] def vars_for_template(self): return { 'payment_belief_elicitation': c(self.session.config['payment_belief_elicitation']) } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] class Message1(Page): form_model = 'player' form_fields = ['Belief_1', 'signal_1_repeat_Control', 'signal_1_repeat_SG'] def vars_for_template(self): return { 'Signal_1': self.player.signal_1, 'Belief_0': self.player.Belief_0, 'treatment': self.participant.vars['treatment'], } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] def error_message(self, values): print('values is', values) if (self.player.signal_1 == 1 and values["signal_1_repeat_Control"]!=1 and values[ "signal_1_repeat_SG"] != 1) or ( self.player.signal_1 == 0 and values["signal_1_repeat_Control"]!=2 and values[ "signal_1_repeat_SG"] != 2): self.player.Message1_num_wrong += 1 return 'You did not confirm the correct information. Try again!' class Message2(Page): form_model = 'player' form_fields = ['Belief_2', 'signal_2_repeat_Control', 'signal_2_repeat_SG'] def vars_for_template(self): return { 'Observed_Signal_1': self.player.signal_1, 'Observed_Signal_2': self.player.signal_2, 'Belief_1': self.player.Belief_1, 'treatment': self.participant.vars['treatment'], } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] def error_message(self, values): print('values is', values) if (self.player.signal_2 == 1 and values["signal_2_repeat_Control"] != 1 and values[ "signal_2_repeat_SG"] != 1) or ( self.player.signal_2 == 0 and values["signal_2_repeat_Control"] != 2 and values[ "signal_2_repeat_SG"] != 2): self.player.Message2_num_wrong += 1 return 'You did not confirm the correct information. Try again!' class Message3(Page): form_model = 'player' form_fields = ['Belief_3','signal_3_repeat_Control', 'signal_3_repeat_SG'] def vars_for_template(self): return { 'Observed_Signal_1': self.player.signal_1, 'Observed_Signal_2': self.player.signal_2, 'Observed_Signal_3': self.player.signal_3, 'Belief_2': self.player.Belief_2, 'treatment': self.participant.vars['treatment'], } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] def error_message(self, values): print('values is', values) if (self.player.signal_3 == 1 and values["signal_3_repeat_Control"] != 1 and values[ "signal_3_repeat_SG"] != 1) or ( self.player.signal_3 == 0 and values["signal_3_repeat_Control"] != 2 and values[ "signal_3_repeat_SG"] != 2): self.player.Message3_num_wrong += 1 return 'You did not confirm the correct information. Try again!' class Message4(Page): form_model = 'player' form_fields = ['Belief_4', 'signal_4_repeat_Control', 'signal_4_repeat_SG'] def vars_for_template(self): return { 'Observed_Signal_1': self.player.signal_1, 'Observed_Signal_2': self.player.signal_2, 'Observed_Signal_3': self.player.signal_3, 'Observed_Signal_4': self.player.signal_4, 'Belief_3': self.player.Belief_3, 'treatment': self.participant.vars['treatment'], } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] def error_message(self, values): print('values is', values) if (self.player.signal_4 == 1 and values["signal_4_repeat_Control"] != 1 and values[ "signal_4_repeat_SG"] != 1) or ( self.player.signal_4 == 0 and values["signal_4_repeat_Control"] != 2 and values[ "signal_4_repeat_SG"] != 2): self.player.Message4_num_wrong += 1 return 'You did not confirm the correct information. Try again!' class BeliefDone(Page): form_model = 'player' def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] class Feedback(Page): form_model = 'player' form_fields = ['feedback_part_1','feedback_part_2'] def before_next_page(self): self.player.set_payoff() def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] class Part1(Page): form_model = 'player' class Judges(Page): form_model = 'player' def vars_for_template(self): return { 'treatment': self.participant.vars['treatment'], } def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] class Draw2(Page): form_model = 'player' def vars_for_template(self): return { 'Observed_Signal': self.participant.vars['signals'][self.player.message_number], 'treatment': self.participant.vars['treatment'], 'num': self.player.message_number+1, } def before_next_page(self): self.player.message_counter() def is_displayed(self): return self.participant.vars['passed_screening'] and self.participant.vars['consent'] page_sequence = [ BeliefElicitation, # BeliefExample, ControlQuestions1, Belief, PerformanceFeedback1, PerformanceFeedback2, Judges, ControlQuestions2, BeliefSummary, Draw2, Message1, Draw2, Message2, Draw2, Message3, Draw2, Message4, BeliefDone, Demographics, Feedback, Results ]