import random from otree import session from otree.api import ( models, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) author = 'BaiLu' doc = """ Payment information for the whole experiment """ class Constants(BaseConstants): name_in_url = 'payment_info' players_per_group = None num_rounds = 1 belief_error = 0 token_per_RMB = 3 class Subsession(BaseSubsession): treatment = models.FloatField() def creating_session(self): if self.session.config['treatment'] == 'Baseline': self.session.vars['treatment'] = 1 elif self.session.config['treatment'] == 'SocialScore': self.session.vars['treatment'] = 2 elif self.session.config['treatment'] == 'SocialScorePunish': self.session.vars['treatment'] = 3 elif self.session.config['treatment'] == 'SocialScorePunishRank': self.session.vars['treatment'] = 4 self.treatment = self.session.vars['treatment'] class Group(BaseGroup): pass class Player(BasePlayer): final_payoff = models.CurrencyField() def set_final_payoff(self): if self.session.vars['treatment'] == 1: self.final_payoff = float(self.participant.vars['total_payoff_trans'])/Constants.token_per_RMB + \ int(self.session.config['participation_fee']) + \ self.participant.vars['crt_payoff_trans'] + \ self.participant.vars['ravens_payoff_trans'] elif self.session.vars['treatment'] != 1: self.final_payoff = float(self.participant.vars['total_payoff_trans'])/Constants.token_per_RMB + \ int(self.session.config['participation_fee']) + \ self.participant.vars['crt_payoff_trans'] + \ self.participant.vars['ravens_payoff_trans'] + \ self.participant.vars['belief_payoff_trans']