from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) doc = "" class Constants(BaseConstants): name_in_url = "my_survey" players_per_group = None num_rounds = 1 instructions_template = 'my_survey/instructions.html' import random import itertools class Subsession(BaseSubsession): def creating_session(self): colors = itertools.cycle(['blue', 'red', 'green', 'yellow', 'orange']) for player in self.get_players(): player.color = next(colors) class Group(BaseGroup): pass class Player(BasePlayer): hidden = models.IntegerField() charity = models.CurrencyField(choices=currency_range(c(0), c(1.00), c(0.10))) def some_method(self): self.random_bonus = c(random.randint(1,10)) color = models.StringField() age = models.IntegerField(label="What is your age?", min=16, max=80) gender = models.IntegerField(choices=[[1, "Male"], [2, "Female"], [3, "Other"]], label="What is your gender?", widget=widgets.RadioSelect) level = models.IntegerField(choices=[[1, "Assessment"], [2, "Bachelor"], [3, "Master"], [4, "PhD"]], label="On which level do you study?", widget=widgets.RadioSelect) major = models.IntegerField(choices=[[1, "Assessment"], [2, "Economics"], [3, "Business Administration"], [4, "Law"], [5, "Law and Economics"], [6, "International Affairs"], [7, "Banking and Finance"], [8, "Accounting and Finance"], [9, "Marketing"], [10, "Other"]], label="major") semester = models.IntegerField(label="What semester are you in?", min=1, max=10) income = models.IntegerField(choices=[[1, "less than CHF 500"], [2, "CHF 500 to 1,499"], [3, "CHF 1,500 to 2,499"], [4, "CHF 2,499 to 3,499"], [5, "CHF 3,500 or more"]], label="How much money do you have at your disposal per month?", widget=widgets.RadioSelect) income_source = models.IntegerField(choices=[[1, "Scholarship"], [2, "Family"], [3, "Job"], [4, "Other"]], label="What is your main source of income?", widget=widgets.RadioSelect) risk = models.IntegerField(choices=[[1, "0 (not at all willing to take risks"], [2, "1"], [3, "2"], [4, "3"], [5, "4"], [6, "5"], [7, "6"], [8, "7"], [9, "8"], [10, "9"], [11, "10 (very willing to take risks)"]], label="How do you see yourself: are you generally a person who is fully prepared to " "take risks or do you try to avoid taking risks? Please tick a box on the scale, " "where ''the value 0 means: not at all willing to take risks and the value 10 " "means: very willing to take risks''") physical = models.StringField(choices=["More than once a week", "Once a week", "One to three times a month ", "Hardly ever, Never"], label="How often do you engage in vigorous physical activity, such as sports, " "heavy housework, or a job that involves physical labor?", widget=widgets.RadioSelect) health = models.IntegerField(choices=[[1, "Excellent"], [2, "Very good"], [3, "Good"], [4, "Fair"], [5, "Poor"]], label="Would you say your health is...", widget=widgets.RadioSelect) birth = models.StringField(choices=["Caesarean section", "Natural birth", "Don\'t know", "Prefer not to say"], label="Was your birth by caesarean section or natural birth?", widget=widgets.RadioSelect) submit = models.StringField() outcome = models.IntegerField( # blank = True, min = 0, max = 10, label = "" , ) HEXACO1 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="I wouldn't use flattery to get a " "raise or promotion at work.", widget=widgets.RadioSelectHorizontal) HEXACO2 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="If I knew that I could never get " "caught, I would be willing to steal a " "million dollars.", widget=widgets.RadioSelectHorizontal) HEXACO3 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="Having a lot of money is not " "especially important to me.", widget=widgets.RadioSelectHorizontal) HEXACO4 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="I think that I am entitled to more " "respect than the average person is.", widget=widgets.RadioSelectHorizontal) HEXACO5 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="If I want something from someone, I " "will laugh at that person's worst jokes.", widget=widgets.RadioSelectHorizontal) HEXACO6 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="I would get a lot of pleasure from " "owning expensive luxury goods.", widget=widgets.RadioSelectHorizontal) HEXACO7 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="I want people to know that I am an " "important person of high status.", widget=widgets.RadioSelectHorizontal) HEXACO8 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="I wouldn't pretend to like someone " "just to get that person to do favors for me.", widget=widgets.RadioSelectHorizontal) HEXACO9 = models.IntegerField(choices=[1, 2, 3, 4, 5], label="I'd be tempted to use counterfeit " "money, if I were sure I could get away with it.", widget=widgets.RadioSelectHorizontal)