from otree.api import * from settings import PARTICIPANT_FIELDS author = "Nathaniel Archer Lawrence, LEMMA, Université Panthéon-Assas - Paris II" doc = """ Consumption simulation with interface based off of 'Shopping app (online grocery store)' from oTree demos, see: . """ class C(BaseConstants): NAME_IN_URL = 'questions' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 TIME_LIMIT = 3 # define subperiods for price memory questions # CONSTANT_2 = .25 # CONSTANT_3 = .5 # CONSTANT_4 = .75 # CONSTANT_5 = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # for perceived inflation measures (inflation estimation and price memory) inflationEstimation = models.FloatField( # choices=[1 + i for i in range(-200, 200)], # Generate choices within predefined range # label='', #Over the course of the {} periods, by what percentage (%) would you estimate the price of the Basket of Goods changed? (In other words, what do you estimate was the overall inflation rate?'.format(player.participant.periods_survived), # min=-200, # max=200, # widget=widgets.RadioSelect ) priceMemory_1 = models.CurrencyField( label='What price did you pay in Period 1?', min=0, max=1000 ) priceMemory_2 = models.CurrencyField( label='What price did you pay in Period 30?', min=0, max=1000 ) priceMemory_3 = models.CurrencyField( label='What price did you pay in Period 60?', min=0, max=1000 ) priceMemory_4 = models.CurrencyField( label='What price did you pay in Period 90?', min=0, max=1000 ) priceMemory_5 = models.CurrencyField( label='What price did you pay in Period 120?', min=0, max=1000 ) # PAGES class Inflation_estimate(Page): form_model = 'player' form_fields = ['inflationEstimation'] # timeout_seconds = C.TIME_LIMIT class Price_memory(Page): form_model = 'player' @staticmethod def get_form_fields(player): if player.participant.periods_survived >= 120: return ['priceMemory_1','priceMemory_2','priceMemory_3','priceMemory_4','priceMemory_5'] elif player.participant.periods_survived >= 90: return ['priceMemory_1','priceMemory_2','priceMemory_3','priceMemory_4'] elif player.participant.periods_survived >= 60: return ['priceMemory_1','priceMemory_2','priceMemory_3',] elif player.participant.periods_survived >= 30: return ['priceMemory_1','priceMemory_2'] else: return ['priceMemory_1'] print(player.inflationEstimate) # class Price_memory_1(Page): # form_model = 'player' # form_fields = ['priceMemory_1'] # @staticmethod # def is_displayed(player: Player): # return player.participant.periods_survived > 0 # class Price_memory_2(Page): # form_model = 'player' # form_fields = ['priceMemory_2'] # @staticmethod # def is_displayed(player: Player): # return player.participant.periods_survived >= 30 # class Price_memory_3(Page): # form_model = 'player' # form_fields = ['priceMemory_3'] # @staticmethod # def is_displayed(player: Player): # return player.participant.periods_survived >= 60 # class Price_memory_4(Page): # form_model = 'player' # form_fields = ['priceMemory_4'] # @staticmethod # def is_displayed(player: Player): # return player.participant.periods_survived > 90 # class Price_memory_5(Page): # form_model = 'player' # form_fields = ['priceMemory_5'] # @staticmethod # def is_displayed(player: Player): # return player.participant.periods_survived > 120 class Results(Page): pass page_sequence = [Inflation_estimate, Price_memory]