from otree.api import * doc = """ Control_Instruction """ class Constants(BaseConstants): name_in_url = 'In_C' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): num_failed_attempts = models.IntegerField(initial=0) task = models.IntegerField( blank=False, choices=[[1, 'Find the best investment option'], [2, 'Make exit decisions'], [3, 'Show that I understand statistics']], label='1. What is your task in this experiment?', widget=widgets.RadioSelect, ) cost = models.IntegerField( blank=False, choices=[[1, '-$5'], [2, '-$2.5'], [3, '$0']], label='2. If you earn $10 in Round 1, 0 in Round 2, -$5 in Round 3, and decide to exit in Round 4, ' 'what is your terminal value after deducting the exit cost of $10?', widget=widgets.RadioSelect, ) income = models.IntegerField( blank=False, choices=[[1, '$52.5'], [2, '$55'], [3, '$57.5']], label=''' 3. Assume that the realized income after Round 2 $60. Suppose it is expected to increase by $20 with a probability of 50% or decrease by 25 with a probability of 50% in Round 3. What will be the expected income after Round 3?''', widget=widgets.RadioSelect, ) # PAGES class MainGame_intro(Page): pass class COMP(Page): form_model = 'player' form_fields = ['task', 'cost', 'income'] @staticmethod def error_message(player, values): solutions = dict( task=2, cost=1, income=3 ) error_messages = dict( task='In this experiment, you will make exit decisions for a for-profit enterprise.', cost='If you earn a total of $5 before exiting, and the exit cost is $10, then your terminal value is $5-$10 = -$5.', income='Expected income in Round 3 = 0.5($20) +0.5(-$25) = -$2.5', ) errors = {name: error_messages[name] for name in solutions if values[name] != solutions[name]} if errors: player.num_failed_attempts += 1 return errors # @staticmethod # def error_message(player: Player, values): # solutions = dict(task=2, cost=10, income=3) # if values != solutions: # return "One or more answers were incorrect." class G_intro(Page): pass page_sequence = [MainGame_intro, COMP, G_intro]