from otree import settings from otree.api import * import time doc = """ Final """ #SESSION class Constants(BaseConstants): name_in_url = "SocioDemo" players_per_group = None num_rounds = 1 #SUBSESSION class Subsession(BaseSubsession): pass #GROUP class Group(BaseGroup): pass ##PLAYER class Player(BasePlayer): time_survey0 = models.FloatField() time_survey1 = models.FloatField() time_survey2 = models.FloatField() time_survey3 = models.FloatField() time_survey4 = models.FloatField() time_survey5 = models.FloatField() time_survey6 = models.FloatField() sex = models.IntegerField( choices=[[0, 'Female'], [1, 'Male'], [2, 'Other'], [3, 'Prefer not to disclose']], label='What was your sex assigned at birth?', widget=widgets.RadioSelect, blank=True ) age = models.IntegerField( label='What is your age?', max=99, min=1, ) race1 = models.IntegerField( label='What is your ethnicity?', choices=[[0, ''], [1, 'White']], widget=widgets.RadioSelectHorizontal, initial=0, blank=True ) race2 = models.IntegerField( label='What is your ethnicity?', choices=[[0, ''], [1, 'Black or African American']], widget=widgets.RadioSelectHorizontal, initial=0, blank=True ) race3 = models.IntegerField( label='What is your ethnicity?', choices=[[0, ''], [1, 'Asian']], widget=widgets.RadioSelectHorizontal, initial=0, blank=True ) race4 = models.IntegerField( label='What is your ethnicity?', choices=[[0, ''], [1, 'American Indian or Alaska Native']], widget=widgets.RadioSelectHorizontal, initial=0, blank=True ) race5 = models.IntegerField( label='What is your ethnicity?', choices=[[0, ''], [1, 'Native Hawaiian or Other Pacific Islander']], widget=widgets.RadioSelectHorizontal, initial=0, blank=True ) race6 = models.IntegerField( label='What is your ethnicity?', choices=[[0, ''], [1, 'Other']], widget=widgets.RadioSelectHorizontal, initial=0, blank=True ) hispanic = models.IntegerField( label='Are you of Hispanic, Latino, or Spanish origin?', choices=[[1, 'Yes'],[0, 'No'], [2, 'Prefer not to disclose']], widget=widgets.RadioSelect, blank=True ) state = models.IntegerField( choices =[[1, "Alabama"], [2, "Alaska"], [3, "Arizona"], [4, "Arkansas"], [5, "California"], [6, "Colorado"], [7, "Connecticut"], [8, "Delaware"], [9, "Florida"], [10, "Georgia"], [11, "Hawaii"], [12, "Idaho"], [13, "Illinois"], [14, "Indiana"], [15, "Iowa"], [16, "Kansas"], [17, "Kentucky"], [18, "Louisiana"], [19, "Maine"], [20, "Maryland"], [21, "Massachusetts"], [22, "Michigan"], [23, "Minnesota"], [24, "Mississippi"], [25, "Missouri"], [26, "Montana"], [27, "Nebraska"], [28, "Nevada"], [29, "New Hampshire"], [30, "New Jersey"], [31, "New Mexico"], [32, "New York"], [33, "North Carolina"], [34, "North Dakota"], [35, "Ohio"], [36, "Oklahoma"], [37, "Oregon"], [38, "Pennsylvania"], [39, "Rhode Island"], [40, "South Carolina"], [41, "South Dakota"], [42, "Tennessee"], [43, "Texas"], [44, "Utah"], [45, "Vermont"], [46, "Virginia"], [47, "Washington"], [48, "West Virginia"], [49, "Wisconsin"], [50, "Wyoming"], [51, "I currently do not reside in the US"]], label="In which state do you currently live?", ) education = models.IntegerField( choices=[[0, "Less than high school"], [1, "High school or equivalent (e.g., GED)"], [2, "Some college, but not a degree"], [3, "Associate degree (e.g., AA, AS)"], [4, "Bachelor's Degree (e.g., BA, BS)"], [5, "Master's Degree (e.g., MA, MS, MBA)"], [6, "Professional Degree (e.g., JD, MD)"], [7, "Doctoral Degree (e.g., PhD)"]], label="What is the highest level of education you have completed?", ) dyslexia = models.IntegerField( choices=[[0, 'No'], [1, 'Yes'], [2, 'Prefer not to disclose']], label='Do you have diagnosed condition of dyslexia?', widget=widgets.RadioSelect, blank=True ) employment = models.IntegerField( choices=[[1, "Employed full-time (35+ hours per week)"], [2, "Employed part-time (less than 35 hours per week)"], [3, "Self-employed"], [4, "Unemployed and currently looking for a job"], [5, "Unemployed and currently not looking for a job"], [6, "Student"], [7, "Homecare"], [8, "Retired"]], label="What is your current employment status?", ) income = models.IntegerField( choices=[[0, '$0'], [1, '$1 to $9,999'], [2, '$10,000 to $14,999'], [3, '$15,000 to $19,999'], [4, '$20,000 to $24,999'], [5, '$25,000 to $49,999'], [6, '$50,000 to $99,999'], [7, 'More than $100,000'], [8, 'Prefer not to disclose']], label="What is your personal gross income in US dollars?", ) income_hh = models.IntegerField( choices=[[0, 'Less than $20,000'], [1, '$20,000 to $34,999'], [2, '$35,000 to $49,999'], [3, '$50,000 to $74,999'], [4, '$75,000 to $99,999'], [5, '$100,000 to $149,999'], [6, '$150,000 to $199,999'], [7, '$200,000 to $249,999'], [8, '$250,000 to $299,999'], [9, 'More than $300,000'], [10, 'Prefer not to disclose']], label="What is your family's gross household income in US dollars?", ) social = models.IntegerField( choices=[[1, "1: Very Liberal"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10: Very Conservative"]], label="When it comes to social issues, how liberal or conservative would you say that you are?", widget=widgets.RadioSelect, blank=True ) economic = models.IntegerField( choices=[[1, "1: Very Liberal"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10: Very Conservative"]], label="When it comes to economic issues, how liberal or conservative would you say that you are?", widget=widgets.RadioSelect, blank=True ) party = models.IntegerField( choices=[[1, 'Democrat'], [2, 'Republican'], [3, 'Independent']], label='Which political party do you more strongly identify with?', widget=widgets.RadioSelect, blank=True ) redis = models.IntegerField( choices = [[1, "Strongly Disagree"], [2, "Disagree"], [3, "Neither Agree nor Disagree"], [4, "Agree"], [5, "Strongly Agree"]], label="Government should redistribute income from the better off to those who are less well off.", widget=widgets.RadioSelect, blank=True ) ineqop = models.IntegerField( choices = [[1, "Strongly Disagree"], [2, "Disagree"], [3, "Neither Agree nor Disagree"], [4, "Agree"], [5, "Strongly Agree"]], label="The context from which a person comes from is important for getting ahead in society.", widget=widgets.RadioSelect, blank=True ) talent = models.IntegerField( choices = [[1, "Strongly Disagree"], [2, "Disagree"], [3, "Neither Agree nor Disagree"], [4, "Agree"], [5, "Strongly Agree"]], label="Exceptional talent can overcome bad luck.", widget=widgets.RadioSelect, blank=True ) shoes = models.IntegerField( choices = [[1, "Strongly Disagree"], [2, "Disagree"], [3, "Neither Agree nor Disagree"], [4, "Agree"], [5, "Strongly Agree"]], label="I find it easy to put myself in someone else’s shoes.", widget=widgets.RadioSelect, blank=True ) #FUNCTIONS def sex_error_message(player, value): if value not in [0, 1, 2, 3]: return 'You have to select one of the options.' def hispanic_error_message(player, value): if value not in [0, 1, 2]: return 'You have to select one of the options.' def dyslexia_error_message(player, value): if value not in [0, 1, 2]: return 'You have to select one of the options.' def social_error_message(player, value): if value not in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: return 'You have to select one of the options.' def economic_error_message(player, value): if value not in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: return 'You have to select one of the options.' def party_error_message(player, value): if value not in [1, 2, 3]: return 'You have to select one of the options.' def redis_error_message(player, value): if value not in [1, 2, 3, 4, 5]: return 'You have to select one of the options.' def ineqop_error_message(player, value): if value not in [1, 2, 3, 4, 5]: return 'You have to select one of the options.' def talent_error_message(player, value): if value not in [1, 2, 3, 4, 5]: return 'You have to select one of the options.' def shoes_error_message(player, value): if value not in [1, 2, 3, 4, 5]: return 'You have to select one of the options.' #PAGES class Instructions(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): player.time_survey0 = round(time.time(),3) class Socio1(Page): form_model = 'player' form_fields = ['sex','age','state','race1','race2','race3','race4','race5','race6','hispanic'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey1 = round(time.time(),3) class Socio2(Page): form_model = 'player' form_fields = ['education','dyslexia'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey2 = round(time.time(),3) class Socio3(Page): form_model = 'player' form_fields = ['employment','income','income_hh'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey3 = round(time.time(),3) class Socio4(Page): form_model = 'player' form_fields = ['social','economic','party'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey4 = round(time.time(),3) class Views(Page): form_model = 'player' form_fields = ['redis','ineqop','talent','shoes'] @staticmethod def before_next_page(player, timeout_happened): player.time_survey5 = round(time.time(),3) #SEQUENCE page_sequence = [Instructions, Socio1,Socio2,Socio3,Socio4, Views]