"""INTERFER v13: consent (participant-facing content preserved from v12).""" from otree.api import * from interfer_shared import Config import random import secrets import string import time import json class C(BaseConstants): NAME_IN_URL = 'consent' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 BASE_PAYMENT = Config.BASE_PAYMENT ESTIMATED_MINUTES = Config.ESTIMATED_MINUTES class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): consent_choice = models.StringField(choices=['yes', 'no']) consent_given = models.BooleanField(initial=False) consent_given_at = models.FloatField(initial=0) class WelcomeConsent(Page): form_model = 'player' form_fields = ['consent_choice'] @staticmethod def is_displayed(player): return player.round_number == 1 @staticmethod def before_next_page(player, timeout_happened): player.consent_given = (player.consent_choice == 'yes') if player.consent_given: player.consent_given_at = time.time() player.participant.vars['consent_given'] = player.consent_given class ConsentDeclined(Page): @staticmethod def is_displayed(player): return player.round_number == 1 and not player.consent_given page_sequence = [WelcomeConsent, ConsentDeclined]