from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import re import random author = 'Miguel Alberto Gomez' doc = """ This is the Models page of the project that provides the basic structure of the experimental instrument. """ class Constants(BaseConstants): name_in_url = 'survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): # Generate treatment groups for p in self.get_players(): p.survey_initial = random.choice([True, False]) p.capability = random.choice([True, False]) p.perspective = random.choice([True, False]) p.culture = random.choice([True, False]) class Group(BaseGroup): pass class Player(BasePlayer): # # Legal # # consent = models.BooleanField( choices=[ [True, 'Yes'], [False, 'No'] ], widget=widgets.RadioSelectHorizontal ) # # Treatment Variables # # # Survey Order survey_initial = models.BooleanField() # Completion Flag scenario_completed = models.BooleanField(initial=False) # Cyber Capabilities Treatment (0 - Control; 1 - Uncertainty; 2 - Certainty) capability = models.IntegerField() # Empathy Treatment perspective = models.BooleanField() # Role Conception Treatment (0 - Control; 1 - Passive; 2 - Aggressive) culture = models.IntegerField() # # Demographic Variables # # # Browser browser = models.StringField() # Participant Age age = models.IntegerField() # Participant Gender gender = models.StringField( choices=['Male', 'Female', 'Transgender Male', 'Transgender Female', 'Other Gender Variant'], ) # Participant Education education = models.StringField( choices=['High School Degree', 'Bachelors Degree', 'Masters Degree', 'Doctoral Degree', 'Rather not say'], ) # Participant Political Science Education political = models.BooleanField( choices=[ [True, 'Yes'], [False, 'No'] ], widget=widgets.RadioSelectHorizontal) # Participant Computer Science Education computer = models.BooleanField( choices=[ [True, 'Yes'], [False, 'No'] ], widget=widgets.RadioSelectHorizontal) # Participant Income Range income = models.IntegerField( choices=[ [1, 'Less than 10,000 USD'], [2, '10,000 – 19,999 USD'], [3, '20,000 – 29,999 USD'], [4, '30,000 – 39,999 USD'], [5, '40,000 – 49,999 USD'], [6, '50,000 – 59,999 USD'], [7, '60,000 – 69,999 USD'], [8, '70,000 – 79,999 USD'], [9, '80,000 – 89,999 USD'], [10, '90,000 – 99,999 USD'], [11, 'More than 100,000 USD'], ] ) # Power Outage Experience outage = models.BooleanField( choices=[ [True, 'Yes'], [False, 'No']], widget=widgets.RadioSelectHorizontal ) # # Covariates # # # Participant World View world = models.FloatField() # Participant Risk Preference risk = models.FloatField() # Participant Cyber Security Knowledge knowledge = models.FloatField() # Participant Empthay (Perspective Taking) Pre-Disposition empathy = models.FloatField() # # Open-Ended Responses # # # Choice Explanation Response reason = models.LongStringField() # # Outcome Variables # # # Policy Choice endorse = models.BooleanField() def endorse_choices(self): choices=[[True, 'Yes'], [False, 'No']] random.shuffle(choices) return choices # # Checks # # attention = models.IntegerField() # Balance of Power Recognition capability_check = models.IntegerField() # Preference Recognition culture_check = models.IntegerField()