from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from math import floor author = 'Wang Song' doc = """ Survey and Payment Info """ class Constants(BaseConstants): name_in_url = 'survey' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): def set_payoff(self): self.payoff = 0 total_payoff = self.participant.vars['game1_payoff'] + self.participant.vars['game2_payoff'] + self.participant.vars['game3_payoff'] if self.participant.payoff != total_payoff: print("ERROR: participant.payoff=", self.participant.payoff, "; total_payoff=", total_payoff) if total_payoff - floor(total_payoff) >= 0.5: self.participant.payoff = floor(total_payoff) + 1 else: self.participant.payoff = floor(total_payoff) q_gender = models.IntegerField( blank=True, choices=[ [1, 'Male'], [2, 'Female'], ], widget=widgets.RadioSelect, label='What is your gender? ' ) q_age = models.IntegerField( blank=True, label='What is your age? ' ) q_nationality = models.StringField( blank=True, label='What is your nationality? ' ) q_year_of_study = models.IntegerField( blank=True, choices=[ [1, 'Year 1'], [2, 'Year 2'], [3, 'Year 3'], [4, 'Year 4'], [5, 'Masters'], [6, 'Ph.D'], [7, 'Others'], ], widget=widgets.RadioSelect, label='Which year are you in? ' ) q_major = models.StringField( blank=True, label='What is your major? ' ) q_activity1 = models.IntegerField( blank=True, choices=[ [1, 'Active member'], [2, 'Inactive member'], [3, 'Not a member'] ], widget=widgets.RadioSelect, label='a) Humanitarian, charity, social work activity/organization: ' ) q_activity2 = models.IntegerField( blank=True, choices=[ [1, 'Active member'], [2, 'Inactive member'], [3, 'Not a member'] ], widget=widgets.RadioSelect, label='Religious activity/organization: ' ) q_activity3 = models.IntegerField( blank=True, choices=[ [1, 'Active member'], [2, 'Inactive member'], [3, 'Not a member'] ], widget=widgets.RadioSelect, label='Environment, nature, animal protection activity/organization: ' ) q_religion = models.StringField( blank=True, label='Could you indicate your religion?' ) q_religion_importance = models.IntegerField( blank=True, choices=[ 0, 1, 2, 3, 4, 5, 6, 7, ], widget=widgets.RadioSelectHorizontal, label='How important is your religion to you? (of a scale from 1 to 7, indicate 0 if you do not have any religion.)' ) q_lost_wallet = models.IntegerField( blank=True, choices=[ 0, 1, 2, 3, 4, 5, 6, 7, ], widget=widgets.RadioSelectHorizontal, label='If you lost your wallet on campus, how likely do you think you would have it returned? ' ) q_HOTA = models.IntegerField( blank=True, choices=[ [1, 'Yes'], [0, 'No'], ], widget=widgets.RadioSelect, label='Are you aware of the Human Organ Transplant Act (HOTA) in Singapore? ' ) q_understand_exp = models.IntegerField( blank=True, choices=[ 1, 2, 3, 4, 5, ], widget=widgets.RadioSelectHorizontal, label='On a scale of 1 to 5, rate whether you understand this experiment or not: ' ) q_understand_ins = models.IntegerField( blank=True, choices=[ 1, 2, 3, 4, 5, ], widget=widgets.RadioSelectHorizontal, label='On a scale of 1 to 5, how well do you understand the instructions: ' ) q_donation_reason = models.LongStringField( blank=True, label='If you have ever donated your B units, describe briefly your reason. If you never donated, explain briefly why.' )