from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'my_survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 18 LEFT = ('198円のプリン', '200円のアイス', '一貫250円の寿司', '13000円のグリーン車', '100g250円のオーストラリア産の牛肉', '1500円の温泉', '200円のチョコ', '1リットル350円の牛乳', '250円のコーヒー', '18000円のグランクラス', '1リットル500円の牛乳', '500円のコーヒー', '500円のチョコ', '3000円の温泉', '100g350円の国産牛肉', '一貫500円の寿司', '300円のアイス', '298円のプリン') RIGHT = ('98円のプリン', '100円のアイス', '一貫100円の寿司', '6000円の普通車', '100g150円のアメリカ産の牛肉', '800円の温泉', '50円のチョコ', '1リットル200円の牛乳', '100円のコーヒー', '13000円のグリーン車', '1リットル200円の牛乳', '250円のコーヒー', '200円のチョコ', '1500円の温泉', '100g250円のオーストラリア産の牛肉', '一貫250円の寿司', '200円のアイス', '198円のプリン') class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): session = subsession.session for p in subsession.get_players(): p.left_choice=C.LEFT[subsession.round_number-1] p.right_choice=C.RIGHT[subsession.round_number-1] class Group(BaseGroup): pass class Player(BasePlayer): Q = models.IntegerField(choices=[[1, '左'], [2, '右']],label='どちらを購入しますか') left_choice = models.StringField() right_choice = models.StringField() class Firstpage(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number==1 class MyPage(Page): form_model = 'player' form_fields = ['Q'] @staticmethod def vars_for_template(player): return dict( image_path_left='my_survey/Left/{}.JPG'.format(player.round_number), image_path_right='my_survey/Right/{}.JPG'.format(player.round_number) ) class Lastpage(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number==C.NUM_ROUNDS page_sequence = [Firstpage, MyPage, Lastpage]