from otree.api import * import random doc = """ """ class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 CONSENTS_TEMPLATE = 'survey/ConsentTemplate.html' INSTRUCTIONS_IND_TASK_ONE = 'survey/IndividualTaskTemplate.html' INSTRUCTIONS_COL_TASK_ONE = 'survey/CollaborativeTaskTemplate.html' # NOT USING INSTRUCTIONS_TEMPLATE = 'survey/instructions.html' INSTRUCTIONS_ONE = 'survey/instructionsONE.html' INSTRUCTIONS_TWO = 'survey/instructionsTWO.html' INSTRUCTIONS_THREE = 'survey/instructionsTHREE.html' IMAGE_INST_ONE = 'images/instructionsONE.png' IMAGE_INST_TWO = 'images/instructionsTWO.png' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): gives_consent = models.BooleanField() prolific_id = models.StringField(label="Enter your Prolific ID:") 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() # PAGES class Consent(Page): form_model = 'player' form_fields = ['gives_consent'] class Education(Page): # timeout_seconds = 300 form_model = 'player' form_fields = ['politicalAffiliation', 'prolific_id'] @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' if timeout_happened: participant.dropped = True else: participant.dropped = False class IndividualTaskOverview(Page): pass class CollaborativeTaskOverview(Page): pass page_sequence = [Consent, Education, IndividualTaskOverview, CollaborativeTaskOverview]