from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'recruiting' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 # INSTRUCTIONS_TEMPLATE = 'recruiting/instructions.html' CONSENTS_TEMPLATE = 'recruiting/consents.html' """ SCHEDULE_WEDNESDAY = [ dict(name='wednesday1000', label="Wednesday, November 9th 2022 at 10H00 (10:00 AM) Eastern Standard Time (EST), New York time"), dict(name='wednesday1200', label="Wednesday, November 9th 2022 at 12H00 (12:00 PM) Eastern Standard Time (EST), New York time"), dict(name='wednesday1400', label="Wednesday, November 9th 2022 at 14H00 (2:00 PM) Eastern Standard Time (EST), New York time"), ] """ SCHEDULE_THURSDAY = [ # dict(name='thursday1000', # label="Thursday, November 10th 2022 at 10H00 (10:00 AM) Eastern Standard Time (EST), New York time"), dict(name='thursday1200', label="Thursday, November 10th 2022 at 12H00 (12:00 PM) Eastern Standard Time (EST), New York time"), dict(name='thursday1400', label="Thursday, November 10th 2022 at 14H00 (2:00 PM) Eastern Standard Time (EST), New York time"), dict(name='week1None', label="None of the above.") ] """ SCHEDULE_FRIDAY = [ dict(name='friday1000', label="Friday, November 11th 2022 at 10H00 (10:00 AM) Eastern Standard Time (EST), New York time"), dict(name='friday1200', label="Friday, November 11th 2022 at 12H00 (12:00 PM) Eastern Standard Time (EST), New York time"), dict(name='friday1400', label="Friday, November 11th 2022 at 14H00 (2:00 PM) Eastern Standard Time (EST), New York time"), # dict(name='week1None', label="None of the above.") ] """ class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): prolific_id = models.StringField(label="Please, provide your Prolific ID below") education = models.IntegerField( label="What is the highest level of school you have completed or the highest degree you have received?", choices=[ [1, 'Less than high school degree'], [2, 'High school graduate (high school diploma or equivalent, including GED)'], [3, 'Some college but no degree'], [4, 'Associate degree in college (2-year)'], [5, 'Bachelor\'s degree in college (4-year)'], [6, 'Master\'s degree'], [7, 'Doctoral degree'], [8, 'Professional degree (JD, MD)'], ] ) timeTwitter = models.IntegerField( label="How much time per day do you spend on Twitter?", choices=[ [1, 'Never/no account'], [2, 'Less than 10 minutes'], [3, 'From 10 minutes to 30 minutes'], [4, 'From 30 minutes to 1 hour'], [5, 'More than 1 hour'], ] ) timeNews = models.IntegerField( label="How much time per day do you spend watching, reading or listening to news about politics and current " "affairs?", choices=[ [1, 'Never'], [2, 'Less than 10 minutes'], [3, 'From 10 minutes to 30 minutes'], [4, 'From 30 minutes to 1 hour'], [5, 'More than 1 hour'], ] ) discussPolitics = models.IntegerField( label="How often do you discuss policy issues with your friends or family members on and off social media?", choices=[ [1, 'Frequently'], [2, 'Often'], [3, 'Sometimes'], [4, 'Rarely'], [5, 'Never'], ] ) politicalAffiliation = models.IntegerField( label="How strongly do you identify with either of these two parties?", widget=widgets.RadioSelectHorizontal(), choices=[[1, '1: Strongly Democrat'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10: Strongly Republican'], ] ) is_democrat = models.BooleanField() is_willing = models.BooleanField(label="Will you attend the second part of the study?", choices=[[True, 'Yes, I would like to join in.'], [False, 'No, I do not wish to participate.']], ) # time slot choices """ wednesday1000 = models.BooleanField(blank=True) wednesday1200 = models.BooleanField(blank=True) wednesday1400 = models.BooleanField(blank=True) """ # thursday1000 = models.BooleanField(blank=True) thursday1200 = models.BooleanField(blank=True) thursday1400 = models.BooleanField(blank=True) week1None = models.BooleanField(blank=True) """ friday1000 = models.BooleanField(blank=True) friday1200 = models.BooleanField(blank=True) friday1400 = models.BooleanField(blank=True) week1None = models.BooleanField(blank=True) """ # PAGES class Consent(Page): # timeout_seconds = 300 form_model = 'player' form_fields = ['prolific_id'] class Questions(Page): # timeout_seconds = 300 form_model = 'player' form_fields = ['education', 'timeTwitter', 'timeNews', 'discussPolitics', 'politicalAffiliation'] @staticmethod def before_next_page(player, timeout_happened): participant = player.participant if player.politicalAffiliation < 6: player.is_democrat = True participant.politics = 'Democrat' else: player.is_democrat = False participant.politics = 'Republican' class Willingness(Page): # timeout_seconds = 300 form_model = 'player' form_fields = ['is_willing'] class Timeslots(Page): # timeout_seconds = 300 form_model = 'player' @staticmethod def is_displayed(player: Player): isWilling = player.is_willing return isWilling @staticmethod def get_form_fields(player: Player): return [reason['name'] for reason in C.SCHEDULE_THURSDAY] # return [reason['name'] for reason in C.SCHEDULE_THURSDAY] + [reason['name'] for reason in C.SCHEDULE_FRIDAY] class Results(Page): @staticmethod def js_vars(player): return dict( completionlink= player.subsession.session.config['completionlink'] ) page_sequence = [Consent, Questions, Willingness, Timeslots, Results]