from otree.api import * import random doc = """ App to recruit participants for dissertation experiment """ class C(BaseConstants): NAME_IN_URL = 'recruiter2023' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 # max_reward = 35 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass # category = models.IntegerField() class Player(BasePlayer): consent = models.BooleanField( choices=[[1, 'I agree']], label=" ", widget=widgets.RadioSelect ) reliance = models.IntegerField( choices=[[1, 'Very important (more than 75% of my basic family expenses)'], [2, 'Important (between 50% and 74% of my basic family expenses)'], [3, 'Moderately important (between 25% and 49% of my basic family expenses)'], [4, 'Slightly important (between 0% and 24% of my basic family expenses)']], label='1. Consider the earnings received from Fiverr (and other similar online platforms) in the past 30 days. Which of the following alternatives best describes how important are these earnings to cover your basic family expenses?', widget=widgets.RadioSelect, ) # reliance = models.BooleanField( # choices=[[1, 'Yes'], # [2, 'No']], # label='Thinking about the past 30 days, would you say the earnings obtained from Fiverr (or other similar platforms) are essential to cover your basic family expenses?', # widget=widgets.RadioSelect, # ) # mainjob = models.BooleanField( # choices=[[1, 'Yes'], [2, 'No']], # label="Thinking about the past 30 days, do you consider the work obtained from online platforms (Fiverr and similar) as your main job?", # widget=widgets.RadioSelect # ) pref = models.IntegerField( choices=[[1, 'I want to choose my time slot now'], [2, 'Give me a random time slot (this option adds a $5.00 bonus to your final reward)'], [3, 'I want to participate at any time (this option reduces $5.00 from your final reward)']], label="Please, select your preferred option:", widget = widgets.RadioSelect ) state = models.StringField( choices=['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming', 'Other'], label="In which state do you live?" ) timezone = models.StringField( choices=['Eastern', 'Central', 'Mountain', 'Pacific', 'Pacific (Arizona)', 'Hawaiian', 'Alaskan'], label="2. Please, select your time zone.", widget=widgets.RadioSelect ) 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="3. Under which Fiverr category do you have your gig listed?", widget=widgets.RadioSelect ) slot = models.StringField( choices=['9:30 am to 10:30 am', '10:45 am to 11:45 am', '2:30 pm to 3:30 pm', '3:45 pm to 4:45 pm', '7:00 pm to 8:00 pm', '8:15 pm to 9:15 pm'], label="Available times", widget=widgets.RadioSelect ) slot2 = models.StringField() slot3 = models.StringField() earnings_pt1 = models.IntegerField(label='Earnings from Part 1') # FUNCTIONS def set_payoffs(player): if player.pref==1: player.earnings_pt1=0 if player.pref==2: player.earnings_pt1=(5) if player.pref==3: player.earnings_pt1=(-5) # PAGES class AConsent(Page): form_model = 'player' form_fields = ['consent'] class BReliance(Page): form_model = 'player' form_fields = ['reliance', 'timezone'] @staticmethod def before_next_page(player, timeout_happened): participant = player.participant participant.timezone = player.timezone if player.reliance < 3: participant.reliance = 1 else: participant.reliance = 2 class CSelectSlot(Page): form_model = 'player' form_fields = ['pref'] @staticmethod def before_next_page(player, timeout_happened): if player.pref==2: player.slot2 = random.choice([ '9:30 am to 10:30 am', '10:45 am to 11:45 am', '2:30 pm to 3:30 pm', '3:45 pm to 4:45 pm', '7:00 pm to 8:00 pm', '8:15 pm to 9:15 pm' ]) else: player.slot2 = ' ' if player.pref==3: player.slot3 = '9:30 am to 9:15 pm' else: player.slot3 = ' ' set_payoffs(player) participant = player.participant participant.earnings_pt1 = player.earnings_pt1 class ResultsWaitPage(WaitPage): pass class DChoosenow(Page): form_model = 'player' form_fields = ['slot'] def is_displayed(player): return player.pref == 1 class EEnd(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): participant = player.participant if player.pref == 1: participant.slot = player.slot if player.pref==2: participant.slot = player.slot2 if player.pref==3: participant.slot = player.slot3 page_sequence = [AConsent, BReliance, CSelectSlot, DChoosenow, EEnd]