from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'exit_survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): gender = models.StringField(choices=[['Male', 'Male'], ['Female', 'Female'], ['Non-Binary', 'Non-Binary'], ['prefer not to say', 'Prefer not to say']], label='What is your gender?', widget=widgets.RadioSelect) education = models.StringField(choices=[['High school', 'High school'], ['Apprenticeship', 'Apprenticeship'], ["Bachelor's degree", "Bachelor's degree"], ["Master's degree", "Master's degree"], ['PhD', 'PhD'], ['Other', 'Other'], ['prefer not to say', 'Prefer not to say']], label='What is the highest level of education you have completed?', widget=widgets.RadioSelect) experience = models.BooleanField(choices=[[True, 'Yes'], [False, 'No']], label='Have you participated in economic or social experiments before?', widget=widgets.RadioSelect) understanding = models.IntegerField(choices=[[1, 'Very Poor'], [2, 'Poor'], [3, 'Medium'], [4, 'Good'], [5, 'Very Good']], label='How would you describe your understanding of the rules of the experiment?', widget=widgets.RadioSelect) informed = models.BooleanField(choices=[[True, 'Yes'], [False, 'No']], label='Did you feel adequately informed about the objectives and rules of the experiment?', widget=widgets.RadioSelect) age = models.StringField(choices=[['younger than 18', 'Younger than 18'], ['18-25', '18-25'], ['26-30', '26-30'], ['31-35', '31-35'], ['36-40', '36-40'], ['older than 40', 'Older than 40'], ['prefer not to say', 'Prefer not to say']], label='What is your age?', widget=widgets.RadioSelect) course = models.BooleanField(choices=[[True, 'Yes'], [False, 'No']], label='Did you ever have a (university) course on game theory?') class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'education'] class Reflection(Page): form_model = 'player' form_fields = ['experience', 'course', 'informed', 'understanding'] class End_Page(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): participant = player.participant # Access the stored payoff from the participant vars selected_payoff = player.participant.payoff # Access the PARTICIPATION_FEE from Constants participation_fee = 5 # Calculate the sum of PARTICIPATION_FEE and selected_payoff total_payoff = player.participant.payoff_plus_participation_fee() return { 'selected_payoff': selected_payoff, 'participation_fee': participation_fee, 'total_payoff': total_payoff, } @staticmethod def js_vars(player: Player): participant = player.participant return dict(p_payoff = player.participant.payoff_plus_participation_fee()) page_sequence = [Demographics, Reflection, End_Page]