from otree.api import * doc = """ Survey and Debrief """ class C(BaseConstants): NAME_IN_URL = 'after_game' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def make_q(label): return models.IntegerField(label=label, choices=[1, 2, 3, 4, 5], widget=widgets.RadioSelect) def make_likert7(label): return models.IntegerField(label=label, choices=[1, 2, 3, 4, 5, 6, 7], widget=widgets.RadioSelect) class Player(BasePlayer): # emergency_number = models.StringField( # label='6. If you had an emergency, what telephone number would you dial?', # widget = widgets.RadioSelect, # choices = ["112", "911", "000", "119"] # ) age = models.IntegerField( label='1. What is your age?', min=13, max=125) gender = models.StringField( label='2. What is your gender?', widget=widgets.RadioSelect, choices=["Female", "Male", "Other", "Prefer not to say"], ) race = models.StringField( label='3. What race or ethnicity best describes you?', widget=widgets.RadioSelect, choices=["White/Caucasian", "Irish Traveler", "Hispanic or Latino", "Black", "Asian", "Multiple ethnicity/Other", 'Prefer not to say']) exchange_student = models.StringField( label='4. Are you a visiting/exchange/erasumus student?', widget=widgets.RadioSelect, choices=["Yes", "No"] ) irish_citizen = models.StringField( label='5. Are you a citizen of the Republic of Ireland?', widget=widgets.RadioSelect, choices=["Yes", "No"] ) immigration_background = models.StringField( label='6. Did one or both of your parents/guardians ' 'immigrate to the Republic of Ireland from another country ' 'that is not the UK/Northern Ireland?', widget=widgets.RadioSelect, choices=["One of my parents/guardians immigrated to Republic of Ireland", "Both of my parents/guardians immigrated to Republic of Ireland", "Neither of my parents/guardians immigrated to Republic of Ireland"] ) naivety = models.StringField( label='7. Have you ever participated in a decision-making game similar to this one before?', widget=widgets.RadioSelect, choices=["Yes", "No", "Not Sure"] ) # education = models.StringField( # label='3. What is the highest education level you have achieved?', # widget=widgets.RadioSelect, # choices=["Less than high school", "High school or equivalent", "Some College", "College", "Advanced Degree"] # ) # race = models.StringField( # label='4. What is your race?', # widget=widgets.RadioSelect, # choices=["White", "Hispanic or Latino", "Black or African American", "Asian", "Other"]) # employment_status = models.StringField( # label='5. What is your employment status?', # widget=widgets.RadioSelect, # choices=["Student", "Unemployed", "Retired", "Full-Time Employed", "Part-Time Employed"]) q1 = make_q('is reserved') q2 = make_q('is generally trusting') q3 = make_q('tends to be lazy') q4 = make_q('is relaxed, handles stress well') q5 = make_q('has few artistic interests') q6 = make_q('is outgoing, sociable') q7 = make_q('tends to find fault with others') q8 = make_q('does a thorough job') q9 = make_q('gets nervous easily') q10 = make_q('has an active imagination') #The big five comes from: Rammstedt, B. and John, O.P., 2007. Measuring personality in one minute or less: # A 10-item short version of the Big Five Inventory in # English and German. Journal of research in Personality, 41(1), pp.203-212. extraversion = models.FloatField() agreeableness = models.FloatField() conscientiousness = models.FloatField() neuroticism = models.FloatField() openness = models.FloatField() bjw1 = make_likert7('I feel that most people in Country A got what they are entitled to have.') bjw2 = make_likert7('I feel that a person’s efforts in Country A were noticed and rewarded.') bjw3 = make_likert7('I feel that people in Country A earned the rewards and punishments they got.') bjw4 = make_likert7('I feel that people in Country A who met with misfortune have brought it on themselves.') bjw5 = make_likert7('I feel that people in Country A got what they deserve.') bjw6 = make_likert7('I feel that in Country A, the rewards and punishments were fairly given.') bjw7 = make_likert7('I basically feel that Country A is a fair place.') political_affiliation = make_likert7('8. Which of the following best ' 'describes your political orientation?') thermometer = models.IntegerField(blank=True, choices=[-100, -75, 50, -25, 0, 25, 50, 75, 100], widget=widgets.RadioSelect) corruption_perception = models.StringField(blank=True, label='Based on the observed amount of tax embezzled by the officials in Country A, according to' ' you, how corrupt or noncorrupt were officials in Country A?', widget=widgets.RadioSelect, choices=["Extremely Corrupt", "Very Corrupt", "Mildly Corrupt", "Not Corrupt at all"], ) def combine_score(positive, negative): return 3 + (positive - negative) / 2 # PAGES class Survey1(Page): form_model = 'player' form_fields = ['thermometer', 'bjw1', 'bjw2', 'bjw2', 'bjw3', 'bjw4', 'bjw5', 'bjw6', 'bjw7', 'corruption_perception'] class Survey2(Page): form_model = 'player' form_fields = ['age', 'gender', 'race', 'political_affiliation', 'naivety', 'exchange_student', 'irish_citizen', 'immigration_background'] class Survey3(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7', 'q8', 'q9', 'q10'] @staticmethod def before_next_page(player: Player, timeout_happened): player.extraversion = combine_score(player.q6, player.q1) player.agreeableness = combine_score(player.q2, player.q7) player.conscientiousness = combine_score(player.q8, player.q3) player.neuroticism = combine_score(player.q9, player.q4) player.openness = combine_score(player.q10, player.q5) class Debrief (Page): pass class Code (Page): pass page_sequence = [Survey1, Survey2, Survey3, Debrief, Code]