from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'puzzle' players_per_group = None num_rounds = 1 pictures = {'dexter': 'motivated_choice/dexter.png', 'deedee': 'motivated_choice/deedee.png', 'mandark': 'motivated_choice/mandark.jpg' } questions = { 'q1': { 'text': 'A gardener charges a $60 call-out fee and then $30 for each hour he spends on the job. ' 'How long did he work on the job if the total bill is $180?', 'choices': ['3 hours', '4 hours', '4.5 hours', '6 hours'], 'solution': '4 hours', 'table': 'no' }, 'q2': { 'text': 'Suppose you had $100 in a savings account and the interest rate was 2% per year. ' 'After 5 years, how much do you think you would have in the account if you left the money to grow?', 'choices': ['More than $102', 'Exactly $102', 'Less than $102'], 'solution': 'More than $102', 'table': 'no' }, 'q3': { 'text': 'Imagine that the interest rate on your savings account was 1% per year ' 'and inflation was 2% per year. ' 'After 1 year, how much would you be able to buy with the money in this account?', 'choices': ['More than today', 'Exactly the same', 'Less than today'], 'solution': 'Less than today', 'table': 'no' }, } class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.puzzle_solution = [p.participant.vars['industries'][i]['name'] for i in self.session.vars['industries']['labels'] if p.participant.vars['industries'][i]['type'] == 'Ind_good'][0] class Group(BaseGroup): pass class Player(BasePlayer): puzzle_1 = models.StringField( choices=Constants.questions['q1']['choices'], widget=widgets.RadioSelect ) puzzle_2 = models.StringField( choices=Constants.questions['q2']['choices'], widget=widgets.RadioSelect ) puzzle_3 = models.StringField( choices=Constants.questions['q3']['choices'], widget=widgets.RadioSelect ) puzzle_solution = models.StringField() puzzle_confidence = models.IntegerField( min=0, max=100, # widget=widgets.Slider(attrs={'step': '1'}) ) # def puzzle_solution_choices(self): # choices = [self.participant.vars['industries']['Industry_1']['name'], # self.participant.vars['industries']['Industry_2']['name'] # ] # return choices