import random from otree.api import * doc = """ Your app description """ class Subsession(BaseSubsession): pass class Constants(BaseConstants): name_in_url = 'RFT' players_per_group = None num_rounds = 1 blue_bonus = 0.05 yellow_bonus = 0.10 class Group(BaseGroup): pass class Player(BasePlayer): # Choice RFT_balls_in_blue = models.IntegerField(min=0, max=20) RFT_balls_in_yellow = models.IntegerField(min=0, max=20) def set_payoffs(player: Player): player.payoff = (player.RFT_balls_in_blue * Constants.blue_bonus) + (player.RFT_balls_in_yellow * Constants.yellow_bonus) player.participant.vars['RFT_balls_in_blue'] = player.RFT_balls_in_blue player.participant.vars['RFT_balls_in_yellow'] = player.RFT_balls_in_yellow player.participant.vars['RFT_profit'] = player.payoff class Page1(Page): pass class Page2(Page): pass class Page3(Page): form_model = 'player' form_fields = ['RFT_balls_in_blue', 'RFT_balls_in_yellow'] def before_next_page(player, timeout_happened): player.payoff = (player.RFT_balls_in_blue * Constants.blue_bonus) + ( player.RFT_balls_in_yellow * Constants.yellow_bonus) class Results(Page): def vars_for_template(player: Player): return dict(blue=player.RFT_balls_in_blue, yellow=player.RFT_balls_in_yellow, payoff=player.payoff) page_sequence = [Page2, Page3, Results]