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): crt_bat = models.IntegerField( label=''' In each round, you are matched with _______ to play a pricing game''', choices=[ [1, 'A random set of two other participants'], [2, 'The same two participants'], [3, 'A random set of three other participants'], [4, 'All other participants in the experiment'], ], widget=widgets.RadioSelect ) crt_type1 = models.IntegerField( label=''' Which statement correctly describes type-1 buyers? ''', choices=[ [1, 'They compare your price with all other firms and buy from the cheapest.'], [2, 'They compare your price with one other firm and buy from the cheaper one.'], [3, 'They buy from you only if your price is below your cost.'], [4, 'They buy from you regardless of your competitors\' prices.'], ], widget=widgets.RadioSelect ) crt_widget = models.IntegerField( label=''' Which statement correctly describes type-2 buyers? ''', choices=[ [1, 'They always buy from you.'], [2, 'They compare prices across all firms and purchase from the lowest-priced firm.'], [3, "They compare your price with one other firm's price and buy from the lower-priced firm."], [4, 'They buy one unit from every firm.'], ], widget=widgets.RadioSelect ) crt_type3 = models.IntegerField( label=''' Which statement correctly describes type-3 buyers? ''', choices=[ [1, 'They always buy from you regardless of other firms\' prices.'], [2, 'They compare your price with the prices of two other firms and buy from the lowest-priced firm.'], [3, 'They compare your price with one other firm and buy from the lower-priced firm.'], [4, 'They split purchases equally among all firms in the market.'], ], widget=widgets.RadioSelect ) crt_lake = models.IntegerField( label=''' If two firms set the same lowest price, type-2 and type-3 buyers: ''', choices=[ [1, 'Do not purchase anything.'], [2, 'Buy all units from the firm listed first.'], [3, 'Split their purchases evenly between the tied firms.'], [4, 'Randomly choose one firm and buy all units from that firm.'], ], widget=widgets.RadioSelect ) crt_price_range = models.IntegerField( label=''' What is the valid range of prices you can set in each round? ''', choices=[ [1, 'Any whole number between 50 and 100'], [2, 'Any whole number between 0 and 100'], [3, 'Any whole number between 50 and 70'], [4, 'Any whole number between 1 and 50'], ], widget=widgets.RadioSelect ) crt_earnings = models.IntegerField( label=''' How are your point earnings in each round calculated? ''', choices=[ [1, 'Your price × units sold'], [2, '(Your price − your cost) × units sold'], [3, 'Your cost × units sold'], [4, '(Your price + your cost) × units sold'], ], widget=widgets.RadioSelect ) crt_private = models.IntegerField( label=''' Which information below is private? ''', choices=[ [1, 'Your production cost'], [2, 'The number of rounds in the session'], [3, 'The prices set by other firms after each round'], [4, 'The number of buyers of each type in the round'], ], widget=widgets.RadioSelect ) # FUNCTIONS # PAGES class KnowledgeTest(Page): form_model = 'player' form_fields = ['crt_bat', 'crt_type1', 'crt_widget', 'crt_type3', 'crt_lake', 'crt_price_range', 'crt_earnings', 'crt_private'] @staticmethod def error_message(player, values): solutions = dict( crt_bat=1, crt_type1=4, crt_widget=3, crt_type3=2, crt_lake=3, crt_price_range=1, crt_earnings=2, crt_private=1, ) errors = dict() if values['crt_bat'] != solutions['crt_bat']: errors['crt_bat'] = "The correct answer is: A random set of two other participants." if values['crt_type1'] != solutions['crt_type1']: errors['crt_type1'] = "The correct answer is: They buy from you regardless of your competitors' prices." if values['crt_widget'] != solutions['crt_widget']: errors['crt_widget'] = "The correct answer is: They compare your price with one other firm's price and buy from the lower-priced firm." if values['crt_type3'] != solutions['crt_type3']: errors['crt_type3'] = "The correct answer is: They compare your price with the prices of two other firms and buy from the lowest-priced firm." if values['crt_lake'] != solutions['crt_lake']: errors['crt_lake'] = "The correct answer is: Split their purchases evenly between the tied firms." if values['crt_price_range'] != solutions['crt_price_range']: errors['crt_price_range'] = "The correct answer is: Any whole number between 50 and 100." if values['crt_earnings'] != solutions['crt_earnings']: errors['crt_earnings'] = "The correct answer is: (Your price − your cost) × units sold." if values['crt_private'] != solutions['crt_private']: errors['crt_private'] = "The correct answer is: Your production cost." return errors page_sequence = [KnowledgeTest]