from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'P3_instruction' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 FIRM_ROLE = 'manager' OFFICIAL_ROLE = 'official' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): consent = models.BooleanField(choices=[[True, 'Yes'], [False, 'No']], initial=True, label='I consent to participate in this study. ') compre_mgr1 = models.IntegerField(choices=[[40, '40'], [30, '30'], [20, '20'], [10, '10'], [0, '0']], label="Manager's payoff") compre_mgr2 = models.IntegerField(choices=[[40, '40'], [30, '30'], [20, '20'], [10, '10'], [0, '0']], label="Manager's payoff") compre_mgr3 = models.IntegerField(choices=[[40, '40'], [30, '30'], [20, '20'], [10, '10']], label="Manager's payoff") compre_3soc = models.IntegerField(choices=[[40, '40'], [30, '30'], [20, '20'], [10, '10'], [0, '0']], label="NGO's payoff") compre_mgr4 = models.StringField(choices=[['South & West offices', 'South & West offices'], ['West & East offices', 'West & East offices'], ['East & North offices', 'East & North offices'], ['North & South offices', 'North & South offices']], label='Your past offices') compre_mgr5 = models.IntegerField(choices=[[5, '5 years'], [10, '10 years'], [15, '15 years']], label='South Office assignment duration') compre_mgr6 = models.StringField(choices=[['Supervisor', 'Supervisor'], ['Division Manager', 'Division Manager'], ['Regional Manager', 'Regional Manager'], ['Manager of Accounting Service', 'Manager of Accounting Service']], label='Your current position') compre_ofc1 = models.IntegerField(choices=[[40, '40'], [30, '30'], [20, '20'], [10, '10'], [0, '0']], label="Official's extra benefit") compre_ofc2 = models.IntegerField(choices=[[40, '40'], [30, '30'], [20, '20'], [10, '10'], [0, '0']], label="Official's payoff") compre_ofc3 = models.IntegerField(choices=[[40, '40'], [30, '30'], [20, '20'], [10, '10']], label="Official's payoff") compre_ofc4 = models.StringField(choices=[['South & West offices', 'South & West offices'], ['West & East offices', 'West & East offices'], ['East & North offices', 'East & North offices'], ['North & South offices', 'North & South offices']], label='Your past offices') compre_ofc5 = models.IntegerField(choices=[[5, '5 years'], [10, '10 years'], [15, '15 years']], label='South Office assignment duration') compre_ofc6 = models.StringField(choices=[['Minister of Public Affairs', 'Minister of Public Affairs'], ['Directorate General of Regional Development', 'Directorate General of Regional Development'], ['Deputy Regional Development', 'Deputy Regional Development'], ['Head Official', 'Head Official']], label='Your current position') time_outs = models.IntegerField(initial=0) firm_1 = models.IntegerField(label='Percentage of participants in the role of MANAGERS who believe it is CORRECT to offer the transfer', max=100, min=0) firm_2 = models.IntegerField(label='Percentage of participants in the role of MANAGERS who believe it is INCORRECT to offer the transfer', max=100, min=0) ofc_1 = models.IntegerField(label='Percentage of participants in the role of OFFICIALS who believe it is CORRECT to ACCEPT the transfer', max=100, min=0) ofc_2 = models.IntegerField(label='Percentage of participants in the role of OFFICIALS who believe it is INCORRECT to ACCEPT the transfer', max=100, min=0) num_failed = models.IntegerField(initial=0) at1 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='1. A problem has little attraction for me if I do not think it has a solution.') at2 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='2. I am just a little uncomfortable with people unless I feel that I can understand their behavior.') at3 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='3. There is a right way and a wrong way to do almost everything.') at4 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='4. I would rather bet 1 to 6 on a long shot than 3 to 1 on a probable winner.') at5 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='5. The way to understand complex problems is to be concerned with their larger aspects instead of breaking them into smaller pieces.') at6 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='6. I get pretty anxious when I am in a social situation over which I have no control.') at7 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='7. Practically every problem has a solution.') at8 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='8. It bothers me when I am unable to follow another person’s train of thought.') at9 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='9. I have always felt that there is a clear difference between right and wrong.') at10 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='10. It bothers me when I do not know how other people react to me.') at11 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='11. Nothing gets accomplished in this world unless you stick to some basic rules.') at12 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='12. If I were a doctor, I would prefer the uncertainties of a psychiatrist to the clear and definite work of someone like a surgeon or X-ray specialist.') at13 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='13. Vague and impressionistic picture really have little appeal for me.') at14 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='14. If I were a scientist, it would bother me that my work would never be completed (because science will always make more discoveries).') at15 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='15. Before an examination, I feel much less anxious if I know how many questions there will be.') at16 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='16. The best part about working on a jigsaw puzzle is putting in the last piece.') at17 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='17. Sometimes I rather enjoy going against the rules and doing things I am not supposed to do. ') at18 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='18. I do not like to work on a problem unless there is a possibility of coming out with a clear-cut and unambiguous answer.') at19 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='19. I like to fool around with new ideas, even if they turn out later to be a total waste of time. ') at20 = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='20. Perfect balance is the essence of all good composition.') compre_worktime = models.IntegerField(choices=[[5, '5'], [10, '10'], [15, '15']], label='Work experience in years') class InformationForm(Page): form_model = 'player' class Consent(Page): form_model = 'player' form_fields = ['consent'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.consent=False @staticmethod def error_message(player: Player, values): solution = dict( consent=True ) error_messages = dict() for field_name in solution: if values [field_name] != solution[field_name]: error_messages[field_name] = 'You cannot proceed to the next page without giving your consent. Please exit this webpage if you do not want to participate.' return error_messages class GeneralInstruction(Page): form_model = 'player' class DetailedInstructionManager(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.role == C.FIRM_ROLE class Comprehension_manager(Page): form_model = 'player' form_fields = ['compre_mgr1', 'compre_mgr2', 'compre_3soc', 'compre_mgr6', 'compre_worktime'] @staticmethod def is_displayed(player: Player): return player.role == C.FIRM_ROLE @staticmethod def error_message(player: Player, values): solutions = dict( compre_mgr1=40, compre_mgr2=20, compre_3soc=0, compre_worktime=10, compre_mgr6= 'Division Manager' ) error_messages = dict() for field_name in solutions: if values [field_name] != solutions[field_name]: player.num_failed += 1 error_messages[field_name] = 'Wrong answer' return error_messages class DetailedInstructionOfficial(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.role == C.OFFICIAL_ROLE class Comprehension_official(Page): form_model = 'player' form_fields = ['compre_mgr1', 'compre_ofc2', 'compre_3soc', 'compre_worktime', 'compre_ofc6'] @staticmethod def is_displayed(player: Player): return player.role == C.OFFICIAL_ROLE @staticmethod def error_message(player: Player, values): solutions = dict( compre_mgr1=40, compre_ofc2=30, compre_3soc=0, compre_worktime=10, compre_ofc6= 'Head Official' ) error_messages = dict() for field_name in solutions: if values [field_name] != solutions[field_name]: player.num_failed += 1 error_messages[field_name] = 'Wrong answer' return error_messages class NormElicitation(Page): form_model = 'player' form_fields = ['firm_1', 'firm_2', 'ofc_1', 'ofc_2'] @staticmethod def error_message(player: Player, values): print ('values is', values) error_messages ="" if values ['firm_1'] + values ['firm_2'] != 100 or values ['ofc_1'] + values['ofc_2'] !=100: error_messages = 'The total percentage must sum to 100.' return error_messages class AmbiguityToleranceIndex(Page): form_model = 'player' form_fields = ['at1', 'at2', 'at3', 'at4', 'at5', 'at6', 'at7', 'at8', 'at9', 'at10', 'at11', 'at12', 'at13', 'at14', 'at15', 'at16', 'at17', 'at18', 'at19', 'at20'] page_sequence = [InformationForm, Consent, GeneralInstruction, DetailedInstructionManager, Comprehension_manager, DetailedInstructionOfficial, Comprehension_official, NormElicitation, AmbiguityToleranceIndex]