from otree.api import * import random doc = """ This app creates a survey containing the questions for the end of the experiment. """ class Constants(BaseConstants): name_in_url = 'consent_lottery' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): prolific_ID = models.StringField(label="Please insert your prolific ID") # vars for attention check: # att_check = models.BooleanField(initial=True) check1 = models.IntegerField( label='How many parts does this study have? ', choices=list(range(1, 7)) ) check2 = models.IntegerField( label='How many rounds does the second part of the study have ', choices=list(range(1, 7)) ) check3 = models.FloatField( label='How much will you get in dollar for each point earned in the first part?', choices=[0.01, 0.02, 0.03, 0.04, 0.05, 0.06] ) # PAGES class consent(Page): pass class prolific_id(Page): form_model = 'player' form_fields = ['prolific_ID'] class introduction(Page): form_model = 'player' def get_form_fields(player): forms = ['check1', 'check2', 'check3'] random.shuffle(forms) return forms def error_message(player, values): solutions = dict( check1=2, check2=6, check3=0.01 ) error_message = dict() for field_name in solutions: if values[field_name] != solutions[field_name]: error_message[field_name] = 'Answer is incorrect!' return error_message page_sequence = [consent, prolific_id, introduction]