from otree.api import * from markupsafe import Markup c = Currency doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'consent' players_per_group = None num_rounds = 1 timer_text = 'Time left:' max_seconds_on_consent_page = 160 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): consent = models.BooleanField( label=Markup('I have read and understood the previous information
and ' 'consent to participate in the experiment:'), choices=[(True, 'YES'), (False, 'NO')], widget=widgets.RadioSelectHorizontal() ) #FUNCTIONS def creating_session(subsession: Subsession): for p in subsession.get_players(): participant = p.participant participant.dropout = False participant.unmatched = False participant.no_consent = False # PAGES class Consent(Page): timer_text = Constants.timer_text timeout_seconds = Constants.max_seconds_on_consent_page form_model = 'player' form_fields = ['consent'] @staticmethod def before_next_page(player: Player, timeout_happened): if timeout_happened: player.consent = False if player.consent is False: player.participant.no_consent = True @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.no_consent: return upcoming_apps[-1] page_sequence = [Consent]