from django.db import models from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Nata Daniela Caro Guevara' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'wtp2_v1' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): for player in self.get_players(): # **************** STAGE 1 **************** # Pago aleatorio x para cada jugador player.randomX = random.choice([c(25), c(35)]) print("randomX:", player.randomX) class Group(BaseGroup): pass def yn_field(): return models.IntegerField( choices=[ [1, "Sí"], [2, "No"], ], widget=widgets.RadioSelectHorizontal ) def time1(): return models.IntegerField( choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], default=0 ) def time2(): return models.IntegerField( choices=[0, 10, 20, 30, 40, 50], default=0 ) # Opciones a escoger en cada una de las 11 situaciones de la tabla. def make_s(): return models.IntegerField( choices=[ [1, "Opción 1"], [2, "Opción 2"], ], widget=widgets.RadioSelectHorizontal ) class Player(BasePlayer): # ************ CONSENTIMIENTO INFORMADO ************ city = models.StringField() day = models.IntegerField(max=31, min=1) month = models.IntegerField(min=1, max=12) year = models.IntegerField(max=2020, min=2020, default=2020) 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.IntegerField(min=0) citycard = models.StringField() # ************ TRANPORTE Y LUGAR DE RESIDENCIA ************ dircity1 = models.IntegerField( choices=[ [1, "Bogotá"], [2, "Otro municipio. ¿Cuál?"] ], widget=widgets.RadioSelect ) dircity2 = models.StringField(blank=True) dir1 = models.IntegerField( choices=[ [0, "Avenida Calle"], [1, "Avenida Carrera"], [2, "Autopista"], [3, "Avenida"], [4, "Carretera"], [5, "Calle"], [6, "Camino"], [7, "Carrera"], [8, "Circunvalar"], [9, "Diagonal"], [10, "Kilometro"], [11, "Transversal"], [12, "Vereda"], [13, "Variante"], [14, "Zona Franca"] ], blank=True ) dir2 = models.IntegerField(min=1, blank=True) dir3 = models.IntegerField( choices=[ [1, "A"], [2, "B"], [3, "C"], [4, "D"], [5, "E"], [6, "F"], [7, "G"], [8, "H"], [9, "I"], [10, "J"], [11, "K"], [12, "L"], [13, "M"], [14, "N"], [15, "O"], [16, "P"], [17, "Q"], [18, "R"], [19, "S"], [20, "T"], [21, "U"], [22, "V"], [23, "W"], [24, "X"], [25, "Y"], [26, "Z"] ], blank=True ) dir4 = models.IntegerField( choices=[ [1, "Bis"], [2, "Este"], [3, "Noreste"], [4, "Noroeste"], [5, "Oeste"], [6, "Sur"], [7, "Sureste"], [8, "Suroeste"] ], blank=True ) dir5 = models.IntegerField(min=1, blank=True) dir6 = models.IntegerField( choices=[ [1, "A"], [2, "B"], [3, "C"], [4, "D"], [5, "E"], [6, "F"], [7, "G"], [8, "H"], [9, "I"], [10, "J"], [11, "K"], [12, "L"], [13, "M"], [14, "N"], [15, "O"], [16, "P"], [17, "Q"], [18, "R"], [19, "S"], [20, "T"], [21, "U"], [22, "V"], [23, "W"], [24, "X"], [25, "Y"], [26, "Z"] ], blank=True ) dir7 = models.IntegerField( choices=[ [1, "Bis"], [2, "Este"], [3, "Noreste"], [4, "Noroeste"], [5, "Oeste"], [6, "Sur"], [7, "Sureste"], [8, "Suroeste"] ], blank=True ) dir8 = models.StringField(blank=True) # pregunta 2 t3 = models.IntegerField( choices=[ [0, "Bus (SITP, urbano, intermunicipal)"], [1, "Caminando"], [2, "Transporte articulado (Transmilenio)"], [3, "Taxi"], [4, "Automóvil de uso particular"], [5, "Automóvil de uso compartido (Uber, Cabify, Didi, etc.)"], [6, "Moto"], [7, "Bicicleta"], [8, "Otro"] ], widget=widgets.RadioSelect ) t4_1 = time1() t4_2 = time2() t5 = models.IntegerField( choices=[ [0, "Bus (SITP, urbano, intermunicipal)"], [1, "Caminando"], [2, "Transporte articulado(Transmilenio)"], [3, "Taxi"], [4, "Automóvil de uso particular"], [5, "Automóvil de uso compartido(Uber, Cabify, Didi, etc.)"], [6, "Moto"], [7, "Bicicleta"], [8, "Otro"] ], widget=widgets.RadioSelect ) t6_1 = time1() t6_2 = time2() t7 = models.IntegerField( choices=[ [0, "Nunca dispuesta/o"], [1, "Poco dispuesta/o"], [2, "Algo dispuesta/o"], [3, "Muy dispuesta/o"], [4, "Siempre dispuesta/o"] ], widget=widgets.RadioSelect ) t8 = models.IntegerField( choices=[ [0, "Nunca dispuesta/o"], [1, "Poco dispuesta/o"], [2, "Algo dispuesta/o"], [3, "Muy dispuesta/o"], [4, "Siempre dispuesta/o"] ], widget=widgets.RadioSelect ) t9 = models.IntegerField( choices=[ [1, "Bogotá"], [2, "En otra ciudad/municipio de Colombia"], [3, "En otra ciudad/municipio fuera de Colombia"] ], widget=widgets.RadioSelect ) t10 = models.IntegerField( choices=[ [0, "Vivía sola/o"], [1, "Vivía con algún familiar"], [2, "Vivía con otras personas (amigos/amigas, residencias estudiantiles, habitación en arriendo)"], [3, "Otro"] ], widget=widgets.RadioSelect, initial=None ) t11_1 = yn_field() t11_2 = yn_field() t11_3 = yn_field() t11_4 = yn_field() t11_5 = yn_field() t11_6 = yn_field() t11_7 = yn_field() t11_8 = yn_field() t11_9 = yn_field() t12_1 = yn_field() t12_2 = time1() t12_3 = time2() t13_1 = yn_field() t13_2 = time1() t13_3 = time2() t14_1 = yn_field() t14_2 = time1() t14_3 = time2() t15_1 = yn_field() t15_2 = time1() t15_3 = time2() t16_1 = yn_field() t16_2 = time1() t16_3 = time2() t17_1 = yn_field() t17_2 = time1() t17_3 = time2() t18_1 = yn_field() t18_2 = time1() t18_3 = time2() t19_1 = yn_field() t19_2 = time1() t19_3 = time2() # ************ USO DEL TIEMPO ************ u1_1 = yn_field() u1_2 = time1() u1_3 = time2() u2_1 = yn_field() u2_2 = time1() u2_3 = time2() u3_1 = yn_field() u3_2 = time1() u3_3 = time2() u4_1 = yn_field() u4_2 = time1() u4_3 = time2() u5_1 = yn_field() u5_2 = time1() u5_3 = time2() u6_1 = yn_field() u6_2 = time1() u6_3 = time2() u7_1 = yn_field() u7_2 = time1() u7_3 = time2() # ************ COMPOSITE MORNING QUESTIONNAIRE ************ m1 = models.IntegerField( choices=[ [5, "5:00 - 6:30 a.m."], [4, "6:30 - 7:45 a.m."], [3, "7:45 - 9:45 a.m."], [2, "9:45 - 11:00 a.m."], [1, "11:00 a.m. - 12:00 p.m."] ], widget=widgets.RadioSelect ) m2 = models.IntegerField( choices=[ [5, "8:00 - 9:00 p.m."], [4, "9:00 - 10:15 p.m."], [3, "10:15 p.m. - 12:30 a.m."], [2, "12:30 - 1:45 a.m."], [1, "1:45 - 3:00 a.m."] ], widget=widgets.RadioSelect ) m3 = models.IntegerField( choices=[ [1, "Muy difícil"], [2, "Poco fácil"], [3, "Bastante fácil"], [4, "Muy fácil"] ], widget=widgets.RadioSelect ) m4 = models.IntegerField( choices=[ [1, "Nada despejada/o"], [2, "Poco despejada/o"], [3, "Bastante despejada/o"], [4, "Muy despejada/o"] ], widget=widgets.RadioSelect ) m5 = models.IntegerField( choices=[ [1, "Muy cansada/o"], [2, "Algo cansada/o"], [3, "Algo descansada/o"], [4, "Muy descansada/o"] ], widget=widgets.RadioSelect ) m6 = models.IntegerField( choices=[ [4, "Estaría en buena forma"], [2, "Estaría en suficiente forma"], [3, "Lo encontraría difícil"], [1, "Lo encontraría muy difícil"] ], widget=widgets.RadioSelect ) m7 = models.IntegerField( choices=[ [5, "8:00 - 9:00 p.m."], [4, "9:00 - 10:15 p.m."], [3, "10:15 p.m. - 12:30 a.m."], [2, "12:30 - 1:45 a.m."], [1, "1:45 - 3:00 a.m."] ], widget=widgets.RadioSelect ) m8 = models.IntegerField( choices=[ [4, "8:00 - 10:00 a.m."], [2, "11:00 a.m. - 1:00 p.m."], [3, "3:00 - 5:00 p.m."], [1, "7:00 - 9:00 p.m."] ], widget=widgets.RadioSelect ) m9 = models.IntegerField( choices=[ [4, "Totalmente una persona diurna"], [2, "Más diurna que nocturna"], [3, "Más nocturna que diurna"], [1, "Totalmente una persona nocturna"] ], widget=widgets.RadioSelect ) m10 = models.IntegerField( choices=[ [4, "Antes de 6:30 a.m."], [2, "6:30 - 7:30 a.m."], [3, "7:30 - 8:30 a.m."], [1, "8:30 o más tarde en la mañana"] ], widget=widgets.RadioSelect ) m11 = models.IntegerField( choices=[ [1, "Muy difícil y desagradable"], [2, "Bastante difícil y desagradable"], [3, "Un poco desagradable, pero no problemático"], [4, "Fácil y no desagradable"] ], widget=widgets.RadioSelect ) m12 = models.IntegerField( choices=[ [4, "0-10 min."], [2, "11-20 min."], [3, "21-40 min."], [1, "Más de 40 min."] ], widget=widgets.RadioSelect ) m13 = models.IntegerField( choices=[ [4, "Muy activa/o por la mañana (despejada/o por la mañana y cansada/o por la noche)"], [2, "Hasta cierto punto activa/o por la mañana"], [3, "Hasta cierto punto activa/o por la noche"], [1, "Muy activa/o por la noche (cansada/o por la mañana y despejada/o por la noche)"] ], widget=widgets.RadioSelect ) # ************ NEW VIRTUAL TREATMENT ************ s1 = make_s() s2 = make_s() s3 = make_s() s4 = make_s() s5 = make_s() s6 = make_s() s7 = make_s() s8 = make_s() s9 = make_s() s10 = make_s() s11 = make_s() # ************ PAYMENT ************ randomX = models.CurrencyField() random_s = models.IntegerField() pagoS5 = models.CurrencyField() # ************ PERCEPTION OF INSECURITY AND VICTIMIZATION ************ v1_1 = yn_field() v1_2 = yn_field() v1_3 = yn_field() v1_4 = yn_field() v1_5 = yn_field() v1_6 = yn_field() v1_7 = yn_field() v2_1 = yn_field() v2_2 = yn_field() v2_3 = yn_field() v2_4 = yn_field() # ************ PAYMENT ************ ##Fields for payment namep = models.StringField() idcard1 = models.StringField() address = models.StringField() cityp = models.StringField() telephone = models.StringField() dayp = models.IntegerField(min=1, max=31) monthp = models.IntegerField(min=1, max=12) yearp = models.IntegerField(max=2020, min=2020, default=2020) concept = models.StringField() valuen = models.IntegerField() value = models.StringField() signaturep = models.StringField() idcard2 = models.StringField() typepayment = models.BooleanField(choices=[ [True, "Transferencia Bancaria"], [False, "Nequi o Daviplata"], ], widget=widgets.RadioSelectHorizontal, ) platform = models.IntegerField(choices=[ [0, "Nequi"], [1, "Daviplata "], ], widget=widgets.RadioSelectHorizontal, initial=None) telephone_2 = models.StringField(initial=None) 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"], ], 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) # Extras participantlabel = models.StringField() lenvector = models.IntegerField() partlabel = models.StringField() partpayoff = models.IntegerField()