import numpy from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from django import forms author = 'Your name here' doc = "" class Constants(BaseConstants): name_in_url = 'Human_Human' players_per_group = None num_rounds = 1 from numpy import random import random import itertools class Subsession(BaseSubsession): def creating_session(self): # randomize to treatments for player in self.get_players(): player.color = numpy.random.choice(['yellow', 'orange', 'black', 'white', 'red', 'green'], p=[0.1, 0.1, 0.1, 0.1, 0.3, 0.3]) print('set player.color to', player.color) from django import forms class Group(BaseGroup): pass class Player(BasePlayer): 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=11) 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) carInsurance = models.IntegerField(choices=[[1, "Yes"], [2, "No"]], label="Did you buy additional insurance the last time you rented a car?", widget=widgets.RadioSelect) gambling = models.IntegerField(choices=[[1, "Yes"], [2, "No"]], label="Do you participate in gambling multiple times a year (e.g. lotteries, " "sport bets, card games for money or casinos)?", widget=widgets.RadioSelect) workload = models.IntegerField(label="What is your workload besides your studies (in percent)?", min=0, max=100) weller8 = models.IntegerField(label="If the chance of getting a disease is 10 percent, how many people would be " "expected to get the disease out of 1,000?", min=0, max=1000) weller7 = models.IntegerField(label="If the chance of getting a disease is 20 out of 100, this would be the same " "as having a ____% chance of getting the disease.", min=0, max=100) weller6 = models.IntegerField(label="Imagine that we roll a fair, six-sided die 1000 times. Out of 1000 rolls, how " "many times do you think the die would come up as an even number?", min=0, max=1000) weller5 = models.IntegerField(label="In the BIG BUCKS LOTTERY, the chances of winning a $10.00 prize are 1%. " "What is your best guess about how many people would win a $10.00 prize if " "1000 people each buy a single ticket from BIG BUCKS?", min=0, max=1000) weller2 = models.DecimalField(verbose_name="A bat and a ball cost CHF 1.10 in total. The bat costs CHF 1.00 more " "than the ball. How much does the ball cost?", min=0, decimal_places=2, max_digits=5, widget=widgets.TextInput) crt2 = models.IntegerField(label="If it takes 5 machines 5 minutes to make 5 widgets, how long would it take 100 " "machines to make 100 widgets?", min=0, max=100) weller3 = models.IntegerField(label="In a lake, there is a patch of lily pads. Every day, the patch doubles in " "size. If it takes 48 days for the patch to cover the entire lake, how long " "would it take for the patch to cover half of the lake?", min=0, max=100) weller4 = models.FloatField(label="In Daily Times Sweepstakes, the chance of winning a car is 1 in 1000. " "What percent of tickets to Daily Times Sweepstakes win a car?", min=0, max=100, widget=widgets.TextInput) smokingever = models.IntegerField(choices=[[1, "Yes"], [2, "No"]], label="Have you ever smoked cigarettes, cigars, cigarillos or a pipe daily for " "a period of at least one year? ", widget=widgets.RadioSelect) smokingpresent = models.IntegerField(choices=[[1, "Yes"], [2, "No"]], label="Do you smoke at the present time?", widget=widgets.RadioSelect) oftendrinkany = models.StringField(choices=["Almost every day", "Five or six days a week", "Three or four days a week", "Once or twice a week", "Once or twice a month", "Less than once a month", "Not at all in the last 6 months"], label="During the last six months, how often have you drunk any alcoholic" " beverages like beer, cider, wine, spirits or cocktails?") oftendrinkmore = models.StringField(choices=["Almost every day", "Five or six days a week", "Three or four days a week", "Once or twice a week", "Once or twice a month", "Less than once a month", "Not at all in the last 6 months"], label="During the last six months, how often have you had more than two " "glasses of alcoholic beverages in a single day?") healthinscomp = models.StringField( choices=["Agrisano", "AMB Assurances SA", "Aquilana", "Arcosana", "Assura-Basis SA", "Atupri", "Avenir Krankenversicherung AG Bildende Künstler/Innen", "Birchmeier", "Compact", "CONCORDIA", "CSS", "Easy Sana Krankenversicherung AG EGK", "Einsiedeln Fenaco-Mitgliedgenossenschaften GALENOS", "Gewerbliche", "Glarner", "Helsana", "Hotela", "Ingenbohl", "INTRAS", "KLuG", "Kolping", "KPT/CPT", "KVF Krankenversicherung AG Lumneziana", "Luzerner Hinterland", "Metallbaufirmen", "Moove Sympany AG", "Mutuel Krankenversicherung AG ÖKK", "Philos Krankenversicherung AG Progrès", "PROVITA", "rhenusana", "sana24", "Sanagate", "sanavals", "Sanitas", "Simplon", "SLKK", "sodalis", "Steffisburg", "Stoffel", "Sumiswalder", "SUPRA-1846 SA", "SWICA", "Vallée d’Entremont", "Ville de Neuchâtel", "Visana", "Visperterminen", "vita surselva", "Vivacare", "Vivao Sympany", "Wädenswil", "I'm not covered under the Swiss Basic Health Care Insurance " "because I have comparable coverage form abroad"], label="From which of the following insurance companies have you bought " "mandatory health insurance coverage?") healthinsmodel = models.StringField(choices=["Standard", "HMO(Note: HMO-insured are obliged to first consult a " "physician at their HMO health center before being " "transferred to a specialist physician.)", "Hausarzt model (Note: insured in the Hausarzt model" " (general practitioner model) do not have free choice of physicians" " but are obliged to first consult their general practitioner " "before being transferred to a specialist physician.)", "Telmed modell (Note: insured in the Telmed modell are obliged to " "first call the medical advice unit of their health insurer before " "being transferred to a physician.)", "Other"], label="Which of the following insurance models have you chosen under the " "mandatory health insurance plan? [only if 1. is not 51]") healthinsded = models.StringField(choices=["300 CHF", "500 CHF", "1000 CHF", "1500 CHF", "2000 CHF", "2500 CHF", "Don't know", "I am not covered under the Swiss Basic Health Care " "Insurance"], label="Which of the following deductible levels have you chosen under the " "mandatory health insurance plan? (Note: the deductible is the amount " "per year you have to pay out of pocket (e.g., for doctor visits, " "hospitalization))") submit = models.StringField() decision = models.StringField(choices=["Deductible of CHF 300 for an annual premium of CHF 5,250.", "Deductible of CHF 500 for an annual premium of CHF 5,120.", "Deductible of CHF 1,000 for an annual premium of CHF 4,795.", "Deductible of CHF 1,500 for an annual premium of CHF 4,470.", "Deductible of CHF 2,000 for an annual premium of CHF 4,145.", "Deductible of CHF 2,500 for an annual premium of CHF 3,820."], label="In the following you find the six deductible options and their respective " "annual premiums. Please choose one of the options as if you would have to " "actually make this decision for real.", widget=widgets.RadioSelect) decision4 = models.StringField(choices=["Deductible of CHF 300 for an annual premium of CHF 5,250.", "Deductible of CHF 2,500 for an annual premium of CHF 3,820."], label="In the following you find the two deductible options and their respective " "annual premiums. Please choose one of the options as if you would have to " "actually make this decision for real.", widget=widgets.RadioSelect) belief = models.StringField(choices=["Exactly CHF 0", "Between CHF 1 and CHF 500", "Between CHF 501 and CHF 1,000", "Between CHF 1,001 and CHF 2,000", "Between CHF 2,001 and CHF 5,000", "Between CHF 5,001 and CHF 10,000", "Between CHF 10,001 and CHF 20,000", "Between CHF 20,001 and CHF 50,000", "More than CHF 50,000"], label="In which of the following ranges do you think your total annual cost of medical " "services will most likely be?", widget=widgets.RadioSelect) beliefconfidence = models.IntegerField(choices=[1, 2, 3, 4, 5], label="How confident are you that your actual total annual cost of medical " "services will be within the range stated in the previous question on " "a scale from 1 to 5, where 1 means not confident at all and 5 means " "very confident?", widget=widgets.RadioSelectHorizontal)