from django.db import models from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, ) from multiselectfield import MultiSelectField import random author = ' ' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'WTP_experiment_H' 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 # **************** STAGE 0 **************** # Opciones para preguntas sobre candidatos def make_s0p1(): return models.IntegerField( choices=[ [1, "Claudia López"], [2, "Carlos Galán"], [3, "Miguel Uribe"], ], widget=widgets.RadioSelect, ) # Opciones para preguntas sobre zonas en Bogotá def make_s0p2(): return models.IntegerField(max=3, min=1) # Opciones para preguntas sobre rangos del día def make_s0p3(): return models.IntegerField( choices=[ [1, "Madrugada-Mañana (12:00am-11:59am)"], [2, "Tarde-Noche (12:00pm-11:59pm)"], ], widget=widgets.RadioSelect ) # **************** STAGE 1 **************** # Opciones a escoger en cada una de las 11 situaciones de la tabla. def make_s1(): return models.IntegerField( choices=[ [1, "Opción 1"], [2, "Opción 2"], ], widget=widgets.RadioSelectHorizontal ) # **************** STAGE 2 **************** # *** Módulo 1 y 2*** def make_urna(): return models.IntegerField( choices=[ [1, "Urna A"], [2, "Urna B"], ], widget=widgets.RadioSelectHorizontal ) # *** Módulo 3 *** def risk_field(): return models.IntegerField( choices=[ [0, "Aceptar"], [1, "Rechazar"], ], widget=widgets.RadioSelectHorizontal ) # **************** STAGE 3 **************** def p6_11(): return models.IntegerField( choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], widget=widgets.RadioSelectHorizontal ) class Player(BasePlayer): # **************** STAGE 0 **************** # *** N *** # Preguntas candidatos s0Np1p1 = make_s0p1() s0Np1p2 = make_s0p1() s0Np1p3 = make_s0p1() # Preguntas zonas de Bogotá s0Np2p1 = make_s0p2() s0Np2p2 = make_s0p2() s0Np2p3 = make_s0p2() # Preguntas sobre rango del día s0Np3p1 = make_s0p3() # *** H *** # Preguntas candidatos s0Hp1p1 = make_s0p1() s0Hp1p2 = make_s0p1() s0Hp1p3 = make_s0p1() # Preguntas zonas de Bogotá s0Hp2p1 = make_s0p2() s0Hp2p2 = make_s0p2() s0Hp2p3 = make_s0p2() # Preguntas sobre rango del día s0Hp3p1 = make_s0p3() # **************** STAGE 1 **************** # Juego S1 s1 = make_s1() s2 = make_s1() s3 = make_s1() s4 = make_s1() s5 = make_s1() s6 = make_s1() s7 = make_s1() s8 = make_s1() s9 = make_s1() s10 = make_s1() s11 = make_s1() # **************** STAGE 2 **************** # Instrucciones S2-RiskExperiment ET_riskreturn = models.IntegerField( choices=[ [0, 'Blanco'], [1, 'Negro'] ], widget=widgets.RadioSelectHorizontal ) # Juego S2-RiskExperiment r1 = make_urna() r2 = make_urna() r3 = make_urna() r4 = make_urna() r5 = make_urna() r6 = make_urna() r7 = make_urna() r8 = make_urna() r9 = make_urna() r10 = make_urna() r11 = make_urna() # Instrucciones S2-AmbiguityExperiment ET_ambiguityreturn = models.IntegerField( choices=[ [0, 'Blanco'], [1, 'Negro'] ], widget=widgets.RadioSelectHorizontal ) # Juego S2-AmbiguityExperiment a1 = make_urna() a2 = make_urna() a3 = make_urna() a4 = make_urna() a5 = make_urna() a6 = make_urna() a7 = make_urna() a8 = make_urna() a9 = make_urna() a10 = make_urna() a11 = make_urna() # Instrucciones S2-LossExperiment ra1 = risk_field() ra2 = risk_field() ra3 = risk_field() ra4 = risk_field() ra5 = risk_field() ra6 = risk_field() # **************** STAGE 3 **************** # PREGUNTA 2 DE CUESTIONARIO p2 = models.IntegerField( choices=[ [0, "Femenino"], [1, "Masculino"], [2, "Otro"], ], widget=widgets.RadioSelect ) # PREGUNTA 3 DE CUESTIONARIO p3 = models.IntegerField( choices=[ [0, "Menos de 20 años"], [1, "Entre 20 y 29 años"], [2, "Entre 30 y 39 años"], [3, "Entre 40 y 49 años"], [4, "Entre 50 y 59 años"], [5, "60 años o más"], ], widget=widgets.RadioSelect ) # PREGUNTA 4 DE CUESTIONARIO p4 = models.IntegerField( choices=[ [0, "Actualmente casado(a)(incluye Unión Libre)"], [1, "Viudo(a)"], [2, "Divorciado(a)/Separado(a)"], [3, "Nunca me he casado"], ], widget=widgets.RadioSelect ) # PREGUNTA 5 DE CUESTIONARIO p5 = models.IntegerField( choices=[ [0, "Primaria o menos"], [1, "Bachillerato"], [2, "Técnico"], [3, "Universitario o más"], ], widget=widgets.RadioSelect ) # PREGUNTA 6-11 DE CUESTIONARIO p6 = p6_11() p7 = p6_11() p8 = p6_11() p9 = p6_11() p10 = p6_11() p11 = p6_11() # PREGUNTA 12 y 13 p12 = models.IntegerField( choices=[ [0, "En desacuerdo"], [1, "De acuerdo"], [2, "No sé"], ], widget=widgets.RadioSelect ) p13 = models.IntegerField( choices=[ [0, "En desacuerdo"], [1, "De acuerdo"], [2, "No sé"], ], widget=widgets.RadioSelect ) # PREGUNTA 14 p14 = models.IntegerField( choices=[ [0, "Seguro"], [1, "Relativamente seguro"], [2, "Inseguro"], [3, "Muy Inseguro"], ], widget=widgets.RadioSelect ) # Pregunta 15 p15a = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) p15b = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) p15c = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) p15d = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) p15e = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) p15f = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) p15g = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) p15h = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) p15i = models.BooleanField(widget=widgets.RadioSelectHorizontal, choices=[[0, 'Sí'], [1, 'No']]) # Pregunta 16 p16 = p6_11() # Pregunta 17-19 p17 = make_s0p2() p18 = make_s0p2() p19 = make_s0p2() randomX = models.CurrencyField()