from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Survey_and_End' players_per_group = None num_rounds = 1 bonus_max = c(0.5) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): Bet = models.StringField(label="Do you want to take the bet?", widget=widgets.RadioSelect, choices=[["No","No bet: keep my full participation fee."], ["Yes","Make the bet: invest £1 from my participation fee."]]) Prolific_ID = models.StringField() Occupation_1 = models.LongStringField() Occupation_2 = models.LongStringField() Question_1 = models.IntegerField(label="Betting a day’s income at a sporting event", choices=[1, 2, 3, 4, 5, 6, 7]) Question_2 = models.IntegerField(label="Investing 10% of your annual income in a new business that might fail, but might give you a very good profit", choices=[1, 2, 3, 4, 5, 6, 7]) Question_3 = models.IntegerField(label="Investing 10% of your annual income in a savings account, which will give you a guaranteed but small return", choices=[1, 2, 3, 4, 5, 6, 7]) win_bet = models.StringField() def payoff_final(self): import random lottery = random.randint(0,1) if lottery == 1: self.win_bet = "Yes" else: self.win_bet = "No" if self.Bet == "Yes": self.payoff = 2*lottery - 1 else: self.payoff = 0