from otree.api import * doc = """ demographic survey and payoff settings """ class Constants(BaseConstants): name_in_url = 'communication_survey_set_finalpayoff' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField( label='What is your age?', min=18, max=100) gender = models.StringField( choices=['Male', 'Female', 'Other'], label='What is your gender?', widget=widgets.RadioSelect) citizenship = models.StringField( label='What is your country(s) of citizenship?') major = models.StringField( label='What is your major?') year = models.StringField( choices=['Freshman', 'Sophomore', 'Junior', 'Senior', 'Graduate', 'Other'], label='Which year are you in?', widget=widgets.RadioSelect) risk = models.StringField( choices=['Strongly Disagree', 'Disagree', 'Slightly Disagree', 'Slightly Agree', 'Agree', 'Strongly Agree'], label='You are a person who is fully prepared to take risks.', widget=widgets.RadioSelect) trust = models.StringField( choices=['Most people can be trusted', 'I need to be very careful in dealing with people'], label='Generally speaking, would you say that most people can be trusted or that you need to be very careful in dealing with people?', widget=widgets.RadioSelect) name = models.StringField(initial=None, label="To link with your payments, please type your G-number below. Note that your identity will be confidential. " ) decision3 = models.LongStringField(initial=None, label="How many points did you choose to invest into the private project on average? Why? ") decision4 = models.LongStringField(initial=None, label="Did you think of investing a different amount into the private project? Why? ") comments = models.LongStringField(blank=True, initial=None, label="Do you have any comments, questions, or complaints about today's experiment?") All_money=models.FloatField(initial=0.0) # PAGES class Survey(Page): @staticmethod def is_displayed(player: Player): return player.round_number == Constants.num_rounds form_model = 'player' form_fields = ['name', 'age', 'gender', 'citizenship', 'major', 'year', 'risk', 'trust'] class Comment(Page): @staticmethod def is_displayed(player: Player): return player.round_number == Constants.num_rounds form_model = 'player' form_fields = [ 'decision3', 'decision4', 'comments'] def before_next_page(player: Player, timeout_happened): ## calculate total payoff of the experiment participant = player.participant player.All_money = participant.payoff_money+participant.social_payoff+participant.risk_payoff+participant.loss_payoff+participant.ambiguity_payoff+participant.CRT_payoff+10 participant.vars['All_money']=player.All_money class End_game(Page): @staticmethod #def is_displayed(player: Player): # return player.round_number == Constants.num_rounds def vars_for_template(player:Player): participant = player.participant return dict( round_to_pay_shown=participant.round_to_pay - 5, ) page_sequence = [Survey, Comment, End_game]