from otree.api import * doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'live_page_accept_offer' players_per_group = None num_rounds = 1 endownment = 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" ] # live page that... @staticmethod def live_method(player: Player, data): #recieve information from javascript page and send it back to Python player if data["information_type"] == "offer": # distinquish between offer and accept/decline response by checking if the information type is an offer if player.id_in_group == 1: # if offer came from player 1 return {2: {"information_type": "offer", "offer": data["offer"]}} #return something to player 2 else: return {1: {"information_type": "offer", "offer": data["offer"]}} #return something to player 1 else: if data["information_type"] == "response": # if the information type is accept/decline response if player.id_in_group == 1: # if offer came from player 1 return {2: {"information_type": "response", "response": data["offer_response"]}} #return something to player 2 else: return {1: {"information_type": "response", "response": data["offer_response"]}} #return something to player 2 class Results(Page): pass page_sequence = [MyPage, Results]