from otree.api import * c = cu doc = '' class C(BaseConstants): # built-in constants NAME_IN_URL = 'Participacion_Defensa' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): R1 = models.IntegerField(choices=[[70, '70%'], [35, '35%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R2 = models.IntegerField(choices=[[45, '45%'], [50, '50%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R3 = models.IntegerField(choices=[[20, '20%'], [10, '10%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R4 = models.IntegerField(choices=[[20, '20%'], [40, '40%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R5 = models.IntegerField(choices=[[35, '35%'], [25, '25%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R6 = models.IntegerField(choices=[[10, '10%'], [5, '5%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R7 = models.IntegerField(choices=[[10, '10%'], [30, '30%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R8 = models.IntegerField(choices=[[60, '60%'], [40, '40%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R9 = models.IntegerField(choices=[[5, '5%'], [30, '30%']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R10 = models.IntegerField(choices=[[25, '25'], [5, '5']], label='¿Qué tasa elije para el pago del impuesto?', widget=widgets.RadioSelectHorizontal) R11 = models.IntegerField(label='Seleccione entre el 0% y el 100% la tasa que quiere pagar de impuesto', max=100, min=0, widget=widgets.RadioSelectHorizontal) class Participacion_Defensa(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 class Ronda1_Defensa(Page): form_model = 'player' form_fields = ['R1'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.35, pago2= participant.task_payment4*0.7, ) class Ronda2_Defensa(Page): form_model = 'player' form_fields = ['R2'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.45, pago2= participant.task_payment4*0.5, ) class Ronda3_Defensa(Page): form_model = 'player' form_fields = ['R3'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.1, pago2= participant.task_payment4*0.2, ) class Ronda4_Defensa(Page): form_model = 'player' form_fields = ['R4'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.2, pago2= participant.task_payment4*0.4, ) class Ronda5_Defensa(Page): form_model = 'player' form_fields = ['R5'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.25, pago2= participant.task_payment4*0.35, ) class Ronda6_Defensa(Page): form_model = 'player' form_fields = ['R6'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.05, pago2= participant.task_payment4*0.1, ) class Ronda7_Defensa(Page): form_model = 'player' form_fields = ['R7'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.1, pago2= participant.task_payment4*0.3, ) class Ronda8_Defensa(Page): form_model = 'player' form_fields = ['R8'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.4, pago2= participant.task_payment4*0.6, ) class Ronda9_Defensa(Page): form_model = 'player' form_fields = ['R9'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.05, pago2= participant.task_payment4*0.3, ) class Ronda10_Defensa(Page): form_model = 'player' form_fields = ['R10'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( pago1= participant.task_payment4*0.05, pago2= participant.task_payment4*0.25, ) class Ronda11_Defensa(Page): form_model = 'player' form_fields = ['R11'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 class P_Participacion_Defensa(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.TX3_R1= player.R1 participant.TX3_R2= player.R2 participant.TX3_R3= player.R3 participant.TX3_R4= player.R4 participant.TX3_R5= player.R5 participant.TX3_R6= player.R6 participant.TX3_R7= player.R7 participant.TX3_R8= player.R8 participant.TX3_R9= player.R9 participant.TX3_R10= player.R10 participant.TX3_R11= player.R11 participant.pagoTX3R1= int(participant.task_payment4 * (participant.TX3_R1/100)) participant.pagoTX3R2= int(participant.task_payment4 * (participant.TX3_R2/100)) participant.pagoTX3R3= int(participant.task_payment4 * (participant.TX3_R3/100)) participant.pagoTX3R4= int(participant.task_payment4 * (participant.TX3_R4/100)) participant.pagoTX3R5= int(participant.task_payment4 * (participant.TX3_R5/100)) participant.pagoTX3R6= int(participant.task_payment4 * (participant.TX3_R6/100)) participant.pagoTX3R7= int(participant.task_payment4 * (participant.TX3_R7/100)) participant.pagoTX3R8= int(participant.task_payment4 * (participant.TX3_R8/100)) participant.pagoTX3R9= int(participant.task_payment4 * (participant.TX3_R9/100)) participant.pagoTX3R10= int(participant.task_payment4 * (participant.TX3_R10/100)) participant.pagoTX3R11= int(participant.task_payment4 * (participant.TX3_R11/100)) participant.pago3R1= int(participant.task_payment4 - participant.pagoTX3R1) participant.pago3R2= int(participant.task_payment4 - participant.pagoTX3R2) participant.pago3R3= int(participant.task_payment4 - participant.pagoTX3R3) participant.pago3R4= int(participant.task_payment4 - participant.pagoTX3R4) participant.pago3R5= int(participant.task_payment4 - participant.pagoTX3R5) participant.pago3R6= int(participant.task_payment4 - participant.pagoTX3R6) participant.pago3R7= int(participant.task_payment4 - participant.pagoTX3R7) participant.pago3R8= int(participant.task_payment4 - participant.pagoTX3R8) participant.pago3R9= int(participant.task_payment4 - participant.pagoTX3R9) participant.pago3R10= int(participant.task_payment4 - participant.pagoTX3R10) participant.pago3R11= int(participant.task_payment4 - participant.pagoTX3R11) import random grupo3=(participant.pago3R1, participant.pago3R2, participant.pago3R3, participant.pago3R4 ,participant.pago3R5 ,participant.pago3R6 ,participant.pago3R7 ,participant.pago3R8, participant.pago3R9, participant.pago3R10,participant.pago3R11) participant.pago3= random.choice(grupo3) page_sequence = [Participacion_Defensa, Ronda1_Defensa, Ronda2_Defensa, Ronda3_Defensa, Ronda4_Defensa, Ronda5_Defensa, Ronda6_Defensa, Ronda7_Defensa, Ronda8_Defensa, Ronda9_Defensa, Ronda10_Defensa, Ronda11_Defensa, P_Participacion_Defensa]