from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import numpy as np import random author = 'Daphne Baldassari' doc = """Post-experiment survey. Ask demographic information""" class Constants(BaseConstants): name_in_url = 'survey_knowledge' players_per_group = None num_rounds = 1 labelfinance = 'If you answered yes, please detail your reasons and which type of job you would like to apply to. '\ ' If you answered no, please detail why. ' lottery_round = random.randint(1, 10) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): birth_year = models.IntegerField( label="What is your birth year?", min=1990, max=2005 ) self_gender = models.StringField( choices=['Male', 'Female', 'Other'], label='What is your gender?', widget=widgets.RadioSelect ) high_school_country = models.StringField( label='In which country did you go to high school?' ) ethnicity = models.StringField( choices=['White', 'South Asian (e.g. East Indian, Pakistani, Sri Lankan...)', 'Chinese', 'Black', 'Filipino', 'Latin American', 'Arab', 'Southeast Asian (e.g. Vietnamese, Cambodian, Laotian, Thai, ...)', 'West Asian (e.g. Iranian, Afghan,...)', 'Korean', 'Japanese', 'Other'], label='Are you:', widget=widgets.RadioSelect ) area = models.StringField( label='In what disciplinary area are you pursuing your degree?' ) year_of_study = models.StringField( choices=['First Year', 'Second Year', 'Third Year', 'Fourth Year', 'Fifth Year or more'], label='What is your current year of study? ', widget=widgets.RadioSelect ) student_in_major = models.StringField( choices=['Yes', 'No'], label='Are you enrolled in a major or a specialist program? ', widget=widgets.RadioSelect ) type_major = models.StringField( initial='N/A', label='If yes, what is your major or specialist program? ' ) desired_major = models.StringField( label='If no, which major or specialist program are you considering? ', initial='N/A' ) finance1 = models.StringField( label='Are you interested in studying finance? ', choices=['Yes', 'No'] ) finance2 = models.StringField( label='Are you considering a career in finance? ', choices=['Yes', 'No'] ) finance3 = models.LongStringField( label=Constants.labelfinance) finance4 = models.LongStringField( label='What are for you the qualities required to be successful in finance?', ) finance5 = models.StringField( label='Do you think men are more common in the financial industry than women?', choices=['Yes', 'No'] ) ra1 = models.StringField() ra2 = models.StringField() ra3 = models.StringField() ra4 = models.StringField() ra5 = models.StringField() ra6 = models.StringField() ra7 = models.StringField() ra8 = models.StringField() ra9 = models.StringField() ra10 = models.StringField() def set_payoff(self): if Constants.lottery_round == 1: p = .1 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p= p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 2: p = .2 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 3: p = .3 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 4: p = .4 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 5: p = .5 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 6: p = .6 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 7: p = .7 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 8: p = .8 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 9: p = .9 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) if Constants.lottery_round == 10: p = 1 if self.ra1 == 'g': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(2) else: self.payoff = c(1.6) if self.ra1 == 'd': dummy = np.random.binomial(n=1, p=p) if dummy == 1: self.payoff = c(3.85) else: self.payoff = c(0.10) pass