from otree.api import * import math doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'Chikyu' PLAYERS_PER_GROUP = None NUM_ROUNDS = 3 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): ellipse_area = models.FloatField() ellipse_center_x = models.FloatField(blank=True) ellipse_center_y = models.FloatField(blank=True) ellipse_width = models.FloatField(blank=True) ellipse_height = models.FloatField(blank=True) ellipse_angle = models.FloatField(blank=True) # Berkeley Color Project に基づくカラーパレット選択 color_palette_type = models.StringField( blank=True, choices=[ ['saturated', '鮮やか(彩度:高・明度:中)'], ['light', '淡い(彩度:中・明度:高)'], ['muted', '落ち着いた(彩度:中・明度:中)'], ['dark', '深い(彩度:中・明度:低)'], ], label="以下のカラーパレットのうち、あなたの好きな色を選びやすいものを1つ選んでください。" ) # 石原式色覚検査 ishihara_q1 = models.IntegerField(blank=True,label="上の図の中に何の数字が見えますか?") ishihara_q2 = models.IntegerField(blank=True,label="上の図の中に何の数字が見えますか?") ishihara_q3 = models.IntegerField(blank=True,label="上の図の中に何の数字が見えますか?") ishihara_q4 = models.IntegerField(blank=True,label="上の図の中に何の数字が見えますか?") ishihara_q5 = models.IntegerField(blank=True, label="上の図の中に何の数字が見えますか?") ishihara_q6 = models.IntegerField(blank=True, label="上の図の中に何の数字が見えますか?") ishihara_q7 = models.IntegerField(blank=True, label="上の図の中に何の数字が見えますか?") ishihara_q8 = models.IntegerField(blank=True, label="上の図の中に何の数字が見えますか?") ishihara_q9 = models.IntegerField(blank=True, label="上の図の中に何の数字が見えますか?") ishihara_q10 = models.IntegerField(blank=True, label="上の図の中に何の数字が見えますか?") avg_r = models.FloatField(blank=True) avg_g = models.FloatField(blank=True) avg_b = models.FloatField(blank=True) avg_hex = models.StringField(blank=True) # 色に関する質問 color_q0 = models.StringField(blank=True, label="あなたが好きな色を1つ教えてください。") color_q1 = models.IntegerField(blank=True, choices=[ [1, '1. ほとんど目にしない'], [2, '2. あまり目にしない'], [3, '3. どちらともいえない'], [4, '4. よく目にする'], [5, '5. 非常によく目にする'],], label="選択した色は、日常生活の中でどの程度慣れ親しんでいますか?") color_q2 = models.IntegerField(blank=True, choices=[ [1, '1. はい'], [2, '2. どちらとも言えない'], [3, '3. いいえ'],], label="選択した色を目にする具体的な場面が、日常生活の中で思い浮かびますか?") # demographics age = models.IntegerField(min=1, max=120, label="あなたの年齢をお書きください") gender = models.IntegerField(label="あなたの性別を教えてください。", choices=[ [1, '男性'], [2, '女性'], [3, 'その他'], [4, '答えたくない'],]) # big 5 neuroticism neuro1 = models.IntegerField(blank=True, choices=[ [1, '全く当てはまらない'], [2, 'あまり当てはまらない'], [3, 'どちらとも言えない'], [4, 'やや当てはまる'], [5, '非常に当てはまる'],], label="私は些細なことでも不安になりやすい。") neuro2 = models.IntegerField(blank=True, choices=[ [1, '全く当てはまらない'], [2, 'あまり当てはまらない'], [3, 'どちらとも言えない'], [4, 'やや当てはまる'], [5, '非常に当てはまる'],], label="物事を慎重に考えすぎることがある。") # PAGES class Intro(Page): def is_displayed(self): return self.round_number == 1 class ColorTestPage(Page): form_model = 'player' form_fields = [ 'ishihara_q1','ishihara_q2','ishihara_q3', 'ishihara_q4','ishihara_q5','ishihara_q6', 'ishihara_q7','ishihara_q8','ishihara_q9', 'ishihara_q10' ] def is_displayed(self): return self.round_number == 1 class ColorPalettePage(Page): form_model = 'player' form_fields = ['color_palette_type'] # BCP 4条件に対応するパレットパラメータ(maxSat, lightness) _PALETTE_PARAMS = { 'saturated': {'sat': 1.0, 'light': 0.50}, 'light': {'sat': 0.60, 'light': 0.75}, 'muted': {'sat': 0.50, 'light': 0.50}, 'dark': {'sat': 0.70, 'light': 0.25}, } _PALETTE_LABELS = { 'saturated': '鮮やか(彩度:高・明度:中)', 'light': '淡い(彩度:中・明度:高)', 'muted': '落ち着いた(彩度:中・明度:中)', 'dark': '深い(彩度:中・明度:低)', } class ColorEllipsePage(Page): form_model = 'player' form_fields = [ 'ellipse_area','ellipse_center_x', 'ellipse_center_y','ellipse_width', 'ellipse_height','ellipse_angle', 'avg_r', 'avg_g', 'avg_b', 'avg_hex','color_q1','color_q2','color_q0' ] def vars_for_template(self): # パレット選択はラウンド1のみ → 全ラウンドでラウンド1の値を参照 selected = self.color_palette_type or 'saturated' params = _PALETTE_PARAMS.get(selected, _PALETTE_PARAMS['saturated']) return { 'palette_max_sat': params['sat'], 'palette_light': params['light'], 'palette_label': _PALETTE_LABELS.get(selected, ''), } class Demographics(Page): form_model = 'player' form_fields = [ 'neuro1', 'neuro2', 'age', 'gender',] def is_displayed(self): return self.round_number == 3 page_sequence = [Intro, ColorTestPage, ColorPalettePage, ColorEllipsePage, Demographics, ]