from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random import itertools class Constants(BaseConstants): name_in_url = 'survey2' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): # # randomize to treatments # for player in self.get_players(): # player.treatment = random.choice(['one', 'two', 'three']) # print('set player.group to', player.treatment), treatment = itertools.cycle(['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve']) for p in self.get_players(): p.treatment = next(treatment) class Group(BaseGroup): pass class Player(BasePlayer): treatment = models.StringField( choices=[['one', 'one'], ['two', 'two',], ['three', 'three'], ['four', 'four'], ['five', 'five',], ['six', 'six'], ['seven', 'seven'], ['eight', 'eight',], ['nine', 'nine'], ['ten', 'ten'], ['eleven', 'eleven'], ['twelve', 'twelve']] ) education = models.StringField( choices=[ ["A. Primary School", "Primary School"], ["B. High School", "High School"], ["C. Vocational Training", "Vocational Training"], ["D. Bachelor", "Bachelor"], ["E. Master", "Master"], ["F: PhD", "PhD"], ["G. Other ", "Other "], ], widget=widgets.RadioSelect, label="34. My highest completed education is", ) occupation = models.StringField( choices=[ ["A. Student ", "Student "], ["B. Employed ", "Employed "], ["C. Self-Employed ", "Self-Employed "], ["D. Unemployed ", "Unemployed "], ["E. Other ", "Other "], ], widget=widgets.RadioSelect, label="35. My current occupation is:", ) income = models.StringField( choices=[ ["A. 0-1500 EUR ", "0-1500 EUR "], ["B. 1501-3000 EUR ", "1501-3000 EUR "], ["C. 3001-5000 EUR ", "3001-5000 EUR "], ["D. >5000 EUR ", ">5000 EUR "], ["E.I do not know ", "I do not know "], ["F. Skip this question", "Skip this question"], ], widget=widgets.RadioSelect, label="36. My monthly before-tax income is:", ) age = models.IntegerField(label="32. What is your year of birth?", widget=widgets.Slider, min=1900, max=2002) residence = models.StringField(label="37. Please select the country of your current residence", choices=['Austria', 'Belgium', 'Estonia', 'Finland', 'France', 'Germany', 'Ireland', 'Italy', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Portugal', 'Slovenia', 'Spain', 'Other'] ) gender = models.StringField( choices=[["Male", "Male"], ["Female", "Female"], ["Other", "Other"]], label="33. What is your gender", widget=widgets.RadioSelect, ) self_risk = models.FloatField( label="31. How do you see yourself: Are you in general a person who takes risk or do you try to avoid risks? Please provide a self-assessment from 1 to 10, with 1 meaning highly avoiding risks, and 10 meaning highly risk taking", choices=[[1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"],[6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10"]], widget=widgets.RadioSelectHorizontal )