from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Huanren' doc = """ Multiple Price List risk preferences elicitation """ class Constants(BaseConstants): name_in_url = 'mpl' players_per_group = None num_rounds = 1 num_choices = 10 # Define the probabilities and payoffs for each option probabilities = [(i + 1) / 10 for i in range(num_choices)] option_a_payoffs = [(40, 40) for i in range(num_choices)] option_b_payoffs = [(60, 0) for i in range(num_choices)] class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def make_q(label=''): return models.StringField(label=label, choices=['A', 'B'], initial='',widget=widgets.RadioSelect) class Player(BasePlayer): # generate 10 fields with a loop for i in range(Constants.num_choices): locals()[f'choice_{i+1}'] = make_q() del i # clean up selected_row = models.IntegerField()