from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'third_party_one' players_per_group = 3 num_rounds = 5 instructionsInicio = 'third_party_one/instructionsInicio.html' instructionsGeneralA = 'third_party_one/instructionsGeneralA.html' instructionsGeneralB = 'third_party_one/instructionsGeneralB.html' instructionsGeneralC = 'third_party_one/instructionsGeneralC.html' instructionsEspA = 'third_party_one/InstructionsEspecificA.html' instructionsEspB = 'third_party_one/InstructionsEspecificB.html' instructionsEspC = 'third_party_one/InstructionsEspecificC.html' etapaUnoA = 'third_party_one/EtapaUnoA.html' etapaUnoB = 'third_party_one/EtapaUnoB.html' etapaUnoC = 'third_party_one/EtapaUnoC.html' etapaDosA = 'third_party_one/EtapaDosA.html' etapaDosB = 'third_party_one/EtapaDosB.html' etapaDosC = 'third_party_one/EtapaDosC.html' PcProdA='third_party_one/PcProcedureA.html' PcProdB='third_party_one/PcProcedureB.html' PcProdC='third_party_one/PcProcedureC.html' collapsed = 'third_party_one/collapseinstructions.html' endowmentA=c(100) endowmentC=c(50) multiplication_factor=3 class Subsession(BaseSubsession): def creating_session(self): global paying_round self.group_randomly(fixed_id_in_group=True) if self.round_number == 1: paying_round = random.randint(1, Constants.num_rounds) self.session.vars['paying_round'] = paying_round print('la ronda a pagar es',paying_round) for g in self.get_groups(): for p in self.get_players(): p.random_round=paying_round class Group(BaseGroup): sent_amount = models.CurrencyField( choices=[0,10,20,30,40,50] ) deduction_0=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) deduction_10=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) deduction_20=models.CurrencyField( label = "", min=0, max=Constants.endowmentC, ) deduction_30=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) deduction_40=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) deduction_50=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) expectation_sent= models.CurrencyField( label="¿Cuántos puntos le dará a usted?", choices=[0,10,20,30,40,50], min=0, max=Constants.endowmentA, ) expectation_return_0=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) expectation_return_10=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) expectation_return_20=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) expectation_return_30=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) expectation_return_40=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) expectation_return_50=models.CurrencyField( label="", min=0, max=Constants.endowmentC, ) expectation_social_norm_s1_B=models.IntegerField( label="", choices=[ [0,"Muy socialmente inapropiada"], [1,"Algo socialmente inapropiada"], [2, "Algo socialmente apropiada"], [3, "Muy socialmente apropiada"] ], widget=widgets.RadioSelect, ) expectation_social_norm_s2_B=models.IntegerField( label="", choices=[ [0,"Muy socialmente inapropiada"], [1,"Algo socialmente inapropiada"], [2, "Algo socialmente apropiada"], [3, "Muy socialmente apropiada"] ], widget=widgets.RadioSelect, ) expectation_social_norm_s1_C=models.IntegerField( label="", choices=[ [0,"Muy socialmente inapropiada"], [1,"Algo socialmente inapropiada"], [2, "Algo socialmente apropiada"], [3, "Muy socialmente apropiada"] ], widget=widgets.RadioSelect, ) expectation_social_norm_s2_C=models.IntegerField( label="", choices=[ [0,"Muy socialmente inapropiada"], [1,"Algo socialmente inapropiada"], [2, "Algo socialmente apropiada"], [3, "Muy socialmente apropiada"] ], widget=widgets.RadioSelect, ) class Player(BasePlayer): survey_10 = models.IntegerField() def survey_10_negative_error_message(self, value): if not (value == 15): return 'Error, recuerde que el número de puntos de deducción se triplican cuando son deducidos.' survey_11 = models.IntegerField() def survey_11_negative_error_message(self, value): if not (value == 40): return 'Error, el participante A le envió 40 puntos al participante B .' survey_12 = models.IntegerField() def survey_12_negative_error_message(self, value): if not (value == 35): return 'Error, el participante C envió 15 puntos de deducción.' survey_14=models.IntegerField() random_round=models.IntegerField() city = models.StringField() day = models.IntegerField(min=1, max=31) month = models.IntegerField(min=1, max=12) year = models.IntegerField(max=2021, min=2021, default=2021) hour = models.IntegerField(min=1, max=12) minutes = models.IntegerField(min=0, max=59) ampm = models.IntegerField( choices=[ [0, 'AM'], [1, 'PM'] ] ) name = models.StringField() signature = models.StringField() idcard = models.StringField() citycard = models.StringField() q1=models.IntegerField(label="") q2=models.IntegerField(choices=[[0,"Masculino"],[1,"Femenino"]], widget=widgets.RadioSelect) q3=models.IntegerField(label="") q4=models.StringField(label="") q5=models.IntegerField(choices=[ [0,"Pregrado"], [1,"Posgrado"], ], widget=widgets.RadioSelect ) q6=models.IntegerField(label="") q7=models.IntegerField(choices=[[0,"Sí"],[1,"No"]], widget=widgets.RadioSelect) q8=models.IntegerField(choices=[[0,"Sí"],[1,"No"]], widget=widgets.RadioSelect) q9=models.IntegerField(min=0, max=100) q10=models.IntegerField(label="") q11=models.IntegerField(choices=[[0,"0"],[1,"1"],[2,"2"],[3,"3"],[4,"4"],[5,"5"],[6,"6"],[7,"7"],[8,"8"],[9,"9"],[10,"10"]], widget=widgets.RadioSelectHorizontal) q12=models.IntegerField(choices=[[0,"0"],[1,"1"],[2,"2"],[3,"3"],[4,"4"],[5,"5"],[6,"6"],[7,"7"],[8,"8"],[9,"9"],[10,"10"]], widget=widgets.RadioSelectHorizontal) q13=models.IntegerField(choices=[[0,"0"],[1,"1"],[2,"2"],[3,"3"],[4,"4"],[5,"5"],[6,"6"],[7,"7"],[8,"8"],[9,"9"],[10,"10"]], widget=widgets.RadioSelectHorizontal) q14=models.IntegerField(choices=[[0,"0"],[1,"1"],[2,"2"],[3,"3"],[4,"4"],[5,"5"],[6,"6"],[7,"7"],[8,"8"],[9,"9"],[10,"10"]], widget=widgets.RadioSelectHorizontal) q15=models.IntegerField(choices=[[0,"1"],[1,"2"],[2,"3"],[3,"4"],[4,"5"],[5,"6"],[6,"No sabe/No Responde"]], widget=widgets.RadioSelect) ##Field del pago de la ronda sin coordinación. round_payoff=models.CurrencyField() ##Fields con respecto a los puntos enviados por A a B (expectativas de B) bel_sent=models.BooleanField(initial=False) expected_sent_ammount_B=models.CurrencyField(initial=None) global_payoff=models.CurrencyField(initial=None) ##Fields con respecto a los puntos de deducción cobrados por A a C (expectativas de B) bel_ded0=models.BooleanField(initial=False) bel_ded10=models.BooleanField(initial=False) bel_ded20=models.BooleanField(initial=False) bel_ded30=models.BooleanField(initial=False) bel_ded40=models.BooleanField(initial=False) bel_ded50=models.BooleanField(initial=False) expected_ded_0_B=models.CurrencyField(initial=None) expected_ded_10_B = models.CurrencyField(initial=None) expected_ded_20_B = models.CurrencyField(initial=None) expected_ded_30_B = models.CurrencyField(initial=None) expected_ded_40_B = models.CurrencyField(initial=None) expected_ded_50_B = models.CurrencyField(initial=None) ded_points=models.CurrencyField(initial=None) # **** PAYMENT **** ##Fields for payment idcard1 = models.StringField() expday = models.IntegerField(min=1, max=31) expmonth = models.IntegerField(min=1, max=12) expyear = models.IntegerField() namep = models.StringField() address = models.StringField() depto = models.StringField() cityp = models.StringField() country1 = models.StringField() email = models.StringField() telephone = models.StringField() dayp = models.IntegerField(min=1, max=31) monthp = models.IntegerField(min=1, max=12) yearp = models.IntegerField(max=2021, min=2021, default=2021) concept = models.StringField() signaturep = models.StringField() idcard2 = models.StringField() typepayment = models.BooleanField(choices=[ [True, "Transferencia Bancaria"], [False, "Daviplata"], ], widget=widgets.RadioSelectHorizontal, ) platform = models.IntegerField(choices=[ [1, "Daviplata "], ], widget=widgets.RadioSelectHorizontal, initial=None) telephone_2 = models.StringField(initial=None) name_titular=models.StringField() cedula_titular = models.StringField() bank = models.IntegerField(choices=[ [0, "AV Villas"], [1, "Bancamía"], [2, "Banco Agrario"], [3, "Banco Bancoldex"], [4, "Banco Compartir"], [5, "Banco Coopcentral"], [6, "Banco Falabella"], [7, "Banco Finandina"], [8, "Banco Mundo Mujer"], [9, "Banco Pichincha"], [10, "Banco Procredit Colombia"], [11, "Banco Santander Colombia"], [12, "Banco Serfinanza"], [13, "Banco W"], [14, "Bancolombia"], [15, "Bancoomeva"], [16, "BBVA"], [17, "BNB Paribas"], [18, "Bogotá"], [19, "Caja Social"], [20, "CitiBank"], [21, "Coltefinanciera"], [22, "Compañía Financiera Juriscoop"], [23, "Confiar"], [24, "Cooperativa financiera Contrafa"], [25, "Cooperativa financiera de Antioquia"], [26, "Davivienda"], [27, "ITAU"], [28, "ITAU antes Corpbanca"], [29, "Occidente"], [30, "Popular"], [31, "Scotiabank Colpatria"], [32, "GNB Sudameris"], ], initial=None) id_bank = models.StringField(initial=None) name_2 = models.StringField(initial=None) account_type = models.BooleanField( choices=[ [True, "Ahorros"], [False, "Corriente"], ], initial=None ) idcard3 = models.StringField(initial=None)