from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, Page, WaitPage, ) import random import json doc = """ This is a post-experiment survey for the Valuing flexibility study """ class Constants(BaseConstants): name_in_url = 'survey_fiverr' players_per_group = None num_rounds = 1 survey_bonus = 200 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): take_survey = models.BooleanField() mainjob = models.IntegerField(choices=[[1, 'Yes'], [0, 'No']], widget=widgets.RadioSelect, label='1. Do you consider your work in Fiverr as your main job?') otherplat = models.IntegerField(choices=[[1, 'Yes'], [0, 'No']], widget=widgets.RadioSelect, label='2. Do you rely on other platforms similar to Fiverr to work?') nonplatjob = models.IntegerField(choices=[[1, 'Yes'], [0, 'No']], widget=widgets.RadioSelect, label='3. Do you currently have another job non-related to platforms?') hoursplat = models.IntegerField(label='4. How many hours per week do you usually work at Fiverr and other platforms (if any)?', min=0, max=100) hoursall = models.IntegerField(label='5. How many hours per week do you usually work on all your jobs?', min=0, max=100) lenghtplat= models.IntegerField(choices=[[1, 'Less than a month'], [2, 'Between one and six months'], [3, 'Between six months and one year'], [4, 'More than one year']], widget=widgets.RadioSelect, label='6. How long have you worked for platforms?') future = models.IntegerField(choices=[[1, 'Yes'], [2, 'No']], widget=widgets.RadioSelect, label='7. Do you see yourself working for Fiverr or another platform one year from now?') incshare = models.IntegerField(choices=[[1, 'Less than 25%'], [2, 'Between 26% and 50%'], [3, 'Between 51% and 75%'], [4, 'More than 76%']], widget=widgets.RadioSelect, label='8. How much would you say that platform income represents in your total income?') reason = models.IntegerField(choices=[[1, 'To be my own boss'], [2, 'I would like to work more hours than allowed in my other job'], [3, 'To supplement income on a regular basis'], [4, 'To supplement income temporarily basis or for a specific purpose'], [5, 'To vary the type of task that I do for work'], [6, 'Other']], widget=widgets.RadioSelect, label='9. Please select the reason that best explains why you work for Fiverr.') advantage = models.StringField( label='10. In your opinion, what is the main advantage of working for Fiverr and online platforms in general?') disadvantage = models.StringField( label='11. In your opinion, what is the main disadvantage of working for Fiverr and online platforms in general?') age = models.IntegerField(label='12. What is your age?', min=10, max=125) gender = models.IntegerField( choices=[[0, 'Male'], [1, 'Female']], label='13. What is your sex?', widget=widgets.RadioSelect, ) race = models.IntegerField( choices=[[1, 'White (non-latino)'], [2, 'Black (non-latino)'], [3, 'Asian (non-latino)'], [4, 'Latino'], [5, 'Other (non-latino)']], label='13. What is your race?', widget=widgets.RadioSelect, ) educ = models.IntegerField( choices=[[1, 'Incomplete High School or Less'], [2, 'High School Degree'], [3, 'Some College'], [4, 'Bachelors degree'], [5, 'Graduate degree']], label='14. What is your highest educational attainment?', widget=widgets.RadioSelect, ) state = models.IntegerField( choices=[[1, 'Alabama'], [2, 'Alaska'], [4, 'Arizona'], [5, 'Arkansas'], [6, 'California'], [8, 'Colorado'], [9, 'Connecticut'], [10, 'Delaware'], [11, 'District of Columbia'], [12, 'Florida'], [13, 'Georgia'], [15, 'Hawaii'], [16, 'Idaho'], [17, 'Illinois'], [18, 'Indiana'], [19, 'Iowa'], [20, 'Kansas'], [21, 'Kentucky'], [22, 'Louisiana'], [23, 'Maine'], [24, 'Maryland'], [25, 'Massachusetts'], [26, 'Michigan'], [27, 'Minnesota'], [28, 'Mississippi'], [29, 'Missouri'], [30, 'Montana'], [31, 'Nebraska'], [32, 'Nevada'], [33, 'New Hampshire'], [34, 'New Jersey'], [35, 'New Mexico'], [36, 'New York'], [37, 'North Carolina'], [38, 'North Dakota'], [39, 'Ohio'], [40, 'Oklahoma'], [41, 'Oregon'], [42, 'Pennsylvania'], [44, 'Rhode Island'], [45, 'South Carolina'], [46, 'South Dakota'], [47, 'Tennessee'], [48, 'Texas'], [49, 'Utah'], [50, 'Vermont'], [51, 'Virginia'], [53, 'Washington'], [54, 'West Virginia'], [55, 'Wisconsin'], [56, 'Wyoming']], label="15. In which state do you live?", ) followup = models.StringField( label="15. Would you be interested in participating in a follow-up interview as part of this study? If yes, please type your email. If no, please type 'No'.", ) # FUNCTIONS def creating_session(subsession): print('in creating session') # Player chooses if taking survey for player in subsession.get_players(): player.payoff_survey = 0 def set_payoffs(player): if player.take_survey: player.payoff_survey = Constants.survey_bonus else: player.payoff_survey = 0 # PAGES class Intro(Page): form_model = 'player' form_fields =['take_survey'] class Survey_plat(Page): form_model = 'player' form_fields = ['mainjob', 'otherplat', 'nonplatjob', 'hoursplat', 'hoursall', 'lenghtplat', 'future', 'reason', 'incshare', 'advantage', 'disadvantage', ] def is_displayed(player): return player.take_survey == True class Survey_demog(Page): form_model = 'player' form_fields = ['age', 'gender', 'race', 'educ', 'followup', 'state'] def is_displayed(player): return player.take_survey == True # class ResultsWaitPage(WaitPage): # after_all_players_arrive = 'set_payoffs' # def before_next_page(player, timeout_happened): # set_payoffs(player) class Results(Page): pass page_sequence = [Intro, Survey_plat, Survey_demog, Results]