from otree.api import * class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField(label='What is your age?', min=13, max=125) gender = models.StringField( choices=[['Male', 'Male'], ['Female', 'Female'], ['Other', 'Other'], ['Prefer not to answer', 'Prefer not to answer']], label='What is your gender?', widget=widgets.RadioSelect, ) musiclisten = models.BooleanField() condition = models.StringField t1_1 = models.StringField( choices=[[0, 'a.3'], [0, 'b.7'], [0, 'c.24'], [1, 'd.5'], [0, 'I do not know']], label='What number best completes the analogy: 8:4 as 10:[?]', widget=widgets.RadioSelect, ) t1_2 = models.StringField( choices=[[0, 'a.8'], [1, 'b.10'], [0, 'c.11'], [0, 'd.13'], [0, 'I do not know']], label='Which number logically follows this series? 7 9 5 11; 4 15 12 7; 13 8 11 [?]', widget=widgets.RadioSelect, ) t1_3 = models.StringField( choices=[[0, 'a.20'], [1, 'b.26'], [0, 'c.28'], [0, 'd.30'], [0, 'I do not know']], label='Which number is missing? 8 10 14 18 [?] 34 50 66', widget=widgets.RadioSelect, ) t1_4 = models.StringField( choices=[[0, 'a.That is impossible '], [0, 'b.20'], [1, 'c.24'], [0, 'd.28'], [0, 'I do not know']], label = 'Mary is 16 years old. She is 4 times older than her brother. How old will Mary be when she is twice his age?', widget = widgets.RadioSelect, ) t1_5 = models.StringField( choices=[[1, 'a.25'], [0, 'b.27'], [0, 'c.30'], [0, 'd.35'], [0, 'I do not know']], label='The store reduces the price of one product by 20 percent. How many percent do you need to raise to the percentage to get the original price?', widget=widgets.RadioSelect, ) t1_6 = models.StringField( choices=[[1, 'a.5'], [0, 'b.10'], [0, 'c.15'], [0, 'd.30'], [0, 'I do not know']], label='There are 5 machines that make 5 parts in 5 minutes. How long does it take to make 100 parts on 100 machines?', widget=widgets.RadioSelect, ) t1_7 = models.StringField( choices=[[0, 'a.4'], [1, 'b.6'], [0, 'c.8'], [0, 'd.10'], [0, 'I do not know']], label='Which number logically follows this series? 2 5 7; 4 7 5; 3 6 [?]', widget=widgets.RadioSelect, ) t2_1 = models.StringField( choices=[[0, 'a.4'], [0, 'b.3'], [1, 'c.6'], [0, 'd.24'], [0, 'I do not know']], label='What number best completes the analogy: 6:3 as 12:[?]', widget=widgets.RadioSelect, ) t2_2 = models.StringField( choices=[[0, 'a.8'], [0, 'b.12'], [1, 'c.14'], [0, 'd.16'], [0, 'I do not know']], label='Which number logically follows this series? 2; 5; 8; 11; [?]', widget=widgets.RadioSelect, ) t2_3 = models.StringField( choices=[[1, 'a.4'], [0, 'b.5'], [0, 'c.11'], [0, 'd.29'], [0, 'I do not know']], label='Which number is missing? 7 9 8 6 10 9 5 11 10 [?] 12', widget=widgets.RadioSelect, ) t2_4 = models.StringField( choices=[[0, 'a.30 mph'], [0, 'b.40 mph'], [0, 'c.60 mph'], [1, 'd.48 mph'], [0, 'I do not know']], label='A car travels at a speed of 40 mph over a certain distance and then returns over the same distance at a speed of 60 mph. What is the average speed for the total journey?', widget=widgets.RadioSelect, ) t2_5 = models.StringField( choices=[[0, 'a.1'], [0, 'b.3'], [1, 'c.15'], [0, 'd.5'], [0, 'I do not know']], label='You have accidentally left the plug out of the bath and are attempting to fill the bath with both taps full on. The hot tap takes three minutes to fill the bath and the cold tap two minutes, and the water empties through the plughole in six minutes. In how many minutes will the bath be filled?', widget=widgets.RadioSelect, ) t2_6 = models.StringField( choices=[[1, 'a.47'], [0, 'b.46'], [0, 'c.96'], [0, 'd.108'], [0, 'I do not know']], label='There is a lake on the surface of which water lilies float. The number of lilies doubles daily. If it takes 48 days to completely occupy the entire area of the lake, how many days will it take to occupy the floor of the lake?', widget=widgets.RadioSelect, ) t2_7 = models.StringField( choices=[[1, 'a.225'], [0, 'b.230'], [0, 'c.275'], [0, 'd.221'], [0, 'I do not know']], label='Which number logically follows this series? 2; 5; 8; 11; [?]', widget=widgets.RadioSelect, ) finish = models.StringField( choices=[[1, 'Finish the experiment']], widget=widgets.RadioSelect, ) musicsearch = models.StringField( label='''Please type your favorite song. Example: queen under pressure''' ) iamready1 = models.StringField( choices=[['I am ready', 'I am ready']], label='DEAR EVERYONE! IMAGINE THAT THERE IS AN AUTOMATICALLY GENERATED YOUTUBE LINK HERE ' '' 'Press I am ready when you listened to your favorite song', widget=widgets.RadioSelect, ) iamready2 = models.StringField( choices=[['I am ready', 'I am ready']], label='Now please do nothing for 3 minutes before the next (last) part of the test. Thank you very much for participation! After 3 minutes of doing nothing please press I am ready and continue', widget=widgets.RadioSelect, ) # FUNCTIONS '''' def creating_session(subsession): import random for player in subsession.get_players(): player.musiclisten = random.choice([True, False]) print('You have to listen to music', player.musiclisten) def creating_session(subsession): for player in subsession.get_players(): player.condition = None class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender'] def before_next_page(player: Player, timeout_happened): condlist = [player.condition for player in player.subsession.get_players() if player.condition != None] condlength = len(condlist) - 1 if condlength < 0: condlength = 0 condlist.append(False) lastcond = condlist[condlength] else: lastcond = condlist[condlength] if lastcond == 0: player.condition = 1 else: player.condition = 0 ''''' # FUNCTIONS def creating_session(subsession): import itertools clist = itertools.cycle([0, 1]) for player in subsession.get_players(): player.musiclisten = next(clist) # PAGES class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender'] class Test_1part(Page): form_model = 'player' form_fields = ['t1_1', 't1_2', 't1_3', 't1_4', 't1_5', 't1_6', 't1_7'] class Test_2part(Page): form_model = 'player' form_fields = ['t2_1', 't2_2', 't2_3', 't2_4', 't2_5', 't2_6', 't2_7'] class Music_or_not(Page): timeout_seconds = 240 form_model = 'player' def get_form_fields(player): if player.musiclisten == True: return ['musicsearch', 'iamready1'] else: return ['iamready2'] class Thankyou(Page): form_model = 'player' # form_fields = ['finish'] page_sequence = [Demographics, Test_1part, Music_or_not, Test_2part, Thankyou] # Demographics, Test_1part, Music_or_not, Test_2part, ThankYou