from otree.api import * import random import json doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 ## Frederick, S. (2005). ## "Cognitive reflection and decision making," ## Journal of Economic perspectives, 19(4), 25-42. materials_crt = { "field": models.IntegerField, "items": { "crt1": { "question": """ バット1本とボール1個の値段はあわせて1100円です。 バットがボールより1000円高いとき、ボールはいくらですか? """, "unit": "円", "correct": 5.0 }, "crt2": { "question": """ ある機械5台で5個の製品を生産すると5分かかります。 この機械100台で100個の製品を製造するには何分かかりますか? """, "unit": "秒", "correct": 5.0 }, "crt3": { "question": """ 池にハスの葉が浮かんでいます。ハスの葉は1日ごとに2倍に増えていきます。 ハスの葉が池全体を覆うまでに48日かかります。では、ハスの葉が湖の半分を覆うまでには何日かかりますか? """, "unit": "日", "correct": 47 } } } ## Yamagishi, T. & Yamagishi, M. (1994). ## "Trust and commitment in the United States and Japan," ## Motivation and Emotion, 18, 129-166. materials_gentrust = { "field": models.IntegerField, "opts": [ [1, "Strongly Disagree"], [2, "Disagree"], [3, "Neutral"], [4, "Agree"], [5, "Strongly Agree"] ], "items": { "gentrust1": "Most people are basically honest.", "gentrust2": "Most people are trustworthy.", "gentrust3": "Most people are basically good and kind.", "gentrust4": "Most people are trustful of others.", "gentrust5": "I am trustful.", "gentrust6": "Most people will respond in kind when they are trusted by others." } } class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): list_crt = [k for k in C.materials_crt["items"].keys()] for p in subsession.get_players(): p.order_crt = json.dumps( random.sample(list_crt, len(list_crt)) ) class Group(BaseGroup): pass class Player(BasePlayer): order_crt = models.LongStringField() for k, v in C.materials_crt["items"].items(): setattr( Player, k, C.materials_crt["field"]( label = v["question"], help_text = v["unit"] ) ) for k, v in C.materials_gentrust["items"].items(): setattr( Player, k, C.materials_gentrust["field"]( label = v, choices = C.materials_gentrust["opts"], widget = widgets.RadioSelectHorizontal ) ) # PAGES class CRT(Page): form_model = "player" form_fields = ["crt1", "crt2", "crt3"] @staticmethod def get_form_fields(player: Player): return json.loads(player.order_crt) class MyPage(Page): pass class ResultsWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [CRT]