import random from otree.api import * class C(BaseConstants): NAME_IN_URL = 'ukiyoe' PLAYERS_PER_GROUP = None IMAGES = [ 'arcBK01-0044_16.jpg', 'arcUP0159.jpg', 'arcUP0230.jpg', 'arcUP0232.jpg', 'arcUP0247.jpg', 'arcUP0278.jpg', 'arcUP0283.jpg', 'arcUP0284.jpg', 'arcUP0290.jpg', 'arcUP0307.jpg', 'arcUP0309.jpg', 'arcUP0501.jpg', 'arcUP1052.jpg', 'arcUP2149.jpg', 'arcUP2153.jpg', 'arcUP2452.jpg', 'arcUP3050.jpg', 'arcUP3168.jpg', 'arcUP3395.jpg', 'arcUP3955.jpg', 'arcUP4098(P).jpg', 'arcUP4129(F).jpg', 'arcUP4247.jpg', 'arcUP4249.jpg', 'arcUP4317.jpg', 'arcUP4461.jpg', 'arcUP4638.jpg', 'arcUP5383.jpg', 'arcUY0071.jpg', 'arcUY0077.jpg', 'arcUY0103.jpg', 'arcUY0152.jpg', 'arcUY0153.jpg', 'arcUY0155.jpg', 'arcUY0156.jpg', 'arcUY0157.jpg', 'arcUY0160.jpg', 'arcUY0165.jpg', 'arcUY0185.jpg', 'arcUY0202.jpg', 'arcUY0212.jpg', 'arcUY0224.jpg', 'arcUY0359.jpg', ] IMAGES_PER_PARTICIPANT = 20 NUM_ROUNDS = IMAGES_PER_PARTICIPANT class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): def make_field(label): return models.IntegerField( choices=[1, 2, 3, 4, 5], label=label, widget=widgets.RadioSelect, ) q1 = make_field('登場人物に対してどれほど躍動感を感じますか。') q2 = make_field('登場人物の体はどれほど捻じれていると思いますか。(捻じれとは、体を左右に回旋させることを指します。例:腰や上半身が正面から横方向にひねられている状態)') q3 = make_field('登場人物は、真顔に比べてどれほど表情(笑顔、怒り顔、泣き顔等)があると思いますか。') q4 = make_field('登場人物の服装はどれほど色豊かに描かれていると思いますか。') q5 = make_field('この画像の登場人物のまとっているもの(服装や装飾品)はどれほど揺れ動いていると思いますか。') consent = models.BooleanField() btn_next = models.BooleanField() def creating_session(subsession): if subsession.round_number == 1: for p in subsession.get_players(): images = random.sample(C.IMAGES, C.IMAGES_PER_PARTICIPANT) random.shuffle(images) p.participant.vars['image_order'] = images class Consent(Page): form_model = 'player' form_fields = ['consent'] def is_displayed(player): return player.round_number == 1 class MyPage(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'btn_next'] def vars_for_template(player): idx = player.round_number - 1 image = player.participant.vars['image_order'][idx] return { 'image': image, 'round_number': player.round_number, 'num_rounds': C.NUM_ROUNDS, } class Results(Page): def is_displayed(player): return player.round_number == C.NUM_ROUNDS page_sequence = [Consent, MyPage, Results]