from otree.api import * import random class Constants(BaseConstants): name_in_url = 'survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): consent = models.IntegerField( widget=widgets.RadioSelect, choices=[1, 0] ) Q1 = models.StringField( choices=[['1', 'A real gambler'], ['2', 'Willing to take risks after completing adequate research'], ['3', 'Cautious'], ['4', 'A real risk avoider'] ], label='In general, how would your best friend describe you as a risk taker?', widget=widgets.RadioSelect, ) Q2 = models.StringField( choices=[['1', '$1,000 in cash'], ['2', 'A 50% chance at winning $5,000'], ['3', 'A 25% chance at winning $10,000'], ['4', 'A 5% chance at winning $100,000'] ], label='You are on a TV game show and can choose one of the following. Which would you take?', widget=widgets.RadioSelect, ) Q3 = models.StringField( choices=[['1', 'Cancel the vacation'], ['2', 'Take a much more modest vacation'], ['3', 'Go as scheduled, reasoning that you need the time to prepare for a job search'], ['4', 'Extend your vacation, because this might be your last chance to go first-class'] ], label='You have just finished saving for a “once-in-a-lifetime” vacation.' ' Three weeks before you plan to leave, you lose your job. You would:', widget=widgets.RadioSelect, ) Q4 = models.StringField( choices=[['1', 'Deposit it in a bank account, money market account, or an insured CD'], ['2', 'Invest it in safe high quality bonds or bond mutual funds'], ['3', 'Invest it in stocks or stock mutual funds'] ], label='If you unexpectedly received $20,000 to invest, what would you do?', widget=widgets.RadioSelect, ) Q5 = models.StringField( choices=[['1', 'Not at all comfortable'], ['2', 'Somewhat comfortable'], ['3', 'Very comfortable'] ], label='In terms of experience, how comfortable are you investing in stocks or stock mutual funds?', widget=widgets.RadioSelect, ) Q6 = models.StringField( choices=[['1', 'Loss'], ['2', 'Uncertainty'], ['3', 'Opportunity'], ['4', 'Thrill'] ], label='When you think of the word “risk” which of the following words comes to mind first?', widget=widgets.RadioSelect, ) Q7 = models.StringField( choices=[['1', 'Hold the bonds'], ['2', 'Sell the bonds, put half the proceeds into money market accounts, and the other half into hard assets'], ['3', 'Sell the bonds and put the total proceeds into hard assets'], ['4', 'Sell the bonds, put all the money into hard assets, and borrow additional money to buy more'] ], label='Some experts are predicting prices of assets such as gold, jewels, collectibles, and real estate (hard assets) to increase in value; ' 'bond prices may fall, however, experts tend to agree that government bonds are relatively safe. ' 'Most of your investment assets are now in high interest government bonds. What would you do?', widget=widgets.RadioSelect, ) Q8 = models.StringField( choices=[['1', '$200 gain best case; $0 gain/loss worst case'], ['2', '$800 gain best case; $200 loss worst case'], ['3', '$2,600 gain best case; $800 loss worst case'], ['4', '$4,800 gain best case; $2,400 loss worst case'] ], label='Given the best and worst case returns of the four investment choices below, which would you prefer?', widget=widgets.RadioSelect, ) Q9 = models.StringField( choices=[['1', 'A sure gain of $500'], ['2', 'A 50% chance to gain $1,000 and a 50% chance to gain nothing'] ], label='In addition to whatever you own, you have been given $1,000. You are now asked to choose between:', widget=widgets.RadioSelect, ) Q10 = models.StringField( choices=[['1', 'A sure loss of $500'], ['2', 'A 50% chance to lose $1,000 and a 50% chance to lose nothing'] ], label='In addition to whatever you own, you have been given $2,000. You are now asked to choose between:', widget=widgets.RadioSelect, ) Q11 = models.StringField( choices=[['1', 'A savings account or money market mutual fund'], ['2', 'A mutual fund that owns stocks and bonds'], ['3', 'A portfolio of 15 common stocks'], ['4', 'Commodities like gold, silver, and oil'] ], label='Suppose a relative left you an inheritance of $100,000, ' 'stipulating in the will that you invest ALL the money in ONE of the following choices. ' 'Which one would you select?', widget=widgets.RadioSelect, ) Q12 = models.StringField( choices=[['1', '60% in low-risk investments 30% in medium-risk investments 10% in high-risk investments'], ['2', '30% in low-risk investments 40% in medium-risk investments 30% in high-risk investments'], ['3', '10% in low-risk investments 40% in medium-risk investments 50% in high-risk investments'] ], label='If you had to invest $20,000, which of the following investment choices would you find most appealing?', widget=widgets.RadioSelect, ) Q13 = models.StringField( choices=[['1', 'Nothing'], ['2', 'One month’s salary'], ['3', 'Three month’s salary'], ['4', 'Six month’s salary'] ], label='Your trusted friend and neighbor, an experienced geologist, is putting together a group of investors to fund an exploratory gold mining venture. ' 'The venture could pay back 50 to 100 times the investment if successful. ' 'If the mine is a bust, the entire investment is worthless. ' 'Your friend estimates the chance of success is only 20%. ' 'If you had the money, how much would you invest?', widget=widgets.RadioSelect, ) # FUNCTIONS # PAGES class Agreement(Page): form_model = 'player' form_fields = ['consent'] @staticmethod def before_next_page(player, timeout_happened): player.participant.showup = 2 player.participant.payment = player.participant.showup player.participant.Consent = player.consent @staticmethod def app_after_this_page(player, upcoming_apps): if player.consent == 0: return upcoming_apps[7] class Instruction(Page): pass class Risk1(Page): form_model = 'player' form_fields = ['Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6'] class Risk2(Page): form_model = 'player' form_fields = ['Q7', 'Q8', 'Q9', 'Q10', 'Q11', 'Q12', 'Q13'] class Results(Page): @staticmethod def app_after_this_page(player, upcoming_apps): player.participant.treatment = random.randint(0, 2) if player.participant.treatment == 0: return upcoming_apps[0] elif player.participant.treatment == 1: return upcoming_apps[2] else: return upcoming_apps[4] page_sequence = [Agreement,Instruction,Risk1,Risk2,Results]