################################################################################ ## POST SURVEY APP ## ################################################################################ from otree.api import * from otree.forms.widgets import RadioSelect as rs doc = """ get post game survey data """ class C(BaseConstants): NAME_IN_URL = "post_survey" NUM_ROUNDS = 1 PLAYERS_PER_GROUP = None # for the survey EDUCATION_LEVEL_CHOICES = { "No schooling":1, "Early childhood education (e.g. Play school, Kindergarten)":2, "Primary education (Elementary school)":3, "Lower secondary education (e.g. Midddle school, AHS)":4, "Upper secondary education (e.g. High schol, Gymnasium, Higher technical and vocational college)":5, "Post-secondary non-tertiary education (e.g. Career, Technical or professional training programmes, Professional certificates":6, "Bachelor's or equivalent level":7, "Master's or equivalent level":8, "Doctoral or equivalent level":9 } class Player(BasePlayer): total_score = models.IntegerField(initial=0) status = models.IntegerField() country = models.StringField( choices=["Austria", "Germany", "Switzerland", "France", "Italy"], label="In which country do you currently live?", widget=rs) education_level = models.StringField( choices={ "No schooling":1, "Early childhood education (e.g. Play school, Kindergarten)":2, "Primary education (Elementary school)":3, "Lower secondary education (e.g. Midddle school, AHS)":4, "Upper secondary education (e.g. High schol, Gymnasium, Higher technical and vocational college)":5, "Post-secondary non-tertiary education (e.g. Career, Technical or professional training programmes, Professional certificates":6, "Bachelor's or equivalent level":7, "Master's or equivalent level":8, "Doctoral or equivalent level":9 }, label="What is your highest level of education?", widget=rs) mothers_education_level = models.StringField( choices={ "No schooling":1, "Early childhood education (e.g. Play school, Kindergarten)":2, "Primary education (Elementary school)":3, "Lower secondary education (e.g. Midddle school, AHS)":4, "Upper secondary education (e.g. High schol, Gymnasium, Higher technical and vocational college)":5, "Post-secondary non-tertiary education (e.g. Career, Technical or professional training programmes, Professional certificates":6, "Bachelor's or equivalent level":7, "Master's or equivalent level":8, "Doctoral or equivalent level":9 }, label="What is the highest level of education of your mother?", widget=rs) fathers_education_level = models.StringField( choices={ "No schooling":1, "Early childhood education (e.g. Play school, Kindergarten)":2, "Primary education (Elementary school)":3, "Lower secondary education (e.g. Midddle school, AHS)":4, "Upper secondary education (e.g. High schol, Gymnasium, Higher technical and vocational college)":5, "Post-secondary non-tertiary education (e.g. Career, Technical or professional training programmes, Professional certificates":6, "Bachelor's or equivalent level":7, "Master's or equivalent level":8, "Doctoral or equivalent level":9 }, label="What is the highest level of education of your father?", widget=rs) occupation = models.StringField( choices={ "Armed forces occupation":1, "Elementary occupation":2, "Plant and machine operators, and assemblers":3, "Craft and related trade workers":4, "Skilled agricultural, forestry and fishery workers":5, "Service and sales workers":6, "Clerical support workers":7, "Technicians and associate professionals":8, "Professionals":9, "Legislators, senior officials and managers":10, "None":0 }, label="What is your main occupation?(If you’re studying, unemployed or are not covering your own expenses, please choose the main occupation of one of your parents, choosing the one where monthly earnings are most likely to be higher)", widget=rs) household_composition = models.StringField( choices={ "One person (just me)":1, "One person and one child":2, "One person and two children":3, "Two persons":4, "Two persons and one child":5, "Two persons and two children":6, "Two persons and three children":7, "Three persons":8, "Three persons and one child":9, "Four persons":10, "Other":0, "No answer":0 }, label="Who lives in your household (including you) An (adult) person is defined as someone aged 15 or older. Persons under 15 are considered children. A household is a group of people who live and manage their expenses together (e.g., a family, a couple, etc.).?", widget=rs ) # not used (?) household_income = models.StringField( choices={ "First":1, "Second":2, "Third":4, "Fourth":7, "Fifth":11 }, label="What is the monthly net income in your household?", widget=rs) number_of_books = models.StringField( choices={"None or a few (0--10 books)":1, "Enough to fill half a shelf (11--25 books)":2, "Enough to fill a bookshelf (26–100 books)":3, "Enough to fill two bookshelves (101–200 books)":4, "Enough to fill three or more bookshelves (more than 200 books)":5}, label="How many books do you have at home?", widget=rs) # not used(?) # Cultural activities frequency cultural_activities_frequency = models.StringField( choices=["Not at all", "Once or twice", "Three or four times", "More than four times"], label="In the past 12 months, how often did you attend the following activities? (Theater, lectures, museums, etc.)", widget=rs) def calculate_total_score(self): total_score = 0 education_points = self.education_level.choices.get(self.education_level, 0) total_score += education_points mothers_ed_points = self.mothers_education_level.choices.get(self.mothers_education_level, 0) total_score += mothers_ed_points fathers_ed_points = self.fathers_education_level.choices.get(self.fathers_education_level, 0) total_score += fathers_ed_points occupation_points = self.occupation.choices.get(self.occupation, 0) total_score += occupation_points household_points = self.household_composition.choices.get(self.household_composition, 0) total_score += household_points books_points = self.number_of_books.choices.get(self.number_of_books, 0) total_score += books_points return total_score def determine_status(self): if 47 <= self.total_score <= 53: return 1 elif 30 <= self.total_score <= 46: return 2 elif 21 <= self.total_score <= 29: return 3 elif 12 <= self.total_score <= 20: return 4 else: return 5 def before_next_page(self): self.total_score = self.player.calculate_total_score() self.status = self.determine_status() # -------------------- UNUSED CLASSES -------------------- class Group(BaseGroup): pass class Subsession(BaseSubsession): pass # -------------------- PAGES -------------------- class PostSurvey(Page): form_model = "player" form_fields = [ 'country', 'education_level', 'mothers_education_level', 'fathers_education_level', 'occupation', 'household_composition', 'number_of_books', 'cultural_activities_frequency', 'total_score', 'status' ] class CompletionConfirmation(Page): pass page_sequence = [PostSurvey, CompletionConfirmation]