from otree.api import * from random import shuffle class C(BaseConstants): NAME_IN_URL = 'Survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): ####### DEMOGRAPHIC MEASURES########## gender = models.IntegerField( label="What is your gender?", choices=[ [1, 'Male'], [2, 'Female'], [3, 'Other'], ], ) citizen = models.IntegerField( label="Were your parents born in the United States or in another country?", choices=[ [1, 'Both parents born in the United States'], [2, 'One parent born in the United States, one parent born in another country'], [3, 'Both parents born in another country or countries'], ], ) education = models.IntegerField( label="What is your highest education level?", choices=[ [1, 'Less than High School Degree'], [2, 'High School Degree'], [3, 'Less than Undergraduate Degree'], [4, 'Undergraduate Degree'], [5, 'Master Degree'], [6, 'Graduate Degree'] ], ) partyid = models.IntegerField( label="Generally speaking, do you think of yourself as a:", choices=[ [1, 'Democrat'], [2, 'Republican'], [3, 'Independent'], [4, 'Other'] ], ) partyid_imp = models.IntegerField(widget=widgets.RadioSelect, label='''Here is a seven-point scale on which the political views that people might hold are arranged from extremely liberal to extremely conservative. Where would you place yourself on this scale?''', choices=[ [1, 'Extremely Liberal'], [2, 'Liberal'], [3, 'Slightly Liberal'], [4, 'Moderate; middle of the road'], [5, 'Slighly conservative'], [6, 'Conservative'], [7, 'Extremely conservative'], ], ) zipcode = models.IntegerField( label="What is your five-digit zip-code?") ########## IDENTITY MEASURES########## # Identity Importance and closeness with group # need to figure out what is the difference between salience and importance racialid_1 = models.IntegerField(min=1, max=6) ethnicid_2 = models.IntegerField(min=1, max=6) americanid_3 = models.IntegerField(min=1, max=6) politicalid_4 = models.IntegerField(min=1, max=6) # Partricipant attention attention = models.IntegerField() ########## Racial Networks and Contact ########## network = models.IntegerField( label='''How many close friends with different ethnic/racial background''') whitefri = models.IntegerField( label="How many close friends that are White") blackfri = models.IntegerField( label="How many close friends that are Black") hispanicfri = models.IntegerField( label="How many close friends that are Hispanic/Latino") asianfri = models.IntegerField( label="How many close friends that are Asian American") contact= models.StringField( choices=[ [1, 'None at all'], [2, 'A little'], [3, 'A moderate amount'], [4, 'A lot'], [5, 'Almost all the time or all the time']], label= ''' How much daily contact do you have with other ethnic or racial groups?''' ) discriminatio_per= models.StringField( choices=[ [1, 'None at all'], [2, 'A little'], [3, 'A moderate amount'], [4, 'A lot '], [5, 'A great deal']], label= '''How much discrimination have you personally faced because of your race or ethnicity?''' ) discrimination_group= models.StringField( choices=[ [1, 'None at all'], [2, 'A little'], [3, 'A moderate amount'], [4, 'A lot '], [5, 'A great deal']], label= ''' How much discrimination do you think your racial or ethnic group face today?''' ) microaggression= models.StringField( choices=[ [1, 'None at all'], [2, 'A little'], [3, 'A moderate amount'], [4, 'A lot '], [5, 'A great deal']], label= ''' How much micro-aggression have you personally faced because of your ethnicity or race?''' ) ########## Trust MEASURES########## whitetrust_1 = models.IntegerField(min=1, max=5) govertrust_2 = models.IntegerField(min=1, max=5) latinotrust_3 = models.IntegerField(min=1, max=5) friendtrust_4 = models.IntegerField(min=1, max=5) familytrust_6=models.IntegerField(min=1, max=5) blacktrust_7 = models.IntegerField(min=1, max=5) generaltrust_8 = models.IntegerField(min=1, max=5) asiantrust_9 = models.IntegerField(min=1, max=5) # Partricipant attention attention2 = models.IntegerField() ########## Group Rating Measures ########## whiterating = models.IntegerField( label="How would you rate White Americans?") demorating = models.IntegerField( label="How would you rate Democrats?") blackrating = models.IntegerField( label="How would you rate Blacks/African Americans?") asianrating = models.IntegerField( label="How would you rate Asian Americans?") immigrantrating = models.IntegerField( label="How would you rate Immigrants?") latinorating = models.IntegerField( label="How would you rate Hispanic/Latinos?") repubrating = models.IntegerField( label="How would you rate Republicans?") # FUNCTIONS # PAGES class Instructions(Page): pass class SurveyDemo1(Page): form_model = 'player' form_fields = ['gender', 'citizen', 'education', ] class SurveyDemo2(Page): form_model = 'player' form_fields = ['partyid', 'partyid_imp', 'zipcode'] class SurveyIdentity(Page): form_model = 'player' form_fields = ['racialid_1', 'ethnicid_2', 'americanid_3', 'politicalid_4', 'attention'] def vars_for_template(player): questions = [ ['racialid_1', 'id_racialid_1', 'My Racial identity is important to the way I think of myself as a person.'], ['ethnicid_2', 'id_ethnicid_2', 'My Ethnic identity is important to the way I think of myself as a person.'], ['americanid_3', 'id_americanid_3', 'My American identity is important to the way I think of myself as a person.'], ['politicalid_4', 'id_politicalid_4', 'My Political identity is important to the way I think of myself as a person.'], ['attention', 'id_attention', 'Please select "Strongly Agree."'], ] # Shuffle to avoid order effects shuffle(questions) return dict(items=questions) class SurveyNetwork(Page): form_model = 'player' form_fields = ['whitefri', 'blackfri', 'hispanicfri', 'asianfri'] class SurveyDiscrimination(Page): form_model = 'player' form_fields = ['contact','discriminatio_per', 'discrimination_group', 'microaggression'] class SurveyTrust1(Page): form_model = 'player' form_fields = ['whitetrust_1', 'govertrust_2','latinotrust_3', 'friendtrust_4', 'attention2'] def vars_for_template(player): questions = [ ['whitetrust_1', 'id_whitetrust_1', 'How often do you feel that you can trust White Americans?'], ['govertrust_2', 'id_govertrust_2', 'How often can you trust the federal government in Washington to do what is right?'], ['latinotrust_3', 'id_latinotrust_3', 'How often do you feel that you can trust Hispanics/Latinos?'], ['friendtrust_4', 'id_friendtrust_4', 'How often do you feel that you can trust your closest Friends?'], ['attention2', 'id_attention2', 'Please select "Strongly Agree."'], ] # Shuffle to avoid order effects shuffle(questions) return dict(items=questions) class SurveyTrust2(Page): form_model = 'player' form_fields = ['familytrust_6', 'blacktrust_7', 'generaltrust_8', 'asiantrust_9' ] def vars_for_template(player): questions = [ ['familytrust_6', 'id_familytrust_6', 'How often do you feel that you can trust your Family?'], ['blacktrust_7', 'id_blacktrust_7', 'How often do you feel that you can trust Blacks or African Americans?'], ['generaltrust_8', 'id_generaltrust_8', 'Generally speaking, how often do you feel that can you trust other people?'], ['asiantrust_9', 'id_asiantrust_9', 'How often do you feel that you can trust Asian Americans?'], ] # Shuffle to avoid order effects shuffle(questions) return dict(items=questions) class SurveyRatings(Page): form_model = 'player' form_fields = ['whiterating', 'demorating', 'blackrating', 'asianrating', 'immigrantrating','latinorating', 'repubrating'] page_sequence = [Instructions, SurveyDemo1, SurveyDemo2, SurveyIdentity, SurveyNetwork, SurveyDiscrimination, SurveyTrust1, SurveyTrust2, SurveyRatings]