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 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): take_survey = models.BooleanField() random_pay = models.IntegerField() pay = models.FloatField() round_to_pay = models.StringField() otherplat = models.IntegerField(choices=[[1, 'Yes'], [0, 'No']], widget=widgets.RadioSelect, label='1. Do you rely on other platforms similar to Fiverr to work?') nonplatjob = models.IntegerField(choices=[[1, 'Yes'], [0, 'No']], widget=widgets.RadioSelect, label='2. Do you currently have another job non-related to platforms?') hoursplat = models.IntegerField( label='3. How many hours per week do you usually work at Fiverr and similar platforms? (Please type a number)', min=0, max=100) hoursall = models.IntegerField(label='4. How many hours per week do you usually work on all your jobs? (If you do not have off-platform jobs, please repeat the number above)', 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='5. How long have you used platforms for work purposes?') future = models.IntegerField(choices=[[1, 'Yes'], [2, 'No'],], widget=widgets.RadioSelect, label='6. Do you see yourself continuing to use Fiverr (or another platform) for work one year from now?') 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='8. Please select the reason that best explains why you work for Fiverr.') advantage = models.StringField( label='9. In your opinion, what is the main advantage of working for Fiverr and online platforms in general?') disadvantage = models.StringField( label='10. In your opinion, what is the main disadvantage of working for Fiverr and online platforms in general?') fiverrcat = models.StringField( choices=['Business', 'Data', 'Digital Marketing', 'Graphics and Design', 'Lifestyle', 'Music and Audio', 'Programming and Tech', 'Video and Animation', 'Writing and Translation'], label="11. Under which Fiverr category do you have your gig listed?", widget=widgets.RadioSelect ) age = models.IntegerField(label='12. What is your age?', min=10, max=125) gender = models.IntegerField( choices=[[0, 'Male'], [1, 'Female'], [2, 'Other'] ], label='13. What is your gender?', widget=widgets.RadioSelect, ) race = models.IntegerField( choices=[[1, 'White (non-latino)'], [2, 'Black (non-latino)'], [3, 'Asian (non-latino)'], [4, 'American Indian or Alaska Native (non-latino)'], [5, 'Latino'], [6, 'None of the above']], label='14. 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='15. What is your highest educational attainment?', widget=widgets.RadioSelect, ) married = models.IntegerField(choices=[[1, 'Married / living with partner'], [2, 'Widowed'], [3, 'Divorced / separated'], [4, 'Never married']], widget=widgets.RadioSelect, label='16. What is your marital status?') hhsize = models.IntegerField(label='17. Including yourself, how many people live in your house?', min=0, max=20) child = models.IntegerField(choices=[[1, 'Yes'], [2, 'No']], widget=widgets.RadioSelect, label='17. Are there any children ages 0 to 15 living with you?') followup = models.IntegerField(choices=[[1, 'Yes'], [2, 'No']], widget=widgets.RadioSelect, label="18. Would you be interested in participating in a follow-up interview as part of this study?", ) email = models.StringField( label='19. If you would like to keep posted on the results of this study in the future, please type your email below. Otherwise, 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 # PAGES class AIntro(Page): # form_model = 'player' # form_fields =['take_survey'] pass class BSurvey_plat(Page): form_model = 'player' form_fields = ['otherplat', 'nonplatjob', 'hoursplat', 'hoursall', 'lenghtplat', 'future', 'reason', 'advantage', 'disadvantage', 'fiverrcat' ] # def is_displayed(player): # return player.take_survey == True class CSurvey_demog(Page): form_model = 'player' form_fields = ['age', 'gender', 'race', 'educ', 'married', 'child', 'followup', 'email'] def before_next_page(player, timeout_happened): player.random_pay = random.choice(range(1, 4)) participant = player.participant if player.random_pay == 1: player.round_to_pay = 'Earnings_1' if player.random_pay == 2: player.round_to_pay = 'Earnings_2' if player.random_pay == 3: player.round_to_pay = 'Earnings_3' if player.random_pay == 4: player.round_to_pay = 'Earnings_mpl' participant.round_to_pay = player.round_to_pay # class ResultsWaitPage(WaitPage): # after_all_players_arrive = 'set_payoffs' # def before_next_page(player, timeout_happened): # set_payoffs(player) class DResults(Page): form_model = 'player' form_fields = ['random_pay', 'pay'] page_sequence = [AIntro, BSurvey_plat, CSurvey_demog, DResults]