from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'Survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField(label='2. How old are you?', min=13, max=125) gender = models.StringField( choices=[['Male', 'Male'], ['Female', 'Female'], ['Other', 'Other']], label='1. What is your gender?', widget=widgets.RadioSelectHorizontal, ) degree = models.StringField(label="3.What is your highest degree? (Include the one you're studying for) ", choices=['Undergraduate', 'Postgraduate (Taught)', 'Postgraduate (Research)']) school = models.StringField(label="4.Which school are you currently enrolled in?", choices=['CAHSS-Business School', 'CAHSS-School of Divinity', 'CAHSS-School of Economics', 'CAHSS-Edinburgh College of Art', 'CAHSS-Moray House School of Education and Sport', 'CAHSS-School of Health in Social Science', 'CAHSS-School of History, Classics and Archaeology', 'CAHSS-School of Law', 'CAHSS-School of Literatures, Languages and Cultures', 'CAHSS-School of Philosophy, Psychology and Language Sciences', 'CAHSS-School of Social and Political Science', 'CAHSS-Centre for Open Learning', 'CMVM-Edinburgh Medical School', 'CMVM-Royal (Dick) School of Veterinary Studies', 'CSE-School of Biological Sciences', 'CSE-School of Chemistry', 'CSE-School of Engineering', 'CSE-School of GeoSciences', 'CSE-School of Informatics', 'CSE-School of Mathematics', 'CSE-School of Physics and Astronomy' ]) # PAGES class MyPage(Page): form_model = "player" form_fields = ['gender', 'age', 'degree', 'school'] class Results(Page): @staticmethod def vars_for_template(player: Player): CRT_result = player.participant.vars.get('CRT_result', 0) payoff_main = player.participant.vars.get('payoff_main', 0) # Corrected to fetch from vars payoff_rev = player.participant.vars.get('payoff_rev', 0) # Corrected to fetch from vars total_payment = payoff_main + payoff_rev pounds=total_payment/4+4 + CRT_result*0.5 outcomes_dict = player.participant.outcomes_dict return { 'CRT_result': CRT_result, 'payoff_main': payoff_main, 'payoff_rev': payoff_rev, 'total_payment': total_payment, 'pounds':pounds, 'outcomes_dict': outcomes_dict } page_sequence = [MyPage, Results]