from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random import numpy as np import csv import pandas as pd doc = '''Information processing game, posterior''' class Constants(BaseConstants): name_in_url = 'Information_processing_intro' players_per_group = None num_rounds = 1 fixed_fee = 2 correct_answers_econ = [0,0,0] correct_answers_health = [0,1,0] cq_incentive = 0.5 correct_forecast = 5 class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): # TREATMENT VARIATIONS # 1=HumanCOrrect, 2=AICorrect # 3=HumanIncorrect, 4=AIIncorrect # 5=HumanNoDisc, 6=AINoDisc p.treat_ = random.randint(1, 6) p.econ_topic = random.randint(0, 1) class Group(BaseGroup): pass class Player(BasePlayer): ######################## ## GENERAL QUESTIONS ## ######################## # HUMAN OR AI TREATMENT treat_ = models.IntegerField(initial=-1) # 1 = ECONOMIC TOPIC, 2 = HEALTH TOPIC econ_topic = models.IntegerField(initial=-1) # CONSENTS consent = models.IntegerField(label='', initial=None, choices=[[1, 'I agree to participate']], widget=widgets.RadioSelect) income_ = models.FloatField(initial=Constants.fixed_fee) ######################################################################################################################## ## ARTICLE QUESTIONS ## ######################################################################################################################## def payoffs_(self): self.participant.vars['correct_answers'] = 0 if self.econ_topic == 1: solutions = Constants.correct_answers_econ else: solutions = Constants.correct_answers_health if solutions[0] == self.control_1: self.participant.vars['correct_answers'] += 1 if solutions[1] == self.control_2: self.participant.vars['correct_answers'] += 1 if solutions[2] == self.control_3: self.participant.vars['correct_answers'] += 1 self.participant.vars['income_answers'] = Constants.cq_incentive*self.participant.vars['correct_answers'] self.income_ += self.participant.vars['income_answers'] ############################################################################## ####### PERCEPTION OF ARTICLE ####### ############################################################################## skew = models.IntegerField( label='On a scale of -3 to +3, with negative numbers representing left leaning or liberal skew,
positive numbers representing right leaning or conservative skew, and 0 representing neutral,
how would you rate the article you just read?', initial=None, choices=[[-3, '-3 (Extremely left leaning)'], [-2, '-2 (Left leaning)'], [-1, '-1 (Slightly left leaning)'], [0, '0 (Neutral)'], [1, '1 (Slightly right leaning)'], [2, '2 (Right leaning)'], [3, '3 (Extremely right leaning)']]) reliance = models.IntegerField( label='On a scale of 1 to 7, with 1 being not reliable at all and 7 being extremely reliable,
how would you rate the information in the article you just read?', initial=None, choices=[[1, '1 (Not reliable at all)'], [2, '2'], [3, '3'], [4, '4 (Fairly reliable)'], [5, '5'], [6, '6'], [7, '7 (Extremely reliable)']]) inspiring = models.IntegerField( label='On a scale of 1 to 7, with 1 being not inspiring at all and 7 being extremely inspiring,
how would you rate the article you just read?', initial=None, choices=[[1, '1 (Not inspiring at all)'], [2, '2'], [3, '3'], [4, '4 (Fairly inspiring)'], [5, '5'], [6, '6'], [7, '7 (Extremely inspiring)']]) objectivity1 = models.IntegerField( label='The article provides objective news.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) objectivity2 = models.IntegerField( label='The article focuses on arguments over emotions in its coverage.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) objectivity3 = models.IntegerField( label='The article offers a comprehensive overview of all the important events.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) trust1 = models.IntegerField( label='I generally trust the information presented in the article I just read.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) trust2 = models.IntegerField( label='I generally distrust the information presented in the article I just read.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) recommendation1 = models.IntegerField( label='', initial=None, choices=[[i, f'{i}%'] for i in range(0,101)]) recommendation2 = models.IntegerField( label='', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) recommendation3 = models.IntegerField( label='', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) recommendation4 = models.IntegerField( label='', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) recommendation5 = models.IntegerField( label='', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) ############################################################################## ####### CONTROL QUESTIONS ####### ############################################################################## control_1 = models.IntegerField( label='', initial=None, choices=[ [0, 'False'], [1, 'True']], widget=widgets.RadioSelect ) control_2 = models.IntegerField( label='', initial=None, choices=[ [0, 'False'], [1, 'True']], widget=widgets.RadioSelect ) control_3 = models.IntegerField( label='', initial=None, choices=[ [0, 'False'], [1, 'True']], widget=widgets.RadioSelect ) ############################################################################## ####### CONCLUDING QUESTIONNAIRE ####### ############################################################################## prediction = models.IntegerField(label='', initial=None, choices=[[1, 'Strong decrease (will decrease by more than 7%).'], [2, 'Moderate decrease (will decrease by more than 3%, but less than 7%).'], [3, 'Stable (will decrease by at most 3%, and not increase by more than 3%).'], [4, 'Moderate increase (will increase by more than 3%, but less than 7 %).'], [5, 'Strong increase (will increase by more than 7%).']], widget=widgets.RadioSelect ) conf = models.IntegerField(label="Concerning the above forecast: On a scale from 1 to 5, with 1 being not confident at all and 5 being extremely confident,
how confident are you, that your personal expectation will turn out to be true.", initial=None, choices=[[1, '1 (Not confident at all.)'], [2, '2'], [3, '3'], [4, '4'], [5, '5 (Extremely confident.)']], widget=widgets.RadioSelect ) # POLITICAL SURVEY republican_1 = models.IntegerField(label='Do you consider yourself a(n)', choices=[ [1, 'Democrat'], [2, 'Republican'], [3, 'Independent'], [4, 'None of the above'] ], widget=widgets.RadioSelect ) republican_2 = models.IntegerField(label='Are you a strong or moderate Democrat/Republican?', choices=[ [1, 'Strong'], [2, 'Moderate'] ], widget=widgets.RadioSelect ) republican_3 = models.IntegerField(label='Do you consider yourself closer to the:', choices=[ [1, 'Democratic party'], [2, 'Republican party'] ], widget=widgets.RadioSelect ) # DEMOGRAPHICS age = models.IntegerField(initial=None, label='How old are you?') female = models.IntegerField(initial=None, label='What is your gender?', choices=[ [0, 'Male'], [1, 'Female'], [2, 'Non-Binary'], [3, 'I prefer not to answer'] ], widget=widgets.RadioSelect ) degree = models.IntegerField(initial=None, label='What is your highest academic degree achieved/in progress?', choices=[ [0, 'None'], [1, 'Highschool diploma'], [2, 'Bachelor'], [3, 'Master'], [4, 'Ph.D.'] ], widget=widgets.RadioSelect ) ethnicity = models.IntegerField(initial=None, label='What is your ethnic background?', choices=[ [0, 'Caucasian'], [1, 'African American'], [2, 'Hispanic'], [3, 'Asian'], [4, 'Other'], [5, 'I prefer not to answer'] ], widget=widgets.RadioSelect ) area = models.IntegerField(initial=None, label='How would you classify the area you live in?', choices=[ [0, 'Rural area'], [1, 'Suburban area'], [2, 'Urban area'] ], widget=widgets.RadioSelect ) # PREFERENCES risk_aversion = models.IntegerField( label='Please use a scale from 0 to 10 to describe your risk preferences. You can also use any numbers between 0 and 10 to indicate where you fall on the scale.', initial=None, choices=[[0, '0 (Completely unwilling to take risks)'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5 (Risk neutral)'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10 (Completely willing to take risks)']]) altruism = models.IntegerField( label='Imagine the following situation: Today you unexpectedly received $ 1,000 . How much of this amount would you donate to a good cause? (Values between 0 and 1,000 are allowed).', initial=None, min=0, max=1000) # ALGO AVERSION algo_aver1 = models.IntegerField( label='Artificial Intelligence Systems outperform humans in the domain of forecasting events like the development of stock market prices.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) algo_aver2 = models.IntegerField( label='Artificial Intelligence Systems outperform humans in the domain of making subjective recommendations like movie suggestions.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) algo_aver3 = models.IntegerField( label='Artificial Intelligence Systems outperform humans in the domain of detecting patterns in data.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) algo_aver4 = models.IntegerField( label='Artificial Intelligence Systems outperform humans in the domain of summarizing information from texts.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) # TECHNOLOGY OPENNESS techn_open1 = models.IntegerField( label='If I heard about a new information technology, I would look for ways to experiment with it.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) techn_open2 = models.IntegerField( label='Among my peers, I am usually the first to try out new information technologies.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) techn_open3 = models.IntegerField( label='In general, I am hesitant to try out new information technologies.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) techn_open5 = models.IntegerField( label='I like to experiment with new information technologies.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) techn_open4 = models.IntegerField( label='I am familiar with modern Artificial Intelligence Systems.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) # SOC NORMS soc_norm1 = models.IntegerField( label='I would feel a social obligation to follow the advice I obtain from another person.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) soc_norm2 = models.IntegerField( label='I would feel a social obligation to follow the advice I obtain from a machine.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) soc_norm3 = models.IntegerField( label='I would feel bad if I were to ignore advice from another person, because it is important to be courteous/polite.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) soc_norm4 = models.IntegerField( label='I would feel bad if I were to ignore advice from a machine, because it is important to be courteous/polite.', initial=None, choices=[[1, '1 (Strongly disagree)'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7 (Strongly agree)']]) open_comment = models.LongStringField(blank=True) # # # ### STRING WITH PARTICIPANTS PARTY AFFILIATION # def party_aff(self): # if (self.republican_1 == 1) | (self.republican_3 == 1): # self.participant.vars['party_aff'] = ['Democrat', 'Democratic', 'Republican', 'Republican'] # else: # self.participant.vars['party_aff'] = ['Republican', 'Republican', 'Democrat', 'Democratic'] # # #