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'] == 1 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'] == 1 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'] == 1 class ControlQuestions1(Page): form_model = 'player' form_fields = ['C1', 'C2'] def is_displayed(self): return self.participant.vars['passed_screening'] == 1 def error_message(self, values): print('values is', values) if values["C1"] !=1: return 'Your answer to Q1 is Incorrect. Your stated probability will determine your choice between two options. Option A: you receive ' + str(c(self.session.config['payment_belief_elicitation'])) + ' if you scored in the top half; Option B: you receive ' + str(c(self.session.config['payment_belief_elicitation'])) + ' with probability x (picked to be 90% in this case). If x is lower than your reported probability, option A will be chosen and you will receive ' + str(c(self.session.config['payment_belief_elicitation'])) + ' if you scored in the top half. If x is higher than or equal to your reported probability, option B will be chosen and you will receive ' + str(c(self.session.config['payment_belief_elicitation'])) + ' with probability x. Now that x = 90% is higher than your reported probability (75%), option B is chosen and you win the prize with probability x = 90%.' if values["C2"] !=2: return 'Your answer to Q2 is Incorrect. Your stated probability will determine your choice between two options: Option A: you receive ' + str(c(self.session.config['payment_belief_elicitation'])) + ' if you scored in the top half; Option B: you receive ' + str(c(self.session.config['payment_belief_elicitation'])) + ' with probability x (picked to be 50% in this case). If x is lower than your reported probability, option A will be chosen and you will receive ' + str(c(self.session.config['payment_belief_elicitation'])) + ' if you scored in the top half. If x is higher than or equal to your reported probability, option B will be chosen and you will receive ' + str(c(self.session.config['payment_belief_elicitation'])) + ' with probability x. Now that x = 50% is lower than your reported probability (75%), option A is chosen and you win the prize if you scored in the top half, which happens with probability 75% according to your true belief. Suppose you report 40%. In that case, x = 50% is higher than your reported probability (40%), option B will be chosen and you win the prize with probability x = 50%, which is lower than 75%. So you would not have had a higher chance of winning by reporting 40% instead of 75%.' class ControlQuestions2(Page): form_model = 'player' form_fields = ['UQ1', 'UQ2', 'UQ3', 'UQ4Control', 'UQ4SG', 'UQ5Control', 'UQ5SG', 'UQ6'] def vars_for_template(self): return { 'treatment': self.participant.vars['treatment'] } def is_displayed(self): return self.participant.vars['passed_screening'] == 1 def error_message(self, values): print('values is', values) if values["UQ1"] != 2: return 'Your answer to Q1 is Incorrect. We will randomly choose one of the three judges who is then going to give you feedback. We will then ask you again about how likely it is you scored in the top half of performances. We repeat these two steps, randomly choosing a judge and asking you about your performance, for another three times (so you hear 4 messages).' if values["UQ2"] != 3: return 'Your answer to Q2 is Incorrect. There are three judges: one super mean judge, one super nice judge and one realistic judge.' if values["UQ3"] != 4: return 'Your answer to Q3 is incorrect. We will randomly choose one of the three judges who is then going to give you feedback. We will then ask you again about how likely it is you scored in the top half of performances. We repeat these two steps, randomly choosing a judge and asking you about your performance, for another three times (so you hear 4 messages).' if self.participant.vars['treatment'] == 'Control': if values["UQ4Control"] != 2: return 'Your answer to Q4 is incorrect. The super mean judge will always tell you that your score is in the bottom half.' else: if values["UQ4SG"] != 2: return 'Your answer to Q4 is incorrect. The super mean judge will always tell you that you are a bad team.' if values["UQ5SG"] != 1 and values["UQ5Control"] != 1: return 'Your answer to Q5 is incorrect. The realistic judge will tell you the truth.' if values["UQ6"] != 1: return 'Your answer to Q6 is incorrect. It could be the case that the super nice judge is always randomly chosen.' class PerformanceFeedback(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'] == 1 class Results(Page): def vars_for_template(self): return { 'total_earnings': self.player.payoff, } class Demographics(Page): form_model = 'player' form_fields = ['gender','ethnic','ethnic2','mumbirthplace','dadbirthplace','mumocc','dadocc','householdincome','age','percentMTurk','education','marital','income','occup','state'] class Belief(Page): form_model = 'player' form_fields = ['Belief_0'] def is_displayed(self): return self.participant.vars['passed_screening'] == 1 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'] == 1 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): 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'] == 1 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): 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'] == 1 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): 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'] == 1 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): 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'] == 1 class Feedback(Page): form_model = 'player' form_fields = ['feedback_part_1','feedback_part_2'] def is_displayed(self): return self.participant.vars['passed_screening'] == 1 page_sequence = [ BeliefElicitation, BeliefExample, ControlQuestions1, Belief, PerformanceFeedback, ControlQuestions2, BeliefSummary, Message1, Message2, Message3, Message4, BeliefDone, Demographics, Feedback, Results ]