from otree.api import * c = cu doc = '' class C(BaseConstants): # built-in constants NAME_IN_URL = 'TX_entrenamiento' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 # user-defined constants TX_TRAIN = 0.2 AUDIT_TRAIN = 1.5 TASA_TRAIN = '20%' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): income_0 = models.IntegerField(label='¿Cuál fue el su ingreso a declarar?', min=0) Pregunta_Verificacion_1 = models.IntegerField(label='¿Cuál es la probabilidad de auditoria? (No incluya el porcentaje - Solo número)') Pregunta_Verificacion_2 = models.IntegerField(label='¿Cuál es la tasa de penalidad sobre el impuesto no pagado en caso de auditoria?(No incluya el porcentaje - Solo número)') def custom_export(players): yield ['participant_code', 'id_in_group'] for p in players: pp = p.participant yield [pp.code, p.id_in_group] class Declaracion_Entrenamiento(Page): form_model = 'player' form_fields = ['income_0'] @staticmethod def error_message(player: Player, values): if values['income_0'] > 4000: return "El Ingreso Declarado NO puede ser mayor al Ingreso Ganado" class Pago_entrenamiento(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): return dict( tx_0= (player.income_0 * C.TX_TRAIN) ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.Income_declarado_0= player.income_0 participant.CTX_TRAIN= C.TX_TRAIN participant.TX_TRAIN= player.income_0 * C.TX_TRAIN participant.subdeclara_r0=4000-player.income_0 participant.sancion_r0= int(1.5 * 0.2 * (4000-player.income_0)) class Auditoria_Entrenamiento(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( sancion_r0= int(1.5 * 0.2 * participant.subdeclara_r0), tx_0= int(player.income_0 * 0.2), pago_entrena_audit=int(4000-participant.TX_TRAIN-participant.sancion_r0), pago_entrena = int(4000-participant.TX_TRAIN) ) class Preguntas_Verificacion(Page): form_model = 'player' form_fields = ['Pregunta_Verificacion_1', 'Pregunta_Verificacion_2'] @staticmethod def error_message(player: Player, values): if values['Pregunta_Verificacion_1'] != 10: return "La probabilidad de auditoria es del 10%" if values['Pregunta_Verificacion_2'] != 150: return "La sanción sobre el impuesto no pagado es de 150%" class Fin_entrenamiento(Page): form_model = 'player' page_sequence = [Declaracion_Entrenamiento, Pago_entrenamiento, Auditoria_Entrenamiento, Preguntas_Verificacion, Fin_entrenamiento]