from otree.api import * from settings import PARTICIPANT_FIELDS, SESSION_CONFIG_DEFAULTS 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 = SESSION_CONFIG_DEFAULTS['time_limit'] class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): ## Session indices day = models.IntegerField() app_sequence = models.IntegerField() inf_sequence = models.IntegerField() intervention = models.IntegerField() # for perceived inflation measures (inflation estimation and price memory) inflationEstimation = models.FloatField() priceMemory_1 = models.CurrencyField( label='What was the price in Period 1?', min=0, max=1000 ) priceMemory_2 = models.CurrencyField( label='What was the price in Period 30?', min=0, max=1000 ) priceMemory_3 = models.CurrencyField( label='What was the price in Period 60?', min=0, max=1000 ) priceMemory_4 = models.CurrencyField( label='What was the price in Period 90?', min=0, max=1000 ) priceMemory_5 = models.CurrencyField( label='What was the price in Period 120?', min=0, max=1000 ) # PAGES class Inflation_estimate(Page): form_model = 'player' form_fields = ['inflationEstimation'] 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'] class Results(Page): pass page_sequence = [Inflation_estimate, Price_memory, Results]