from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import math author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'closing' players_per_group = None num_rounds = 1 rounding = 0.25 ExpD_to_USD = 50 payoff_message = "In today's activity, you earned %d Credits, which equals %.2f U.S. Dollars. We will pay this amount to you in cash" donations_message = "In today's activity, you generated $%d USD in donations. We will send this money directly to the charities that you selected." class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): def get_payoff_message(self): exp_payoff = self.participant.payoff conversion = exp_payoff / Constants.ExpD_to_USD usd_payoff = conversion + ((math.ceil(conversion) - conversion) % Constants.rounding) return Constants.payoff_message % (exp_payoff, usd_payoff) def get_donations_message(self): return Constants.donations_message % (self.participant.vars['donations'])