from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'live_page_accept_offer' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 endowment = 100 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): money_after_trade = models.FloatField() accepted_other_participants_offer = models.BooleanField() # PAGES class MyPage(Page): form_model = "player" form_fields = ["money_after_trade", "accepted_other_participants_offer"] @staticmethod def live_method(player: Player, data): """ we want to distinguish between the two types of information we get from the Page. That is, between the offer made and acceptance/rejection of the offer. """ if data["information_type"] == "offer": if player.id_in_group == 1: return {2: {"information_type": "offer", "offer": data["offer"]}, 1: "Your offer was sent."} else: return {1: {"information_type": "offer", "offer": data["offer"]}, 2: "Your offer was sent."} else: """ if data["information_type"] == "response": if player.id_in_group == 1: return {2: {"information_type": "response", "response": data["offer_response"]}} else: return {1: {"information_type": "response", "response": data["offer_response"]}} """ if player.id_in_group == 1: return {2: {"information_type": "response", "response": data["offer_response"]}} else: return {1: {"information_type": "response", "response": data["offer_response"]}} class Results(Page): pass page_sequence = [MyPage, Results]