import random from otree.api import * class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 PAY_PER_ROUND = cu(15) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass AGREE_CHOICES = ( (1, 'Strongly disagree'), (2, 'Disagree'), (3, 'Somewhat disagree'), (4, 'Neither agree nor disagree'), (5, 'Somewhat agree'), (6, 'Agree'), (7, 'Strongly agree'), ) def make_field(label): return models.IntegerField( choices=AGREE_CHOICES, label=label, widget=widgets.RadioSelect, ) class Player(BasePlayer): # Demograoghics page age = models.IntegerField(label='What is your age?', min=13, max=125) gender = models.IntegerField( choices=[(1, 'Male'), (2, 'Female'), (3, 'Other'), (4, 'Prefer not to say')], label='What is your gender?', widget=widgets.RadioSelect, ) education = models.IntegerField( choices=[ (1, "No formal education"), (2, "Primary education"), (3, "Secondary education"), (4, "GED"), (5, "Vocational qualification"), (6, "Bachelor's degree"), (7, "Master's degree"), (8, "Doctorate or higher"), ], label='What is the highest level of education attained?', widget=widgets.RadioSelect, ) work_experience = models.IntegerField( label='How many years of work experience do you have (in full-time or part-time jobs)?', min=0, max=125 ) perceived_competence = models.IntegerField( label='How do you perceive your competence in the button pressing task?', choices=[(1, 'Very low'), (2, 'Low'), (3, 'Medium'), (4, 'High'), (5, 'Very high')], widget=widgets.RadioSelect, ) strategy = models.IntegerField( label='What strategy do you think is the best way to solve the button pressing task?', choices=[(1, 'I used 2 hands to solve the task'), (2, 'I used 1 hand to solve the task'), (3, 'Other')], widget=widgets.RadioSelect, ) def creating_session(subsession: Subsession): pass class Demographics(Page): form_model = 'player' form_fields = ['age', 'work_experience', 'gender', 'education', 'perceived_competence', 'strategy'] @staticmethod def vars_for_template(player): # Set participant payoff to 0.2 unless self_select_choice is 2 if player.participant.self_select_choice == 2: player.participant.payoff = 0 else: player.participant.payoff = 0.2 return dict() class FinalPage(Page): pass page_sequence = [ Demographics, FinalPage, ]