from otree.api import * doc = """ Consent forms, if the participants refuse to take part in, then exit. """ class C(BaseConstants): NAME_IN_URL = 'consent_forms' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): consent_no = models.IntegerField(initial = 0) pass class Group(BaseGroup): pass class Player(BasePlayer): is_agree = models.BooleanField(initial=False) year_of_birth = models.IntegerField(min=1950, max=2023) gender = models.IntegerField( choices=[ [1, 'Male'], [2, 'Female'], [3, 'None of Above'] ] ) class ConsentForm(Page): form_model = 'player' form_fields = ['is_agree'] @staticmethod def before_next_page(player,timeout_happened): if player.is_agree: player.subsession.consent_no += 1 class RefusePage(Page): @staticmethod def is_displayed(player: Player): return (not player.is_agree) class Demographics(Page): form_model = 'player' form_fields = ['year_of_birth','gender'] class InstructionsText(Page): pass class InstructionsGraphics(Page): @staticmethod def before_next_page(player,timeout_happened): import time player.participant.arrival_at_waiting = time.time() page_sequence = [ConsentForm, RefusePage, Demographics, InstructionsText, InstructionsGraphics]