from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class Introduction(Page): def is_displayed(self): return self.round_number == 1 class Instructions_Especific(Page): def is_displayed(self): return self.round_number == 1 class Offer(Page): form_model = 'group' form_fields = ['sent_amount'] def is_displayed(self): return self.player.id_in_group==1 def vars_for_template(self): mostrar_ronda = True if self.subsession.round_number == 1: mostrar_ronda = False return dict(mostrar=mostrar_ronda) class Deduction(Page): form_model = 'group' form_fields = ['deduction_0','deduction_10','deduction_20','deduction_30','deduction_40','deduction_50'] def is_displayed(self): return self.player.id_in_group==3 def vars_for_template(self): mostrar_ronda = True if self.subsession.round_number == 1: mostrar_ronda = False return dict(mostrar=mostrar_ronda) class Expectations(Page): form_model = 'group' form_fields = ['expectation_sent', 'expectation_return_0', 'expectation_return_10', 'expectation_return_20', 'expectation_return_30', 'expectation_return_40', 'expectation_return_50'] def is_displayed(self): return self.player.id_in_group==2 def vars_for_template(self): mostrar_ronda = True if self.subsession.round_number == 1: mostrar_ronda = False return dict(mostrar=mostrar_ronda) class WaitForAll(WaitPage): pass class RoundResults(Page): def before_next_page(self): self.group.choice_sent=self.group.sent_amount self.group.choice_expected_return=self.group.expectation_sent self.group.choice_expected_ded_0=self.group.expectation_return_0 self.group.choice_expected_ded_10=self.group.expectation_return_10 self.group.choice_expected_ded_20=self.group.expectation_return_20 self.group.choice_expected_ded_30=self.group.expectation_return_30 self.group.choice_expected_ded_40=self.group.expectation_return_40 self.group.choice_expected_ded_50=self.group.expectation_return_50 self.group.choice_ded_0=self.group.deduction_0 self.group.choice_ded_10=self.group.deduction_10 self.group.choice_ded_20=self.group.deduction_20 self.group.choice_ded_30=self.group.deduction_30 self.group.choice_ded_40=self.group.deduction_40 self.group.choice_ded_50=self.group.deduction_50 if self.group.sent_amount == c(0): self.group.choice_actual_deduction=self.group.deduction_0 elif self.group.sent_amount == c(10): self.group.choice_actual_deduction=self.group.deduction_10 elif self.group.sent_amount == c(20): self.group.choice_actual_deduction=self.group.deduction_20 elif self.group.sent_amount == c(30): self.group.choice_actual_deduction = self.group.deduction_30 elif self.group.sent_amount == c(40): self.group.choice_actual_deduction = self.group.deduction_40 else: self.group.choice_actual_deduction=self.group.deduction_50 self.group.choice_message=self.group.message self.group.choice_expected_message=self.group.expectation_message def vars_for_template(self): mostrar_ronda = True if self.subsession.round_number == 1: mostrar_ronda = False mensaje=False Sapo=False if self.group.message==True: mensaje=True Sapo=True if self.group.message==False: mensaje=True if self.group.sent_amount == c(0): deduction_points=self.group.deduction_0 elif self.group.sent_amount == c(10): deduction_points=self.group.deduction_10 elif self.group.sent_amount == c(20): deduction_points=self.group.deduction_20 elif self.group.sent_amount == c(30): deduction_points = self.group.deduction_30 elif self.group.sent_amount == c(40): deduction_points = self.group.deduction_40 else: deduction_points=self.group.deduction_50 paymentA=Constants.endowmentA-self.group.sent_amount-deduction_points*Constants.multiplication_factor return dict(mensaje=mensaje,Sapo=Sapo,round_paymentA=paymentA , round_paymentC=Constants.endowmentC-deduction_points, ded_points=deduction_points, mostrar=mostrar_ronda) class DespuesRondaUno(Page): def is_displayed(self): return self.round_number == 1 class Message(Page): form_model='group' form_fields = ['message'] def is_displayed(self): mostrar_mensaje = False if self.group.sent_amount == c(0): deduction_points = self.group.deduction_0 elif self.group.sent_amount == c(10): deduction_points = self.group.deduction_10 elif self.group.sent_amount == c(20): deduction_points = self.group.deduction_20 elif self.group.sent_amount == c(30): deduction_points = self.group.deduction_30 elif self.group.sent_amount == c(40): deduction_points = self.group.deduction_40 else: deduction_points = self.group.deduction_50 if deduction_points != 0: mostrar_mensaje = True return self.player.id_in_group == 1 and mostrar_mensaje def vars_for_template(self): mostrar_ronda = True if self.subsession.round_number == 1: mostrar_ronda = False if self.group.sent_amount == c(0): deduction_points = self.group.deduction_0 elif self.group.sent_amount == c(10): deduction_points = self.group.deduction_10 elif self.group.sent_amount == c(20): deduction_points = self.group.deduction_20 elif self.group.sent_amount == c(30): deduction_points = self.group.deduction_30 elif self.group.sent_amount == c(40): deduction_points = self.group.deduction_40 else: deduction_points = self.group.deduction_50 return dict(ded_points=deduction_points, mostrar=mostrar_ronda) class MessageB(Page): form_model='group' form_fields = ['expectation_message'] def is_displayed(self): return self.player.id_in_group==2 def vars_for_template(self): mostrar_ronda = True if self.subsession.round_number == 1: mostrar_ronda = False return dict(mostrar=mostrar_ronda) class ResultsWaitPage(WaitPage): def is_displayed(self): return self.round_number == Constants.num_rounds def after_all_players_arrive(self): num_round = self.session.vars['paying_round'] group = self.group player_A=group.get_player_by_id(1) player_B=group.get_player_by_id(2) player_C=group.get_player_by_id(3) ded_points=group.in_round(num_round).choice_actual_deduction player_A.payoff=(Constants.endowmentA-group.in_round(num_round).choice_sent-Constants.multiplication_factor*ded_points)*2 player_B.payoff=(group.in_round(num_round).choice_sent)*2 player_C.payoff=(Constants.endowmentC-ded_points)*2 #método para coger el vector de los valores de mensaje para la ronda escogida Groups=self.subsession.get_groups() ##Creencias para la cantidad enviada por A. values_sent_ammount=[] for g in Groups: values_sent_ammount.append(g.in_round(num_round).choice_sent) #Vector de modas repetitions_1 = 0 for i in values_sent_ammount: aparitions = values_sent_ammount.count(i) if aparitions > repetitions_1: repetitions_1= aparitions modes_sent_ammount = [] for i in values_sent_ammount: aparitions = values_sent_ammount.count(i) if aparitions == repetitions_1 and i not in modes_sent_ammount: modes_sent_ammount.append(i) for i in modes_sent_ammount: if group.in_round(num_round).choice_expected_return ==i: player_B.payoff +=c(3)*2 break ##Creencias para los puntos de deducción de C cuando A envía 0 puntos. values_deduction_0 = [] for g in Groups: values_deduction_0.append(g.in_round(num_round).choice_ded_0) # Vector de modas repetitions_2 = 0 for i in values_deduction_0: aparitions = values_deduction_0.count(i) if aparitions > repetitions_2: repetitions_2 = aparitions modes_sent_ammount_0 = [] for i in values_deduction_0: aparitions = values_deduction_0.count(i) if aparitions == repetitions_2 and i not in modes_sent_ammount_0: modes_sent_ammount_0.append(i) if group.in_round(num_round).choice_expected_ded_0 in modes_sent_ammount_0: player_B.payoff += c(1) ##Creencias para los puntos de deducción de C cuando A envía 10 puntos. values_deduction_10 = [] for g in Groups: values_deduction_10.append(g.in_round(num_round).choice_ded_10) # Vector de modas repetitions_3 = 0 for i in values_deduction_10: aparitions = values_deduction_10.count(i) if aparitions > repetitions_3: repetitions_3 = aparitions modes_sent_ammount_10 = [] for i in values_deduction_10: aparitions = values_deduction_10.count(i) if aparitions == repetitions_3 and i not in modes_sent_ammount_10: modes_sent_ammount_10.append(i) if group.in_round(num_round).choice_expected_ded_10 in modes_sent_ammount_10: player_B.payoff += c(1) ##Creencias para los puntos de deducción de C cuando A envía 20 puntos. values_deduction_20 = [] for g in Groups: values_deduction_20.append(g.in_round(num_round).choice_ded_20) # Vector de modas repetitions_4 = 0 for i in values_deduction_20: aparitions = values_deduction_20.count(i) if aparitions > repetitions_4: repetitions_4 = aparitions modes_sent_ammount_20 = [] for i in values_deduction_20: aparitions = values_deduction_20.count(i) if aparitions == repetitions_4 and i not in modes_sent_ammount_20: modes_sent_ammount_20.append(i) if group.in_round(num_round).choice_expected_ded_20 in modes_sent_ammount_20: player_B.payoff += c(1) ##Creencias para los puntos de deducción de C cuando A envía 30 puntos. values_deduction_30 = [] for g in Groups: values_deduction_30.append(g.in_round(num_round).choice_ded_30) # Vector de modas repetitions_5 = 0 for i in values_deduction_30: aparitions = values_deduction_30.count(i) if aparitions > repetitions_5: repetitions_5 = aparitions modes_sent_ammount_30 = [] for i in values_deduction_30: aparitions = values_deduction_30.count(i) if aparitions == repetitions_5 and i not in modes_sent_ammount_30: modes_sent_ammount_30.append(i) if group.in_round(num_round).choice_expected_ded_30 in modes_sent_ammount_30: player_B.payoff += c(1) ##Creencias para los puntos de deducción de C cuando A envía 40 puntos. values_deduction_40 = [] for g in Groups: values_deduction_40.append(g.in_round(num_round).choice_ded_40) # Vector de modas repetitions_6 = 0 for i in values_deduction_40: aparitions = values_deduction_40.count(i) if aparitions > repetitions_6: repetitions_6 = aparitions modes_sent_ammount_40 = [] for i in values_deduction_40: aparitions = values_deduction_40.count(i) if aparitions == repetitions_6 and i not in modes_sent_ammount_40: modes_sent_ammount_40.append(i) if group.in_round(num_round).choice_expected_ded_40 in modes_sent_ammount_40: player_B.payoff += c(1) ##Creencias para los puntos de deducción de C cuando A envía 50 puntos. values_deduction_50 = [] for g in Groups: values_deduction_50.append(g.in_round(num_round).choice_ded_50) # Vector de modas repetitions_7 = 0 for i in values_deduction_50: aparitions = values_deduction_50.count(i) if aparitions > repetitions_7: repetitions_7 = aparitions modes_sent_ammount_50 = [] for i in values_deduction_50: aparitions = values_deduction_50.count(i) if aparitions == repetitions_7 and i not in modes_sent_ammount_50: modes_sent_ammount_50.append(i) if group.in_round(num_round).choice_expected_ded_50 in modes_sent_ammount_50: player_B.payoff += c(1) ##Creencias para el mensaje enviado por A. values_sent_message=[] for g in Groups: values_sent_message.append(g.in_round(num_round).choice_message) values_message_no_None=[x for x in values_sent_message if x is not None] #Saca la moda de dicho vector encontrado sin valores None repetitions=0 for i in values_message_no_None: aparitions=values_message_no_None.count(i) if aparitions>repetitions: repetitions=aparitions modes_messages_A=[] for i in values_message_no_None: aparitions=values_message_no_None.count(i) if aparitions==repetitions and i not in modes_messages_A: modes_messages_A.append(i) if len(values_message_no_None)!= 0 and group.in_round(num_round).choice_expected_message in modes_messages_A: player_B.payoff+=Constants.correct_expectations_message*2 else: player_B.payoff+=c(1) ##Creencias para B en la última ronda (normas sociales) matching = random.randint(0, len(Groups)-2) ##pregunta 1 norms_B_s1=[] for g in Groups: norms_B_s1.append(g.expectation_social_norm_s1_B) norms_B_s1.remove(group.expectation_social_norm_s1_B) if norms_B_s1[matching]==group.expectation_social_norm_s1_B: player_B.payoff+=c(1)*2 ##pregunta 2 norms_B_s2=[] for g in Groups: norms_B_s2.append(g.expectation_social_norm_s2_B) norms_B_s2.remove(group.expectation_social_norm_s2_B) if norms_B_s2[matching]==group.expectation_social_norm_s2_B: player_B.payoff+=c(1)*2 ##pregunta 3 norms_B_s3=[] for g in Groups: norms_B_s3.append(g.expectation_social_norm_s3_B) norms_B_s3.remove(group.expectation_social_norm_s3_B) if norms_B_s3[matching]==group.expectation_social_norm_s3_B: player_B.payoff+=c(1)*2 ##Creencias para C en la última ronda (normas sociales) ##pregunta 1 norms_C_s1=[] for g in Groups: norms_C_s1.append(g.expectation_social_norm_s1_C) norms_C_s1.remove(group.expectation_social_norm_s1_C) if norms_C_s1[matching]==group.expectation_social_norm_s1_C: player_C.payoff+=c(1)*2 ##pregunta 2 norms_C_s2 = [] for g in Groups: norms_C_s2.append(g.expectation_social_norm_s2_C) norms_C_s2.remove(group.expectation_social_norm_s2_C) if norms_C_s2[matching] == group.expectation_social_norm_s2_C: player_C.payoff += c(1)*2 ##pregunta 3 norms_C_s3 = [] for g in Groups: norms_C_s3.append(g.expectation_social_norm_s3_C) norms_C_s3.remove(group.expectation_social_norm_s3_C) if norms_C_s3[matching] == group.expectation_social_norm_s3_C: player_C.payoff += c(1)*2 class WaitForAll_2(WaitPage): wait_for_all_groups = True title_text="Por favor espere a que el resto de participantes tomen sus decisiones." body_text ="De vez en cuando (cada 30 segundos aproximadamente), por favor oprima el botón de teclado F5 para refrescar la conexión de su computador con el servidor del experimento, y así poder avanzar más rápidamente." class Results(Page): def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): num_round=self.session.vars['paying_round'] deduction_points=self.group.in_round(num_round).choice_actual_deduction payoff_B=self.group.in_round(num_round).choice_sent #método para coger el vector de los valores de mensaje para la ronda escogida Groups=self.subsession.get_groups() ##Creencias para la cantidad enviada por A. values_sent_message_A="No" payment_message_deduction=0 values_sent_ammount=[] for g in Groups: values_sent_ammount.append(g.in_round(num_round).choice_sent) #Vector de modas repetitions_1 = 0 for i in values_sent_ammount: aparitions = values_sent_ammount.count(i) if aparitions > repetitions_1: repetitions_1= aparitions modes_sent_ammount = [] for i in values_sent_ammount: aparitions = values_sent_ammount.count(i) if aparitions == repetitions_1 and i not in modes_sent_ammount: modes_sent_ammount.append(i) if self.group.in_round(num_round).choice_expected_return in modes_sent_ammount: payment_message_deduction+= 3 values_sent_message_A="Sí" ##Creencias para los puntos de deducción de C cuando A envía 0 puntos. values_deduction_message_0="No" values_deduction_0 = [] for g in Groups: values_deduction_0.append(g.in_round(num_round).choice_ded_0) # Vector de modas repetitions_2 = 0 for i in values_deduction_0: aparitions = values_deduction_0.count(i) if aparitions > repetitions_2: repetitions_2 = aparitions modes_sent_ammount_0 = [] for i in values_deduction_0: aparitions = values_deduction_0.count(i) if aparitions == repetitions_2 and i not in modes_sent_ammount_0: modes_sent_ammount_0.append(i) if self.group.in_round(num_round).choice_expected_ded_0 in modes_sent_ammount_0: payment_message_deduction += 0.5 values_deduction_message_0="Sí" ##Creencias para los puntos de deducción de C cuando A envía 10 puntos. values_deduction_message_10="No" values_deduction_10 = [] for g in Groups: values_deduction_10.append(g.in_round(num_round).choice_ded_10) # Vector de modas repetitions_3 = 0 for i in values_deduction_10: aparitions = values_deduction_10.count(i) if aparitions > repetitions_3: repetitions_3 = aparitions modes_sent_ammount_10 = [] for i in values_deduction_10: aparitions = values_deduction_10.count(i) if aparitions == repetitions_3 and i not in modes_sent_ammount_10: modes_sent_ammount_10.append(i) if self.group.in_round(num_round).choice_expected_ded_10 in modes_sent_ammount_10: payment_message_deduction += 0.5 values_deduction_message_10="Sí" ##Creencias para los puntos de deducción de C cuando A envía 20 puntos. values_deduction_message_20="No" values_deduction_20 = [] for g in Groups: values_deduction_20.append(g.in_round(num_round).choice_ded_20) # Vector de modas repetitions_4 = 0 for i in values_deduction_20: aparitions = values_deduction_20.count(i) if aparitions > repetitions_4: repetitions_4 = aparitions modes_sent_ammount_20 = [] for i in values_deduction_20: aparitions = values_deduction_20.count(i) if aparitions == repetitions_4 and i not in modes_sent_ammount_20: modes_sent_ammount_20.append(i) if self.group.in_round(num_round).choice_expected_ded_20 in modes_sent_ammount_20: payment_message_deduction += 0.5 values_deduction_message_20="Sí" ##Creencias para los puntos de deducción de C cuando A envía 30 puntos. values_deduction_message_30="No" values_deduction_30 = [] for g in Groups: values_deduction_30.append(g.in_round(num_round).choice_ded_30) # Vector de modas repetitions_5 = 0 for i in values_deduction_30: aparitions = values_deduction_30.count(i) if aparitions > repetitions_5: repetitions_5 = aparitions modes_sent_ammount_30 = [] for i in values_deduction_30: aparitions = values_deduction_30.count(i) if aparitions == repetitions_5 and i not in modes_sent_ammount_30: modes_sent_ammount_30.append(i) if self.group.in_round(num_round).choice_expected_ded_30 in modes_sent_ammount_30: payment_message_deduction += 0.5 values_deduction_message_30="Sí" ##Creencias para los puntos de deducción de C cuando A envía 40 puntos. values_deduction_message_40="No" values_deduction_40 = [] for g in Groups: values_deduction_40.append(g.in_round(num_round).choice_ded_40) # Vector de modas repetitions_6 = 0 for i in values_deduction_40: aparitions = values_deduction_40.count(i) if aparitions > repetitions_6: repetitions_6 = aparitions modes_sent_ammount_40 = [] for i in values_deduction_40: aparitions = values_deduction_40.count(i) if aparitions == repetitions_6 and i not in modes_sent_ammount_40: modes_sent_ammount_40.append(i) if self.group.in_round(num_round).choice_expected_ded_40 in modes_sent_ammount_40: payment_message_deduction += 0.5 values_deduction_message_40="Sí" ##Creencias para los puntos de deducción de C cuando A envía 50 puntos. values_deduction_message_50="No" values_deduction_50 = [] for g in Groups: values_deduction_50.append(g.in_round(num_round).choice_ded_50) # Vector de modas repetitions_7 = 0 for i in values_deduction_50: aparitions = values_deduction_50.count(i) if aparitions > repetitions_7: repetitions_7 = aparitions modes_sent_ammount_50 = [] for i in values_deduction_50: aparitions = values_deduction_50.count(i) if aparitions == repetitions_7 and i not in modes_sent_ammount_50: modes_sent_ammount_50.append(i) if self.group.in_round(num_round).choice_expected_ded_50 in modes_sent_ammount_50: payment_message_deduction += 0.5 values_deduction_message_50="Sí" ##Creencias para el mensaje enviado por A. payment_message_A=c(0) values_sent_message=[] for g in Groups: values_sent_message.append(g.in_round(num_round).choice_message) values_message_no_None=[x for x in values_sent_message if x is not None] #Saca la moda de dicho vector encontrado sin valores None repetitions=0 for i in values_message_no_None: aparitions=values_message_no_None.count(i) if aparitions>repetitions: repetitions=aparitions modes_messages_A=[] for i in values_message_no_None: aparitions=values_message_no_None.count(i) if aparitions==repetitions and i not in modes_messages_A: modes_messages_A.append(i) if len(values_message_no_None)!= 0 and self.group.in_round(num_round).choice_expected_message in modes_messages_A: payment_message_A+=Constants.correct_expectations_message ##Creencias para B en la última ronda (normas sociales) matching = random.randint(0, len(Groups)-2) social_norms_B=c(0) ##pregunta 1 norms_B_s1=[] correct_1_B="No" for g in Groups: norms_B_s1.append(g.expectation_social_norm_s1_B) norms_B_s1.remove(self.group.expectation_social_norm_s1_B) if norms_B_s1[matching]==self.group.expectation_social_norm_s1_B: social_norms_B=+c(1) correct_1_B="Sí" ##pregunta 2 norms_B_s2=[] correct_2_B="No" for g in Groups: norms_B_s2.append(g.expectation_social_norm_s2_B) norms_B_s2.remove(self.group.expectation_social_norm_s2_B) if norms_B_s2[matching]==self.group.expectation_social_norm_s2_B: social_norms_B+=c(1) correct_2_B="Sí" ##pregunta 3 norms_B_s3=[] correct_3_B="No" for g in Groups: norms_B_s3.append(g.expectation_social_norm_s3_B) norms_B_s3.remove(self.group.expectation_social_norm_s3_B) if norms_B_s3[matching]==self.group.expectation_social_norm_s3_B: social_norms_B+=c(1) correct_3_B="Sí" ##Creencias para C en la última ronda (normas sociales) social_norms_C=c(0) ##pregunta 1 norms_C_s1=[] correct_1_C="No" for g in Groups: norms_C_s1.append(g.expectation_social_norm_s1_C) norms_C_s1.remove(self.group.expectation_social_norm_s1_C) if norms_C_s1[matching]==self.group.expectation_social_norm_s1_C: social_norms_C+=c(1) correct_1_C="Sí" ##pregunta 2 norms_C_s2 = [] correct_2_C="No" for g in Groups: norms_C_s2.append(g.expectation_social_norm_s2_C) norms_C_s2.remove(self.group.expectation_social_norm_s2_C) if norms_C_s2[matching] == self.group.expectation_social_norm_s2_C: social_norms_C +=c(1) correct_2_C="Sí" ##pregunta 3 norms_C_s3 = [] correct_3_C="No" for g in Groups: norms_C_s3.append(g.expectation_social_norm_s3_C) norms_C_s3.remove(self.group.expectation_social_norm_s3_C) if norms_C_s3[matching] == self.group.expectation_social_norm_s3_C: social_norms_C +=c(1) correct_3_C="Sí" ##Organización en Labels para la interfaz del jugador. #Normas sociales en la pregunta 1 para B if self.group.expectation_social_norm_s1_B==0: belief_sn_B1="Muy socialmente inapropiada" elif self.group.expectation_social_norm_s1_B==1: belief_sn_B1="Algo socialmente inapropiada" elif self.group.expectation_social_norm_s1_B==2: belief_sn_B1="Algo socialmente apropiada" else: belief_sn_B1="Muy socialmente apropiada" #Normas sociales en la pregunta 2 para B if self.group.expectation_social_norm_s2_B==0: belief_sn_B2="Muy socialmente inapropiada" elif self.group.expectation_social_norm_s2_B==1: belief_sn_B2="Algo socialmente inapropiada" elif self.group.expectation_social_norm_s2_B==2: belief_sn_B2="Algo socialmente apropiada" else: belief_sn_B2="Muy socialmente apropiada" #Normas sociales en la pregunta 3 para B if self.group.expectation_social_norm_s3_B==0: belief_sn_B3="Muy socialmente inapropiada" elif self.group.expectation_social_norm_s3_B==1: belief_sn_B3="Algo socialmente inapropiada" elif self.group.expectation_social_norm_s3_B==2: belief_sn_B3="Algo socialmente apropiada" else: belief_sn_B3="Muy socialmente apropiada" #Normas sociales en la pregunta 1 para C if self.group.expectation_social_norm_s1_C == 0: belief_sn_C1 = "Muy socialmente inapropiada" elif self.group.expectation_social_norm_s1_C == 1: belief_sn_C1 = "Algo socialmente inapropiada" elif self.group.expectation_social_norm_s1_C == 2: belief_sn_C1 = "Algo socialmente apropiada" else: belief_sn_C1 = "Muy socialmente apropiada" # Normas sociales en la pregunta 2 para C if self.group.expectation_social_norm_s2_C == 0: belief_sn_C2 = "Muy socialmente inapropiada" elif self.group.expectation_social_norm_s2_C == 1: belief_sn_C2 = "Algo socialmente inapropiada" elif self.group.expectation_social_norm_s2_C == 2: belief_sn_C2 = "Algo socialmente apropiada" else: belief_sn_C2 = "Muy socialmente apropiada" # Normas sociales en la pregunta 3 para C if self.group.expectation_social_norm_s3_C == 0: belief_sn_C3 = "Muy socialmente inapropiada" elif self.group.expectation_social_norm_s3_C == 1: belief_sn_C3 = "Algo socialmente inapropiada" elif self.group.expectation_social_norm_s3_C == 2: belief_sn_C3 = "Algo socialmente apropiada" else: belief_sn_C3 = "Muy socialmente apropiada" #Invocamos al "grupo" en la ronda aleatoria. Group=self.group.in_round(num_round) #Sobre las expectativas de B de los puntos envíados por A. if Group.expectation_sent==c(0): belief_sent="0 puntos" elif Group.expectation_sent==c(10): belief_sent="10 puntos" elif Group.expectation_sent==c(20): belief_sent="20 puntos" elif Group.expectation_sent==c(30): belief_sent="30 puntos" elif Group.expectation_sent==c(40): belief_sent="40 puntos" else: belief_sent="50 puntos" #Expectativas de B de los puntos de deducción enviados por C belief_ded_0 =str(int(Group.expectation_return_0))+" puntos." belief_ded_10=str(int(Group.expectation_return_10))+" puntos." belief_ded_20=str(int(Group.expectation_return_20))+" puntos." belief_ded_30=str(int(Group.expectation_return_30))+" puntos." belief_ded_40=str(int(Group.expectation_return_40))+" puntos." belief_ded_50=str(int(Group.expectation_return_50))+" puntos." #Expectativas de B sobre el mensaje enviado por A if Group.expectation_message==True: belief_sent_message= 'A' else: belief_sent_message="B" #Modas del mensaje enviado por A: modes_messages_A_label="No" if Group.expectation_message in modes_messages_A: modes_messages_A_label="Sí" groupi = self.group player_A = groupi.get_player_by_id(1) player_B = groupi.get_player_by_id(2) player_C = groupi.get_player_by_id(3) player_A_payoff=int(player_A.payoff)/2 player_B_payoff=int(player_B.payoff)/2 player_C_payoff=int(player_C.payoff)/2 return dict( paying_round=num_round, payoff_B=payoff_B, ded_points=deduction_points, social_norms_C=social_norms_C, social_norms_B=social_norms_B, correct_1_C=correct_1_C, correct_1_B=correct_1_B, correct_2_B=correct_2_B, correct_2_C=correct_2_C, correct_3_B=correct_3_B, correct_3_C=correct_3_C, modes_sent_message=modes_messages_A_label, payment_message_A=payment_message_A, payment_message_deduction=payment_message_deduction, belief_sent_message=belief_sent_message, belief_sent=belief_sent, belief_ded_0=belief_ded_0, belief_ded_10=belief_ded_10, belief_ded_20=belief_ded_20, belief_ded_30=belief_ded_30, belief_ded_40=belief_ded_40, belief_ded_50=belief_ded_50, belief_sn_B1=belief_sn_B1, belief_sn_B2=belief_sn_B2, belief_sn_B3=belief_sn_B3, belief_sn_C1=belief_sn_C1, belief_sn_C2=belief_sn_C2, belief_sn_C3=belief_sn_C3, player_A_payoff=player_A_payoff, player_B_payoff=player_B_payoff, player_C_payoff=player_C_payoff, values_deduction_message_0=values_deduction_message_0, values_deduction_message_10=values_deduction_message_10, values_deduction_message_20=values_deduction_message_20, values_deduction_message_30=values_deduction_message_30, values_deduction_message_40=values_deduction_message_40, values_deduction_message_50=values_deduction_message_50, values_sent_message_A=values_sent_message_A ) class Payment(Page): def vars_for_template(self): group = self.group player_A = group.get_player_by_id(1) player_B = group.get_player_by_id(2) player_C = group.get_player_by_id(3) player_A_payoff=int(player_A.payoff)/2 player_B_payoff=int(player_B.payoff)/2 player_C_payoff=int(player_C.payoff)/2 payment=self.participant.payoff.to_real_world_currency(self.session) total=self.participant.payoff_plus_participation_fee() return dict(player_A_payoff=player_A_payoff, player_B_payoff=player_B_payoff, player_C_payoff=player_C_payoff, payment=payment, total=total) def is_displayed(self): return self.round_number == Constants.num_rounds class Survey(Page): form_model = 'player' form_fields = ["survey_7","survey_8","survey_9","survey_10","survey_11","survey_12"] def is_displayed(self): return self.round_number==1 class AfterSurvey(Page): def vars_for_template(self): total_correct=0 correct_7="No" if self.player.survey_7==60: correct_7="Si" total_correct+=1 correct_8="No" if self.player.survey_8==40: correct_8="Si" total_correct+=1 correct_9="No" if self.player.survey_9==50: correct_9="Si" total_correct+=1 correct_10="No" if self.player.survey_10==15: correct_10="Si" total_correct+=1 correct_11="No" if self.player.survey_11==40: correct_11="Si" total_correct+=1 correct_12="No" if self.player.survey_12==35: correct_12="Si" total_correct+=1 show=False if total_correct<6: show =True return dict( correct_7=correct_7, correct_8=correct_8, correct_9=correct_9, correct_10=correct_10, correct_11=correct_11, correct_12=correct_12, total_correct=total_correct, show=show ) def is_displayed(self): return self.round_number==1 class Survey2(Page): def is_displayed(self): total_correct = 0 correct_7 = "No" if self.player.survey_7 == 60: correct_7 = "Si" total_correct += 1 correct_8 = "No" if self.player.survey_8 == 40: correct_8 = "Si" total_correct += 1 correct_9 = "No" if self.player.survey_9 == 50: correct_9 = "Si" total_correct += 1 correct_10 = "No" if self.player.survey_10 == 15: correct_10 = "Si" total_correct += 1 correct_11 = "No" if self.player.survey_11 == 40: correct_11 = "Si" total_correct += 1 correct_12 = "No" if self.player.survey_12 == 35: correct_12 = "Si" total_correct += 1 show = False if total_correct < 6: show = True return show and self.round_number==1 form_model = "player" form_fields = ["survey_13","survey_14"] def error_message(self, values): if values["survey_13"]!=50 or values["survey_14"]!=10: return "Tiene un error en por lo menos una respuesta." class WaitForAll_3(WaitPage): wait_for_all_groups = True title_text="Por favor espere a que el resto de participantes tomen sus decisiones." body_text ="De vez en cuando (cada 30 segundos aproximadamente), por favor oprima el botón de teclado F5 para refrescar la conexión de su computador con el servidor del experimento, y así poder avanzar más rápidamente." class InstructionsLastRoundB(Page): def is_displayed(self): return self.round_number==Constants.num_rounds and self.player.id_in_group==2 class InstructionsLastRoundC(Page): def is_displayed(self): return self.round_number == Constants.num_rounds and self.player.id_in_group == 3 class AllGroupsWaitPage(WaitPage): def is_displayed(self): return self.round_number==Constants.num_rounds wait_for_all_groups = True class PcProcedure(Page): def is_displayed(self): return self.round_number==1 class SocialNormsB(Page): form_model='group' form_fields=["expectation_social_norm_s1_B","expectation_social_norm_s2_B","expectation_social_norm_s3_B"] def is_displayed(self): return self.round_number==Constants.num_rounds and self.player.id_in_group==2 class SocialNormsC(Page): form_model = 'group' form_fields = ["expectation_social_norm_s1_C", "expectation_social_norm_s2_C", "expectation_social_norm_s3_C"] def is_displayed(self): return self.round_number == Constants.num_rounds and self.player.id_in_group == 3 class instructionsEspecificA(Page): def is_displayed(self): return self.round_number==1 and self.player.id_in_group==1 class instructionsEspecificB(Page): def is_displayed(self): return self.round_number==1 and self.player.id_in_group==2 class InstructionsEspecificC(Page): def is_displayed(self): return self.round_number==1 and self.player.id_in_group==3 class Questionnaire_A(Page): form_model = "player" form_fields = ["q1","q2","q3","q4","q5","q6","q16","q17"] def is_displayed(self): return self.round_number==Constants.num_rounds class Questionnaire_B(Page): form_model = "player" form_fields = ["q7","q8","q9","q10","q11","q12","q13","q14","q15"] def is_displayed(self): return self.round_number==Constants.num_rounds class FinalMessage(Page): def is_displayed(self): return self.round_number==Constants.num_rounds page_sequence = [ Introduction, instructionsEspecificA, instructionsEspecificB, InstructionsEspecificC, PcProcedure, Survey, AfterSurvey, Survey2, WaitForAll_2, Offer, Expectations, Deduction, WaitForAll_3, Message, MessageB, WaitForAll_2, RoundResults, DespuesRondaUno, InstructionsLastRoundB, InstructionsLastRoundC, SocialNormsB, SocialNormsC, AllGroupsWaitPage, ResultsWaitPage, Results, Payment, Questionnaire_A, Questionnaire_B, FinalMessage ]