from otree.api import * from common_modules import functions class Constants(BaseConstants): name_in_url = 'crt_en' players_per_group = None num_rounds = 1 def creating_session(subsession): # Initializing parameters in subsessions: if subsession.round_number == 1: # Initializing or updating "message" of each participant for player in subsession.get_players(): # We must check that message is a key in participant.vars functions.initialize_var_as_dict(player.participant.vars, 'message', 'crt') class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): crt_bat = models.IntegerField( label=''' A bat and a baseball cost 22 euro in total. The bat costs 20 euro more than the ball. What is the cost of the ball?''', blank = True ) crt_widget = models.IntegerField( label=''' If 5 people need 5 minutes to produce 5 bottles, How long would it take 100 people to produce 100 bottles? ''', blank = True ) crt_lake = models.IntegerField( label=''' Imagine a lake with water lilies. Each day the water lily formation doubles in size. If the lake is completely filled with water lilies in 48 days, how long did it take the water lilies to cover half the surface of the lake? ''', blank = True ) def custom_export(players): # header row yield ['session', 'participant_code', 'id_in_group', 'crt1', 'crt2', 'crt3'] for p in players: participant = p.participant session = p.session yield [session.code, participant.code, p.id_in_group, p.crt_bat, p.crt_widget, p.crt_lake] # FUNCTIONS # PAGES class CognitiveReflectionTest(Page): form_model = 'player' form_fields = ['crt_bat', 'crt_widget', 'crt_lake'] @staticmethod def error_message(player, values): player.participant.message['crt']['answers'] = values @staticmethod def get_timeout_seconds(player): return player.session.config['crt_timeout'] page_sequence = [CognitiveReflectionTest]