from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'David Lucius' doc = """ created by: David Lucius (david.lucius@posteo.de) """ class Constants(BaseConstants): name_in_url = 'SOCIAL_PREFERENCES' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # Screen: FirstStep i = None n = None # Loop: From 1 to 21 for i in range(1, 22): # Add: Variables for every step to data base (not nice, but it works) n = '0' + str(i) if i <= 9 else str(i) locals()[f'SP_1ST_STEP_{n}'] = models.BooleanField( label='', choices=[ [True, ''], [False, ''] ], widget=widgets.RadioSelectHorizontal ) # Delete: Auxiliary variables to prevent oTree error del i, n # Screen: SecondStep i = None n = None # Loop: From 1 to 21 for i in range(1, 22): # Add: Variables for every step to data base (not nice, but it works) n = '0' + str(i) if i <= 9 else str(i) locals()[f'SP_2ND_STEP_{n}'] = models.StringField( label='', choices=[ ['l', ''], ['r', ''] ], widget=widgets.RadioSelectHorizontal ) # Delete: Auxiliary variables to prevent oTree error del i, n