from otree.api import * from session_utils import merge_t, texts_for doc = """ Consent form and General Instructions. """ class C(BaseConstants): NAME_IN_URL = 'consent' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass def creating_session(subsession): if subsession.round_number == 1: lang = subsession.session.config.get('language', 'en') for p in subsession.get_players(): p.participant.vars['language'] = lang p.participant.session_language = lang class Group(BaseGroup): pass class Player(BasePlayer): consent_given = models.BooleanField( label="", widget=widgets.CheckboxInput, initial=False, ) class ConsentPage(Page): form_model = 'player' form_fields = ['consent_given'] @staticmethod def vars_for_template(player): return merge_t(player) @staticmethod def error_message(player, values): if not values['consent_given']: return texts_for(player)['consent_error'] class GeneralInstructions(Page): @staticmethod def vars_for_template(player): return merge_t(player) page_sequence = [ConsentPage, GeneralInstructions]