from otree.api import * c = cu doc = 'For this set of rounds, you and all other players, will be given feedback on the total amount that has been contributed to the public good. ' class C(BaseConstants): NAME_IN_URL = 'Public_Good_Feedback' PLAYERS_PER_GROUP = 6 NUM_ROUNDS = 20 ENDOWMENT = cu(100) MULTIPLIER = 1.5 class Subsession(BaseSubsession): pass class Group(BaseGroup): total_contribution = models.CurrencyField() individual_share = models.CurrencyField() def set_payoffs(group: Group): players = group.get_players() contributions = [p.contribution for p in players] group.total_contribution = sum(contributions) group.individual_share = ( group.total_contribution * C.MULTIPLIER / C.PLAYERS_PER_GROUP ) for p in players: p.payoff = C.ENDOWMENT - p.contribution + group.individual_share class Player(BasePlayer): contribution = models.CurrencyField(label='How much will you contribute', max=C.ENDOWMENT, min=0) class Contribute(Page): form_model = 'player' form_fields = ['contribution'] class ResultsWaitPage(WaitPage): pass class Results(Page): form_model = 'player' page_sequence = [Contribute, ResultsWaitPage, Results]