from otree.api import * c = cu doc = '' class Constants(BaseConstants): name_in_url = 'Dictador_Da' players_per_group = None num_rounds = 1 Dotacion = cu(10) errores = 20 premio = cu(5000) instructions_template = 'Dictador_Da/instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass def upset_payoff(player): player.payoff = player.dec1 class Player(BasePlayer): my_field = models.IntegerField() dec1 = models.CurrencyField() dec2 = models.CurrencyField() dec3 = models.CurrencyField() Errores = models.IntegerField(label='¿Cuantos errores encontrĂ³?') upset_payoff = upset_payoff class Noticia(Page): form_model = 'player' form_fields = ['Errores'] class Decision1(Page): form_model = 'player' form_fields = ['dec1'] class Decision2(Page): form_model = 'player' form_fields = ['dec2'] class Decision3(Page): form_model = 'player' form_fields = ['dec3'] class Resultados(Page): form_model = 'player' @staticmethod def before_next_page(player, timeout_happened): participant = player.participant pagos= [player.dec1,player.dec2,player.dec3] import random if player.Errores == Constants.errores: participant.payoff = random.choice (pagos) + Constants.premio if player.Errores != Constants.errores: participant.payoff = random.choice (pagos) class Pagofinal(Page): form_model = 'player' page_sequence = [Noticia, Decision1, Decision2, Decision3, Resultados, Pagofinal]