from otree.api import * c = Currency doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'public_goods_templates' players_per_group = 2 num_rounds = 1 investments_factor = 1.5 budget = 10 class Subsession(BaseSubsession): pass class Group(BaseGroup): total_contribution = models.FloatField() total_profit = models.FloatField() class Player(BasePlayer): contribution = models.FloatField(min=0, max=Constants.budget, label="How much do you want to invest?") guess_contribution_other = models.FloatField(min=0, max=Constants.budget, label="How much do you think the others will invest?") # PAGES class Contribution(Page): form_model = "player" form_fields = ["contribution", "contribution_other"] class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): total_contribution = 0 for player in self.group.get_players(): total_contribution += player.contribution self.group.total_contribution = total_contribution self.group.total_profit = total_contribution * Constants.investments_factor class Results(Page): def vars_for_template(self): self.player.payoff = (Constants.budget -self.player.contribution) + self.group.total_profit / Constants.players_per_group list_of_contributions = [self.player.contribution] for player in self.player.get_others_in_group(): list_of_contributions.append(player.contribution) return{ "list_of_contributions": list_of_contributions, } page_sequence = [Contribution, ResultsWaitPage, Results]