from otree.api import * doc = """ Consent form """ class C(BaseConstants): NAME_IN_URL = 'consent' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 BLANK = False DEFINITIONS = '_templates/definitions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # Consent Form variables is_mobile = models.BooleanField() date = models.StringField(blank=C.BLANK, label="Consent date (YYYY/MM/DD):") name = models.StringField(blank=C.BLANK, label="Your full name:") email = models.StringField(blank=C.BLANK, label="""The email address with which you would like to receive the Interac e-transfer of any money you earn:""") i_consent = models.StringField(blank=C.BLANK, label="""If you wish to consent to participating in the experiment, please type 'I consent':""") def i_consent_error_message(player: Player, value): if value != 'I consent': return "Please type 'I consent'" # PAGES class Consent(Page): form_model = 'player' form_fields = ['is_mobile', 'date', 'name', 'email', 'i_consent'] @staticmethod def error_message(player: Player, values): if values['is_mobile']: return """Sorry, this experiment does not allow mobile browsers. Please open the experiment link on your personal computer.""" @staticmethod def before_next_page(player, timeout_happened): player.participant.name = player.name player.participant.email = player.email class Definitions(Page): pass page_sequence = [ Consent, Definitions ]