from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'Setting' PLAYERS_PER_GROUP = None NUM_ROUNDS = 5 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): ConsistencyMarkov = models.IntegerField(choices=[[20, '20'], [40, '40'], [60, '60'], [80, '80']], label='What is the likelihood (in%) that a stock is in the good state in the next period given that stock is in the good state in this period?', widget=widgets.RadioSelect) ComprehensionCheck = models.BooleanField() ProbabilityUpdate = models.StringField(choices=[['I increase the probability estimate that the asset is in the good distribution', 'I increase the probability estimate that the asset is in the good state'], ['I reduce the probability estimate that the asset is in the good distribution', 'I decrease the probability estimate that the asset is in the good state']], label='You observe a -10, how do you have to update your probability estimate that the asset is in the good state?', widget=widgets.RadioSelect) StartingProbability = models.BooleanField(choices=[[True, 'True'], [False, 'False']], label='In period 0, the probability that the risky asset is in the good state is 50%.') Payment = models.FloatField(choices=[[0.55, '0.55'], [0.67, '0.67'], [0.75, '0.77'], [0.87, '0.83']], label="The correct probability estimate is let's say 0.70. Which probability estimate would be in the range such that you earn a bonus payment?", widget=widgets.RadioSelect) ProlificID = models.StringField(label='Please enter your Prolific ID so that we can match the payment.') def assign_treatment(player: Player): import random number=random.choice([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) return number class WelcomePage(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): #if player.round_number==1: # player.ComprehensionCheck=False #else: # prev_player=player.in_round(player.round_number-1) # player.ComprehensionCheck=prev_player.ComprehensionCheck return player.round_number==1 class ProlificID(Page): form_model = 'player' form_fields = ['ProlificID'] @staticmethod def is_displayed(player: Player): #if player.round_number==1: # player.ComprehensionCheck=False #else: # prev_player=player.in_round(player.round_number-1) # player.ComprehensionCheck=prev_player.ComprehensionCheck return player.round_number==1 class Revision(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==1: player.ComprehensionCheck=False else: prev_player=player.in_round(player.round_number-1) player.ComprehensionCheck=prev_player.ComprehensionCheck player.StartingProbability=prev_player.StartingProbability player.ConsistencyMarkov=prev_player.ConsistencyMarkov player.ProbabilityUpdate=prev_player.ProbabilityUpdate player.Payment=prev_player.Payment return player.ComprehensionCheck==False and player.round_number>1 class Instructions(Page): form_model = 'player' form_fields = ['ConsistencyMarkov', 'ProbabilityUpdate', 'StartingProbability', 'Payment'] @staticmethod def is_displayed(player: Player): if player.round_number==1: player.ComprehensionCheck=False else: prev_player=player.in_round(player.round_number-1) player.ComprehensionCheck=prev_player.ComprehensionCheck return player.ComprehensionCheck==False class CheckConfirmation(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): if player.round_number==1: player.ComprehensionCheck=False else: prev_player=player.in_round(player.round_number-1) player.ComprehensionCheck=prev_player.ComprehensionCheck if player.ComprehensionCheck==True: prev_player=player.in_round(player.round_number-1) player.StartingProbability=prev_player.StartingProbability player.ConsistencyMarkov=prev_player.ConsistencyMarkov player.ProbabilityUpdate=prev_player.ProbabilityUpdate player.Payment=prev_player.Payment else: if player.StartingProbability==True and player.ConsistencyMarkov==80 and player.ProbabilityUpdate=="I reduce the probability estimate that the asset is in the good distribution" and player.Payment==0.67: player.ComprehensionCheck=True return player.StartingProbability==True and player.ConsistencyMarkov==80 and player.ProbabilityUpdate=="I reduce the probability estimate that the asset is in the good distribution" and player.Payment==0.67 class EndSetting(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant participant.treatmentnumber=assign_treatment(player) return player.round_number==5 and player.ComprehensionCheck==False @staticmethod def app_after_this_page(player: Player, upcoming_apps): return upcoming_apps[2] page_sequence = [WelcomePage, ProlificID, Revision, Instructions, CheckConfirmation, EndSetting]