from random import randrange from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Marco Faillo' doc = """ SIF versione Prolif - Solo lavoratore_3.0""" # t1 quality fixed , t2 = quantity , t3 = quality t4= average t5: threshold class Constants(BaseConstants): name_in_url = 'sif_singolo_L3' players_per_group = None num_rounds = 1 # euro_UMS=0.10 #tasso conversione endowment_L = 20 # endowment lavoratore endowment_F = 30 #endowment finanziatore # p = 50 # p per beni per L # q= 50 #q per beni per B B_return_1= 0.1 #pagamento beni 1 per il beneficiario B_return_2 = 1 #pagamento beni 2 per il beneficiario L_return = 1 #pagamento unitario per il lavoratore beni di tipo e 2 L_cost_1_F = 0.5 L_cost_2_F = 1 L_cost_1_NF = 1 L_cost_2_NF = 2 class Subsession(BaseSubsession): def creating_session(self): # self.session.config['real_world_currency_per_point'] = 0.10 # self.session.config['participation_fee'] = 0.50 # settings.REAL_WORLD_CURRENCY_CODE = 'GBP' # settings.LANGUAGE_CODE = 'en' # settings.USE_POINTS = True pass class Group(BaseGroup): pass class Player(BasePlayer): ## numero di beni b1 ## b1_choice = models.IntegerField( min=0, max=20, initial=0, label=" Quanti beni b1 vuoi acquistare?", ) ## numero di beni b2 ## b2_choice = models.IntegerField( min=0, max=10, initial=0, doc="Quanti beni b2 vuoi acquistare?", ) # costo totale per L # Prol= models.StringField(label=False) #prolific ID B_pay_1 = models.FloatField(initial=0) # pagamento beni di tipo 1 beneficiario B_pay_2 = models.FloatField(initial=0) # pagamento beni di tipo 2 beneficiario B_total_payment = models.FloatField(initial=0) B_total_payment_pounds = models.FloatField(initial=0) L_total_payment_F = models.FloatField(initial=0) # payoff se viene finanziato L_total_payment_pounds_F = models.FloatField(initial=0) # payoff pounds se finanziato L_total_payment_NF = models.FloatField(initial=0) # payoff se non viene finanziato L_total_payment_pounds_NF = models.FloatField(initial=0) # payoff pounds se non finanziato F_return_payment = models.FloatField(initial=0) F_return_payment_pounds = models.FloatField(initial=0) F_total_payment = models.FloatField(initial=0) F_total_payment_pounds =models.FloatField(initial=0) Errors=models.IntegerField(initial=0) #errori nelle domande di controllo. q1 = models.IntegerField( choices=[[1, 'True'], [2, 'False']], widget=widgets.RadioSelect) q2 = models.IntegerField( choices=[[1, 'True'], [2, 'False']], widget=widgets.RadioSelect) q3 = models.IntegerField( choices=[[1, 'True'], [2, 'False']], widget=widgets.RadioSelect) q4 = models.IntegerField( choices=[[1, 'True'], [2, 'False']], widget=widgets.RadioSelect) q5 = models.IntegerField( choices=[[1, 'True'], [2, 'False']], widget=widgets.RadioSelect) q6 = models.IntegerField( choices=[[1, 'True'], [2, 'False']], widget=widgets.RadioSelect) q7 = models.IntegerField( choices=[[1, 'COST'], [2, 'EARNING']], ) # controls and beliefs L_beliefs = models.PositiveIntegerField( choices= [[1, 'Yes'], [0, 'No']]) def set_payoff(self): # payoff B self.B_pay_1 = Constants.B_return_1*self.b1_choice self.B_pay_2 = Constants.B_return_2*self.b2_choice self.B_total_payment = (self.B_pay_1+self.B_pay_2) self.B_total_payment_pounds = (self.B_pay_1 + self.B_pay_2)*0.10 #payoff F if self.session.config['treatment'] == 1: #baseline self.F_total_payment =12 #T2 quantità elif self.session.config['treatment'] == 2: self.F_total_payment =(self.b1_choice +self.b2_choice)*0.8 #T5 soglia elif self.session.config['treatment'] == 5: if self.b2_choice >2: self.F_total_payment=14.4 else: self.F_total_payment =5.6 #T6 valutatore T7 finanziatore fixed elif self.session.config['treatment'] == 6: self.F_total_payment =12 else: #T3 qualità self.F_total_payment =self.B_total_payment*2 self.F_total_payment_pounds =self.F_total_payment*0.10 #payoff L se viene finanziato self.L_total_payment_F = Constants.endowment_L+(Constants.L_return*self.b1_choice+Constants.L_return*self.b2_choice)-(Constants.L_cost_1_F*self.b1_choice+Constants.L_cost_2_F*self.b2_choice) self.L_total_payment_pounds_F = self.L_total_payment_F*0.10 #payoff L se non viene finanziato self.L_total_payment_NF = Constants.endowment_L+(Constants.L_return*self.b1_choice + Constants.L_return*self.b2_choice)-(Constants.L_cost_1_NF*self.b1_choice+Constants.L_cost_2_NF*self.b2_choice) print(self.L_total_payment_NF ) self.L_total_payment_pounds_NF = self.L_total_payment_NF*0.10 print( self.L_total_payment_F, self.L_total_payment_NF)