from otree.api import * from survey.lib.validations import * from survey.lib.utils import (fetch_articles, fetch_countries, fetch_code, mark_info, info_provided, insert_email_article_pair) c = cu doc = '' countries = fetch_countries() class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 SUBTITLE = "Questions" A_LABEL = "1. Is the article about Johnny Depp?" B_LABEL = "2. What is the overall stance towards Johnny Depp within the article?" B_LABEL2 = "(0 being most negative and 10 being most positive)" C_LABEL = "3. Does the article mention Amber Heard?" D_LABEL = "4. What is the overall stance towards Amber Heard within the article?" D_LABEL2 = "(0 being most negative and 10 being most positive)" E_LABEL = "5. Is the article related to the 2022 defamination trial of Johnny Depp and Amber Heard?" F_LABEL = "6. Which words/phrases mostly impacted your judgment? Copy and paste them below, separated by a new line." class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): email = models.StringField() code = models.StringField() name = models.StringField() age = models.IntegerField() gender = models.StringField(choices=[['male', 'Male'], ['female', 'Female'], ['other', 'Other'], ['na', 'Prefer not to say']], widget=widgets.RadioSelect) country = models.StringField(choices=countries) q1_a = models.BooleanField(label=C.A_LABEL) q1_b = models.IntegerField(label=C.B_LABEL, max=10, min=0) q1_c = models.BooleanField(label=C.C_LABEL) q1_d = models.IntegerField(label=C.D_LABEL, max=10, min=0) q1_e = models.BooleanField(label=C.E_LABEL) q1_f = models.LongStringField(label=C.F_LABEL, blank=True) q1_id = models.StringField() q2_a = models.BooleanField(label=C.A_LABEL) q2_b = models.IntegerField(label=C.B_LABEL, max=10, min=0) q2_c = models.BooleanField(label=C.C_LABEL) q2_d = models.IntegerField(label=C.D_LABEL, max=10, min=0) q2_e = models.BooleanField(label=C.E_LABEL) q2_f = models.LongStringField(label=C.F_LABEL, blank=True) q2_id = models.StringField() class UserEmail(Page): form_model = 'player' form_fields = ['email'] class UserCode(Page): form_model = 'player' form_fields = ['code'] class UserInfo(Page): @staticmethod def is_displayed(player): return not(info_provided(player.email)) form_model = 'player' form_fields = ['name', 'age', 'gender', 'country'] class Question1(Page): @staticmethod def vars_for_template(player): current_articles = fetch_articles(email=player.email) return dict( Q1 = current_articles[0][1], Q1_ID = current_articles[0][0] ) form_model = 'player' form_fields = ['q1_id', 'q1_a', 'q1_b', 'q1_c', 'q1_d', 'q1_e', 'q1_f'] class Question2(Page): @staticmethod def vars_for_template(player): current_articles = fetch_articles(email=player.email) return dict( Q2 = current_articles[0][1], Q2_ID = current_articles[0][0] ) form_model = 'player' form_fields = ['q2_id', 'q2_a', 'q2_b', 'q2_c', 'q2_d', 'q2_e', 'q2_f'] class ThankYou(Page): @staticmethod def vars_for_template(player): insert_email_article_pair(player.email, player.q1_id) insert_email_article_pair(player.email, player.q2_id) page_sequence = [UserEmail, UserCode, UserInfo, Question1, Question2, ThankYou]