from otree.api import * doc = """ One player decides how to divide a certain amount between himself and the other player. See: Kahneman, Daniel, Jack L. Knetsch, and Richard H. Thaler. "FairnessModuleNotFoundError: No module named 'otree' and the assumptions of economics." Journal of business (1986): S285-S300. """ class C(BaseConstants): NAME_IN_URL = 'dictator_sin_recipient' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 INSTRUCTIONS_TEMPLATE = 'dictator_sin_recipient/instructions.html' # Initial amount allocated to the dictator ENDOWMENT = cu(100) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): shared = models.CurrencyField( doc="""Amount dictator decided to share to another""", min=0, max=C.ENDOWMENT, label="How much do you want to send to participant B?" " I will share...", ) # Assigning a random id. Uso string. player_id = models.StringField() # FUNCTIONS def set_payoffs(player: Player): p1 = player.player_id p2 = player.player_id player.kept = C.ENDOWMENT - player.shared p1.payoff = player.kept p2.payoff = player.shared # PAGES class Introduction(Page): pass class Sent(Page): #Digo, PRIMERO, DONDE quiero que me guarde la data. form_model = 'player' #Defino, SEGUNDO, qué inputs (fields) tendran los jugadores. (QUE PREVIAMENTE CREÉ EN "PLAYER CLASS") form_fields = ['shared'] @staticmethod def before_next_page(player: Player, timeout_happened): return { "You have shared:": player.shared, "Recently, another player, same as you, have decided to share:": "0" } class ResultsWaitPage(WaitPage): pass class Results(Page): @staticmethod def vars_for_template(player: Player): result = C.ENDOWMENT - player.shared return { "Result": result } page_sequence = [Introduction, Sent, Results]