from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from random import shuffle doc = '' class Constants(BaseConstants): name_in_url = 'Price_lisitings' players_per_group = 4 # num_rounds = 1 tasks = ['5108734', '27688407'] num_rounds = len(tasks) class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for p in self.get_players(): round_numbers = list(range(1, Constants.num_rounds+1)) shuffle(round_numbers) p.participant.vars['task_rounds'] = dict(zip(Constants.tasks, round_numbers)) class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField(label='Enter your age:', max=85, min=18) gender = models.StringField(label="Enter your gender:", choices=("Male", "Female", "Other")) isRented = models.StringField(label="Have you rented an apartment in Airbnb?", choices=("Yes", "No")) mturkID = models.StringField(label="MTurk ID:", blank=True) price_5108734_F1 = models.IntegerField(label='Enter your price here in US dollars (digits only):', max=200, min=60) price_5108734_F2 = models.IntegerField(label='Enter your price here in US dollars (digits only):', max=200, min=60) price_5108734_M1 = models.IntegerField(label='Enter your price here in US dollars (digits only):', max=200, min=60) price_5108734_M2 = models.IntegerField(label='Enter your price here in US dollars (digits only):', max=200, min=60) price_27688407_F1 = models.IntegerField(label='Enter your price here in US dollars (digits only):', max=140, min=30) price_27688407_F2 = models.IntegerField(label='Enter your price here in US dollars (digits only):', max=140, min=30) price_27688407_M1 = models.IntegerField(label='Enter your price here in US dollars (digits only):', max=140, min=30) price_27688407_M2 = models.IntegerField(label='Enter your price here in US dollars (digits only):', max=140, min=30) def role(self): return {1: 'F1', 2: 'F2', 3: 'M1', 4: 'M2'}[self.id_in_group]