from otree.api import * c = cu doc = 'Information and consent' class C(BaseConstants): NAME_IN_URL = 'P3_consent' 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) def custom_export(players): yield ['participant_code', 'id_in_group'] for p in players: pp = p.participant yield [pp.code, p.id_in_group] 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 page_sequence = [InformationForm, Consent]