from otree.api import * doc = """ Introduction and consent """ class C(BaseConstants): NAME_IN_URL = 'Introduction' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): missing_partner = models.BooleanField(blank=False) class Player(BasePlayer): melessa_id = models.StringField( label = "Before your start the experiment, please indicate your unique Melessa ID:" ) consent = models.BooleanField( widget=widgets.CheckboxInput(), blank=True, ) no_consent = models.BooleanField( widget=widgets.CheckboxInput(), blank=True, ) repeat_consent = models.BooleanField( widget=widgets.CheckboxInput(), blank=True, ) repeat_no_consent = models.BooleanField( widget=widgets.CheckboxInput(), blank=True, initial=False, ) task_understood = models.BooleanField( widget=widgets.CheckboxInput(), blank=True, ) number_K_test = models.IntegerField(min=0, max=100, label='Number of letters "K" clicked in the grid.') number_IK_test = models.IntegerField(min=0, max=100, label='Number of letters "I" clicked in the grid.') sum_K_test = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "K" clicked in the grid.') sum_IK_test = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') correct_K_test = models.IntegerField(initial=0, min=0, max=100, label='Sum of correct "K" in the grid.') correct_IK_test = models.IntegerField(initial=0, min=0, max=100, label='Sum of letters "IK" clicked in the grid.') # PAGES class MelessaID(Page): form_model = 'player' form_fields = ['melessa_id'] class ConsentPage(Page): form_model = 'player' form_fields = ['consent', 'no_consent'] def error_message(player, values): if values['consent'] == 0 and values['no_consent'] == 0: return 'Unfortunately, you cannot participate in this experiment without your consent.' if values['consent'] == 1 and values['no_consent'] == 1: return 'Please select one of the options.' elif values['consent'] == None and values['no_consent'] == None: return 'Please select one of the options.' class YouSure(Page): form_model = 'player' form_fields = ['repeat_consent', 'repeat_no_consent'] def before_next_page(player, timeout_happened): if player.repeat_no_consent == True: participant = player.participant participant.receive_1 = 0 participant.receive_2 = 0 participant.total_earnings_1 = 0 def is_displayed(player): return player.no_consent == True def app_after_this_page(player, upcoming_apps): if player.repeat_no_consent == True: return upcoming_apps[-1] def error_message(player, values): if values['repeat_consent'] == 0 and values['repeat_no_consent'] == 0: return 'Unfortunately, you cannot participate in this experiment without your consent.' if values['repeat_consent'] == 1 and values['repeat_no_consent'] == 1: return 'Please select one of the options.' elif values['repeat_consent'] == None and values['repeat_no_consent'] == None: return 'Please select one of the options.' class Wait_1(WaitPage): form_model = 'player' @staticmethod def partner_is_missing(group): players = group.get_players() missings = [p.repeat_no_consent for p in players] if sum(missings) == 0: group.missing_partner = False; else: group.missing_partner = True; for player in players: participant = player.participant participant.no_partner = group.missing_partner participant.team_continues = False; after_all_players_arrive = partner_is_missing class IntroTask(Page): form_model = 'player' form_fields = ['task_understood'] def error_message(player, values): if values['task_understood'] == 0 or values['task_understood'] == None: return 'You have to understand the task in order to continue with the experiment. Please read the instructions again.' class TaskTest(Page): form_model = 'player' form_fields = ['number_K_test', 'number_IK_test'] @staticmethod def live_method(player, data): player.sum_K_test = int(data['value_K']); player.sum_IK_test = int(data['value_IK']); player.correct_K_test = int(data['correct_K']); player.correct_IK_test = int(data['correct_IK']); page_sequence = [MelessaID, ConsentPage, YouSure, Wait_1, IntroTask, TaskTest]