from otree.api import * doc = """ Images in radio button choices """ def make_image_data(image_names): return [dict(name=name, path='global/{}'.format(name)) for name in image_names] class Constants(BaseConstants): name_in_url = 'choice_images' players_per_group = None num_rounds = 1 # change to 61 in the real game class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): img_choice = models.StringField() # PAGES class MyPage(Page): form_model = 'player' form_fields = ['img_choice'] @staticmethod def vars_for_template(player: Player): image_names = [ 'A1.png', 'A2.png', ] return dict(image_data=make_image_data(image_names)) class Result(Page): pass page_sequence = [MyPage, Result]