from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import csv import random class GroupWaitPage(WaitPage): group_by_arrival_time = True def is_displayed(self): return self.round_number == 1 class A_ImportDetails(Page): def is_displayed(self): return self.round_number == 1 #define variables by using data from link def before_next_page(self): part_lab = self.player.participant.label.split("_") self.player.enum_name = int(part_lab[0]) self.player.male = 1 if not (self.player.enum_name % 2) else 0 #use temp variables for type, treatment, subtreatment if part_lab[2] == "bowl": self.player.game_role = 0 elif part_lab[2] == "headset": self.player.game_role = 1 if part_lab[3] == "0": self.group.type = 0 elif part_lab[3] == "1": self.group.type = 1 elif part_lab[3] == "2": self.group.type = 2 if part_lab[4] == "2": self.group.treatment = 2 print(self.group.treatment) elif part_lab[4] =="1": self.group.treatment = 1 print(self.group.treatment) elif part_lab[4] =="0": self.group.treatment = 0 print(self.group.treatment) if part_lab[5] =="1": self.group.subtreatment = 1 print(self.group.subtreatment) elif part_lab[5] =="0": self.group.subtreatment = 0 print(self.group.subtreatment) if part_lab[6] =="00": self.group.twohusbands = 1 self.group.twowives = 0 self.group.oppgender = 0 self.group.oppgendertwo = 0 elif part_lab[6] == "11": self.group.oppgender = 1 self.group.twowives = 0 self.group.twohusbands = 0 self.group.oppgendertwo = 0 elif part_lab[6] == "10": self.group.oppgendertwo = 1 self.group.twowives = 0 self.group.oppgender = 0 self.group.twohusbands = 0 else: self.group.twowives=1 self.group.twohusbands = 0 self.group.oppgender = 0 self.group.oppgendertwo = 0 self.player.HHID = int(part_lab[8]) self.player.PID = int(str(part_lab[9])+str(00)+str(part_lab[0])) self.group.super_game_ID = int(part_lab[9]) #self.group.cv_ante = int(part_lab[8]) self.player.uid = int(part_lab[10]) self.group.eph_elicit_regret = int(part_lab[11]) self.group.elicit_onlook = int(part_lab[12]) self.group.elicit_reason = int(part_lab[13]) self.participant.vars['male'] = self.player.male self.participant.vars['game_role'] = self.player.game_role self.participant.vars['type'] = self.group.type self.participant.vars['treatment'] = self.group.treatment self.participant.vars['subtreatment'] = self.group.subtreatment self.participant.vars['eph_elicit_regret'] = self.group.eph_elicit_regret self.participant.vars['elicit_onlook'] = self.group.elicit_onlook self.participant.vars['elicit_reason'] = self.group.elicit_reason self.session.vars['type'] = self.group.type self.session.vars['treatment'] = self.group.treatment self.session.vars['subtreatment'] = self.group.subtreatment #self.session.vars['cv_ante'] = self.group.cv_ante self.participant.vars['HHID'] = self.player.HHID self.participant.vars['PID'] = self.player.PID self.participant.vars['uid'] = self.player.uid self.session.vars['super_game_ID'] = self.group.super_game_ID if self.group.twohusbands==1: self.player.opp_male=1 elif self.group.twowives==1: self.player.opp_male=0 elif self.group.oppgender==1 and self.player.male==1: self.player.opp_male=0 elif self.group.oppgender==1 and self.player.male==0: self.player.opp_male=1 elif self.group.oppgendertwo==1 and self.player.male==1: self.player.opp_male=0 elif self.group.oppgendertwo==1 and self.player.male==0: self.player.opp_male=1 self.participant.vars['opp_male'] = self.player.opp_male #self.group.diagnostic = self.participant.vars['diagnostic'] #self.session.vars['diagnostic'] = self.participant.vars['diagnostic'] #randomize #share of woman disobey by income order #self.group.h_income_d_first = random.randint(0,1) #self.participant.vars['h_income_d_first'] = self.group.h_income_d_first #randomize ego plate type good asked first #self.group.ego_plate_good_first = random.randint(1,1) #self.participant.vars['ego_plate_good_first'] = self.group.ego_plate_good_first #randomize rounds only once: if self.participant.vars['game_role'] == 1: #shuffle likelihood disobedience if RM/NRM rounds round_number_likelihood = list(range(1, Constants.likelihood_rounds + 1)) random.shuffle(round_number_likelihood) print(round_number_likelihood) #shuffle sound if bad bowl/good bowl rounds round_number_game = list(range(Constants.likelihood_rounds + 1, Constants.likelihood_rounds + Constants.num_schedule_rounds + 1)) random.shuffle(round_number_game) print(round_number_game) round_numbers = (round_number_likelihood + round_number_game) print(round_numbers) self.group.rounds = ','.join(str(r) for r in round_numbers) # set shuffled tasks to players and save is dict for p in self.group.get_players(): p.participant.vars['task_rounds'] = dict(zip(Constants.tasks, round_numbers)) print(p.participant.vars['task_rounds']) class A_RMSWscore(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' def get_form_fields(self): if self.player.male == 1: return ['e_irscore', 'e_irscorecheck'] else: return ['si_irscore', 'si_irscorecheck'] def before_next_page(self): if self.player.male == 1: self.participant.vars['e_irscore'] = self.player.e_irscore self.participant.vars['e_irscorecheck'] = self.player.e_irscorecheck others = self.player.get_others_in_group() for p in others: p.participant.vars['e_score_other'] = self.participant.vars['e_irscore'] else: self.participant.vars['si_irscore'] = self.player.si_irscore self.participant.vars['si_irscorecheck'] = self.player.si_irscorecheck others = self.player.get_others_in_group() for p in others: p.participant.vars['si_score_other'] = self.participant.vars['si_irscore'] def error_message(self, values): if self.player.male == 1: fieldone = values['e_irscore'] fieldtwo = values['e_irscorecheck'] if fieldone != fieldtwo: return "Please go back to SurveyCTO and ensure you inputted the right numbers!" else: fieldone = values['si_irscore'] fieldtwo = values['si_irscorecheck'] if fieldone != fieldtwo: return "Please go back to SurveyCTO and ensure you inputted the right numbers!" class A_RMSW_Threshold(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' def get_form_fields(self): if self.player.male == 1: return ['e_threshold', 'e_threshold_check'] else: return ['si_threshold', 'si_threshold_check'] def before_next_page(self): if self.player.male == 1: self.participant.vars['e_threshold'] = self.player.e_threshold self.participant.vars['e_threshold_check'] = self.player.e_threshold_check self.player.e_high = 1 if self.player.e_irscore >= self.player.e_threshold else 0 self.participant.vars['e_high'] = self.player.e_high print(self.participant.vars['e_irscore']) print(self.participant.vars['e_threshold']) print(self.participant.vars['e_high']) others = self.player.get_others_in_group() else: self.participant.vars['si_threshold'] = self.player.si_threshold self.participant.vars['si_threshold_check'] = self.player.si_threshold_check self.player.si_high = 1 if self.player.si_irscore >= self.player.si_threshold else 0 self.participant.vars['si_high'] = self.player.si_high print(self.participant.vars['si_irscore']) print(self.participant.vars['si_threshold']) print(self.participant.vars['si_high']) # Share the thresholds with other players in the same group group = self.group for p in group.get_players(): if self.player.male == 1: p.participant.vars['e_threshold_other'] = self.participant.vars['e_threshold'] p.participant.vars['e_high_other'] = self.participant.vars['e_high'] else: p.participant.vars['si_threshold_other'] = self.participant.vars['si_threshold'] p.participant.vars['si_high_other'] = self.participant.vars['si_high'] def error_message(self, values): if self.player.male == 1: fieldthree = values['e_threshold'] fieldfour = values['e_threshold_check'] if fieldthree != fieldfour: return "Please go back to SurveyCTO and ensure you inputted the right numbers!" else: fieldthree = values['si_threshold'] fieldfour = values['si_threshold_check'] if fieldthree != fieldfour: return "Please go back to SurveyCTO and ensure you inputted the right numbers!" class A_onlookers_present(Page): def is_displayed(self): return self.round_number == 1 and self.player.game_role == 1 form_model = 'group' form_fields = ['onlookers_present','wristband','pass_key'] def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['onlookers_present'] = self.group.onlookers_present self.participant.vars['wristband'] = self.group.wristband others = self.player.get_others_in_group() for p in others: p.participant.vars['onlookers_present'] = self.group.onlookers_present p.participant.vars['wristband'] = self.group.wristband class A_instructions(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = ['g_plate_pref','pass_key'] def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.player.pass_key = None class A_is_transgression(Page): def is_displayed(self): return self.round_number == 1 and self.player.game_role == 1 form_model = 'group' form_fields = ['is_transgression','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None ######################################################## #### PRACTICE SLIDERS & Understand Qs################### ######################################################## class A_responseSample(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = ['be01a_practice','check_be01a_practice','other_annoying','pass_key'] #change check error messages (combine with below method) def check_be01a_practice_error_message(self, value): if not value: return 'Please make a selection' def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.player.pass_key = None ### SI Questions ######################################################################### #In this page we ask how important it is for the respondent to be a RM/SW, we reveal their score, and we ask #how likely they think they are among the top 5 most RM/SW among 20 people. class A_ego_11_rank(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.round_number == 1 form_model = 'group' form_fields = ['SI_imp','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class A_ego_11_rank_pt2(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.round_number == 1 form_model = 'group' def get_form_fields(self): if self.participant.vars['treatment'] != 0: return ['e_rank','onlook_pres_one','pass_key'] else: return ['e_rank','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank'] = self.group.e_rank others = self.player.get_others_in_group() for p in others: p.participant.vars['e_rank'] = self.group.e_rank if self.participant.vars['treatment'] != 0: self.participant.vars['onlook_pres_one'] = self.group.onlook_pres_one others = self.player.get_others_in_group() for p in others: p.participant.vars['onlook_pres_one'] = self.group.onlook_pres_one class A_ego_11_rank_pub(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['treatment'] != 0 and self.round_number == 1 form_model = 'group' form_fields = ['ego_pub_bean','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['ego_pub_bean'] = self.group.ego_pub_bean class A_ego_11_rank_public_act_bel(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['treatment'] != 0 \ and self.round_number == 1 and self.participant.vars['onlook_pres_one'] == 1 \ and self.participant.vars['elicit_onlook'] == 1 form_model = 'group' form_fields = ['ego_pub_bean_public','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['ego_pub_bean_public'] = self.group.ego_pub_bean_public class A_Lik_Disob_RM(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.round_number == self.participant.vars['task_rounds']['Lik_T1_RM'] form_model = 'group' form_fields = ['plt_type_1_RM_n','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class A_Lik_Disob_NRM(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.round_number == self.participant.vars['task_rounds']['Lik_T1_NRM'] form_model = 'group' form_fields = ['plt_type_1_NRM_n','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class A_Summary_uq_c(Page): def is_displayed(self): return self.round_number == (Constants.likelihood_rounds + 1) and self.participant.vars['game_role'] == 0 form_model = 'player' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class A_CunderstandQ(Page): def is_displayed(self): return self.round_number == (Constants.likelihood_rounds + 1) and self.participant.vars['game_role'] == 0 form_model = 'player' form_fields = ['u_1','u_2','u_3','u_4','pass_key'] def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.player.pass_key = None class A_ego_wait(WaitPage): def is_displayed(self): return self.round_number == (Constants.likelihood_rounds + 1) class A_Beliefs_Update_RM_Disob_new(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['will_upd_t1','will_upd_t0','bel_upd_oth_d0','bel_upd_oth_d1','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['will_upd_t1'] = self.group.will_upd_t1 self.participant.vars['will_upd_t0'] = self.group.will_upd_t1 others = self.player.get_others_in_group() for p in others: p.participant.vars['will_upd_t1'] = self.group.will_upd_t1 p.participant.vars['will_upd_t0'] = self.group.will_upd_t1 class A_Chooser_score_reveal(Page): def is_displayed(self): return self.round_number == (Constants.likelihood_rounds + 1) and self.participant.vars['game_role'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['opp_male'] == 1: return dict( game_role=self.participant.vars['game_role'], opp_male=self.participant.vars['opp_male'], score_opponent=self.participant.vars['e_score_other'] ) else: return dict( game_role=self.participant.vars['game_role'], opp_male=self.participant.vars['opp_male'], score_opponent=self.participant.vars['si_score_other'] ) def before_next_page(self): self.group.pass_key = None class A_Chooser_type_reveal_p(Page): def is_displayed(self): return self.round_number == (Constants.likelihood_rounds + 1) and self.participant.vars['game_role'] == 1 and self.participant.vars['subtreatment'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['opp_male'] == 1: return dict( game_role=self.participant.vars['game_role'], opp_male=self.participant.vars['opp_male'], rank_opponent=self.participant.vars['e_high_other'] ) else: return dict( game_role=self.participant.vars['game_role'], opp_male=self.participant.vars['opp_male'], rank_opponent=self.participant.vars['si_high_other'] ) def before_next_page(self): self.group.pass_key = None class A_Chooser_type_reveal_ch(Page): def is_displayed(self): return self.round_number == (Constants.likelihood_rounds + 1) and self.participant.vars['game_role'] == 0 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['opp_male'] == 1: return dict( game_role=self.participant.vars['game_role'], opp_male=self.participant.vars['opp_male'], rank_opponent=self.participant.vars['e_high_other'] ) else: return dict( game_role=self.participant.vars['game_role'], opp_male=self.participant.vars['opp_male'], rank_opponent=self.participant.vars['si_high_other'] ) def before_next_page(self): self.group.pass_key = None class A_Summary_uq_p(Page): def is_displayed(self): return self.round_number == (Constants.likelihood_rounds + 1) and self.participant.vars['game_role'] == 1 form_model = 'player' form_fields = ['pass_key'] def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.player.pass_key = None class A_PunderstandQ(Page): def is_displayed(self): return self.round_number == (Constants.likelihood_rounds + 1) and self.participant.vars['game_role'] == 1 form_model = 'player' def get_form_fields(self): if self.participant.vars['treatment'] != 0: return ['u_1','u_2','u_3','u_4','u_5','u_6','pass_key'] else: return ['u_1','u_2','u_3','u_4','u_5','u_6','pass_key'] def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.player.pass_key = None ######################################################## #### EA SCHEDULE RANDOMIZATION START ################### ######################################################## ######################################################## #### EA SCHEDULE RANDOMIZATION START#################### ######################################################## #Sound class EATemperPre(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.participant.vars['wristband'] == 1 and \ self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['ea_temper_pre'] def before_next_page(self): self.participant.vars['ea_temper_pre'] = self.group.ea_temper_pre class EATemperPreTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.participant.vars['wristband'] == 1 \ and self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['min_pre_announce','time_pre_two','time_pre','sec_pre_announce','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class EAPSoundBad(Page): def is_displayed(self): return self.participant.vars['type'] == 0 and self.participant.vars['game_role'] == 1 and self.round_number == self.participant.vars['task_rounds']["be01aSB"] form_model = 'group' form_fields = ['be01a','check_be01a', 'pass_key'] def check_be01a_error_message(self, value): if not value: return 'Please make a selection' def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be01a'] = self.group.be01a others = self.player.get_others_in_group() for p in others: p.participant.vars['be01a'] = self.group.be01a self.group.pass_key = None class EAPSoundGood(Page): def is_displayed(self): return self.participant.vars['type'] == 0 and self.participant.vars['game_role'] == 1 and self.round_number == self.participant.vars['task_rounds']["be02aSG"] form_model = 'group' form_fields = ['be02a','check_be02a', 'pass_key'] def check_be02a_error_message(self, value): if not value: return 'Please make a selection' def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be02a'] = self.group.be02a others = self.player.get_others_in_group() for p in others: p.participant.vars['be02a'] = self.group.be02a self.group.pass_key = None class EATemperPostS(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.participant.vars['wristband'] == 1 and \ self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['ea_temper_post_s'] def before_next_page(self): self.participant.vars['ea_temper_post_s'] = self.group.ea_temper_post_s class EATemperPostSTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.participant.vars['wristband'] == 1 and \ self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['min_post_sch','sec_post_sch','time_post_sch','time_post_sch_two','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None #Why sound chosen class EAP_sound_reason(Page): def is_displayed(self): return self.participant.vars['type'] == 0 and self.participant.vars['game_role'] == 1 and self.round_number == (Constants.num_rounds) form_model = 'group' def get_form_fields(self): if self.participant.vars['treatment'] == 0 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other','pass_key'] elif self.participant.vars['treatment'] == 1 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other', 'n_onlookers_sound','pass_key'] elif self.participant.vars['treatment'] == 2 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other', 'n_onlookers_sound','pass_key'] elif self.participant.vars['treatment'] == 1 and self.participant.vars['elicit_reason'] == 0: return ['n_onlookers_sound', 'pass_key'] elif self.participant.vars['treatment'] == 2 and self.participant.vars['elicit_reason'] == 0: return ['n_onlookers_sound', 'pass_key'] else: return ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['onlookers_1'] = self.group.onlookers_1 if self.participant.vars['treatment'] != 0: self.participant.vars['n_onlookers_sound'] = self.group.n_onlookers_sound class EA_Onlookers_listen(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 \ and self.round_number == Constants.num_rounds and \ self.participant.vars['treatment'] == 1 and self.participant.vars['n_onlookers_sound'] != 0 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' # pass javascript variables to later compute sound selected in page def js_vars(self): # if self.session.vars['subtreatment'] != 2: return dict( subtreatment=self.participant.vars['subtreatment'], sound_bad=self.participant.vars['be01a'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None ''' #Punisher selects likelihood of disobedience class EAPLikelihoodD(Page): def is_displayed(self): return self.participant.vars['type'] == 0 and self.participant.vars['game_role'] == 1 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['likelihood_d','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None ''' ######################################################## #### EA SCHEDULE RANDOMIZATION END###################### ######################################################## #Chooser waits for punisher to select schedule class EAWaitPagePSchedules(WaitPage): def is_displayed(self): return self.participant.vars['type'] == 0 and self.round_number == Constants.num_rounds #Chooser listens to the punishers schedule based on their selection class EACScheduleListen(Page): def is_displayed(self): return self.participant.vars['type'] == 0 and self.participant.vars['game_role'] == 0 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' #pass javascript variables to later compute sound selected in page def js_vars(self): #if self.session.vars['subtreatment'] != 2: return dict( subtreatment = self.participant.vars['subtreatment'], sound_bad = self.participant.vars['be01a'], sound_good = self.participant.vars['be02a'] ) #else: # return dict( # subtreatment = self.session.vars['subtreatment'], # sound_bad=self.session.vars['be01a'], # sound_good=self.session.vars['be02a'], # money_bad=self.session.vars['be01b'], # money_good=self.session.vars['be02b'] # ) def before_next_page(self): self.group.pass_key = None class EACselectPlate(Page): def is_displayed(self): return self.participant.vars['game_role'] == 0 and self.participant.vars['type'] == 0 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['be01','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['be01'] = self.group.be01 others = self.player.get_others_in_group() for p in others: p.participant.vars['be01'] = self.group.be01 #Punisher waits till chooser selects a plate class EAWaitPageCselectPlate(WaitPage): def is_displayed(self): return self.participant.vars['type'] == 0 and self.round_number == Constants.num_rounds class EATemperPostAnn(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.participant.vars['wristband'] == 1 and \ self.round_number == (Constants.num_rounds) form_model = 'group' form_fields = ['ea_temper_post_a'] def before_next_page(self): self.participant.vars['ea_temper_post_a'] = self.group.ea_temper_post_a class EATemperPostAnnTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.participant.vars['wristband'] == 1 and \ self.round_number == (Constants.num_rounds) form_model = 'group' form_fields = ['min_post_announce','sec_post_announce','time_post_ann_two','time_post_ann','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None #Announce chooser selection to punisher class EAPAnnounceCselection(Page): def is_displayed(self): return self.participant.vars['type'] == 0 and self.participant.vars['game_role'] == 1 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['onlook_pres_two'] = self.group.onlook_pres_two self.participant.vars['onlookers_2'] = self.group.onlookers_2 class EA_Onlookers_1(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and \ self.round_number == Constants.num_rounds and self.participant.vars['treatment'] != 0 and \ self.participant.vars['n_onlookers_sound'] == 0 form_model = 'group' form_fields = ['onlookers_1', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['onlookers_1'] = self.group.onlookers_1 self.group.pass_key = None class EA_Onlookers_1_Sound(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.round_number == Constants.num_rounds and self.participant.vars['treatment'] != 0 and self.participant.vars['onlookers_1'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['be01'] == 1: return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'] ) elif self.participant.vars['be01'] == 0: return dict( plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None class EA_Likelihood_RMSW_PostS(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.round_number == Constants.num_rounds def get_form_fields(self): if self.participant.vars['treatment'] != 0 and self.participant.vars['onlook_pres_one'] == 1: return ['e_rank_post', 'onlook_pres_two', 'pass_key'] else: return ['e_rank_post', 'pass_key'] form_model = 'group' def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post'] = self.group.e_rank_post others = self.player.get_others_in_group() for p in others: p.participant.vars['e_rank_post'] = self.group.e_rank_post if self.participant.vars['treatment'] != 0 and self.participant.vars['onlook_pres_one'] == 1: self.participant.vars['onlook_pres_two'] = self.group.onlook_pres_two class EA_Likelihood_RMSW_PostS_Pub(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and self.participant.vars['treatment'] != 0 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['e_rank_post_pub', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post_pub'] = self.group.e_rank_post_pub others = self.player.get_others_in_group() for p in others: p.participant.vars['e_rank_post_pub'] = self.group.e_rank_post_pub class EA_Likelihood_RMSW_PostS_Pub_ActBel(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and \ self.participant.vars['treatment'] != 0 and self.round_number == Constants.num_rounds and \ self.participant.vars['onlook_pres_two'] == 1 and self.participant.vars['elicit_onlook'] == 1 form_model = 'group' form_fields = ['e_rank_post_onl', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post_onl'] = self.group.e_rank_post_onl class EA_Onlookers_2(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and \ self.round_number == Constants.num_rounds and self.participant.vars['treatment'] != 0 and \ self.participant.vars['n_onlookers_sound'] == 0 and self.participant.vars['onlookers_1'] == 0 form_model = 'group' form_fields = ['onlookers_2', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['onlookers_2'] = self.group.onlookers_2 self.group.pass_key = None class EA_Onlookers_2_Sound(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 0 and \ self.round_number == Constants.num_rounds and self.participant.vars['treatment'] != 0 and \ self.participant.vars['onlookers_2'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['be01'] == 1: return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'] ) elif self.participant.vars['be01'] == 0: return dict( plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None ############################################################################### ## EA ## ## EA ## ## EA ## ## EA ## ## EA ## ## EA ## ## EA ## ## EA ## ############################################################################### ############################################################################### ## EPC ## ## EPC ## ## EPC ## ## EPC ## ## EPC ## ## EPC ## ## EPC ## ## EPC ## ############################################################################### #Chooser selects a plate for him/herself. class EPCCselectPlate(Page): def is_displayed(self): return self.participant.vars['game_role'] == 0 and self.participant.vars['type'] == 1 and \ self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['be01','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be01'] = self.group.be01 others = self.player.get_others_in_group() for p in others: p.participant.vars['be01'] = self.group.be01 self.group.pass_key = None # The punisher waits until the chooser has selected a plate! class EPCWaitPageCselectPlate(WaitPage): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and \ self.round_number == (Constants.likelihood_rounds + 1) ######################################################## #### EPC SCHEDULE RANDOMIZATION START################### ######################################################## #Sound class EPCTemperPre(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and self.participant.vars['wristband'] == 1 and \ self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['epc_temper_pre'] def before_next_page(self): self.participant.vars['epc_temper_pre'] = self.group.epc_temper_pre class EPCTemperPreTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and self.participant.vars['wristband'] == 1 and \ self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['min_pre_announce','time_pre_two','time_pre','sec_pre_announce','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class EPCPSoundBad(Page): def is_displayed(self): return self.participant.vars['type'] == 1 and self.participant.vars['game_role'] == 1 and \ self.round_number == self.participant.vars['task_rounds']["be01aSB"] form_model = 'group' form_fields = ['be01a','check_be01a', 'pass_key'] def check_be01a_error_message(self, value): if not value: return 'Please make a selection' def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be01a'] = self.group.be01a others = self.player.get_others_in_group() for p in others: p.participant.vars['be01a'] = self.group.be01a self.group.pass_key = None class EPCPSoundGood(Page): def is_displayed(self): return self.participant.vars['type'] == 1 and self.participant.vars['game_role'] == 1 and \ self.round_number == self.participant.vars['task_rounds']["be02aSG"] form_model = 'group' form_fields = ['be02a','check_be02a', 'pass_key'] def check_be02a_error_message(self, value): if not value: return 'Please make a selection' def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be02a'] = self.group.be02a others = self.player.get_others_in_group() for p in others: p.participant.vars['be02a'] = self.group.be02a self.group.pass_key = None class EPCTemperPostS(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and self.participant.vars['wristband'] == 1 and \ self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['epc_temper_post_s'] def before_next_page(self): self.participant.vars['epc_temper_post_s'] = self.group.epc_temper_post_s class EPCTemperPostSTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and self.participant.vars['wristband'] == 1 and \ self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['min_post_sch','sec_post_sch','time_post_sch','time_post_sch_two','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None ######################################################## #### EPC SCHEDULE RANDOMIZATION END##################### ######################################################## #Chooser waits for punisher to select schedule class EPCWaitPagePSchedules(WaitPage): def is_displayed(self): return self.participant.vars['type'] == 1 and self.round_number == Constants.num_rounds # Why sound chosen class EPCP_sound_reason(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and \ self.round_number == (Constants.num_rounds) form_model = 'group' def get_form_fields(self): if self.participant.vars['treatment'] == 0 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other','pass_key'] elif self.participant.vars['treatment'] == 1 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other', 'n_onlookers_sound','pass_key'] elif self.participant.vars['treatment'] == 2 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other', 'n_onlookers_sound','pass_key'] elif self.participant.vars['treatment'] == 1 and self.participant.vars['elicit_reason'] == 0: return ['n_onlookers_sound', 'pass_key'] elif self.participant.vars['treatment'] == 2 and self.participant.vars['elicit_reason'] == 0: return ['n_onlookers_sound', 'pass_key'] else: return ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['onlookers_1'] = self.group.onlookers_1 if self.participant.vars['treatment'] != 0: self.participant.vars['n_onlookers_sound'] = self.group.n_onlookers_sound class EPC_Onlookers_listen(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 \ and self.round_number == Constants.num_rounds and \ self.participant.vars['treatment'] == 1 and self.participant.vars['n_onlookers_sound'] != 0 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' # pass javascript variables to later compute sound selected in page def js_vars(self): # if self.session.vars['subtreatment'] != 2: return dict( subtreatment=self.participant.vars['subtreatment'], sound_bad=self.participant.vars['be01a'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None class EPCPAnnounceCselectionReveal(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and \ self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['onlook_pres_two'] = self.group.onlook_pres_two self.participant.vars['onlookers_2'] = self.group.onlookers_2 class EPCTemperPostAnn(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and self.participant.vars['wristband'] == 1 and \ self.round_number == (Constants.num_rounds) form_model = 'group' form_fields = ['epc_temper_post_a'] def before_next_page(self): self.participant.vars['epc_temper_post_a'] = self.group.epc_temper_post_a class EPCTemperPostAnnTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and self.participant.vars['wristband'] == 1 and \ self.round_number == (Constants.num_rounds) form_model = 'group' form_fields = ['min_post_announce','sec_post_announce','time_post_ann_two','time_post_ann','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class EPC_Onlookers_1(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and \ self.round_number == Constants.num_rounds and self.participant.vars['treatment'] == 1 and \ self.participant.vars['n_onlookers_sound'] == 0 form_model = 'group' form_fields = ['onlookers_1', 'pass_key'] def before_next_page(self): self.participant.vars['onlookers_1'] = self.group.onlookers_1 self.group.pass_key = None def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' class EPC_Onlookers_1_Sound(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 \ and self.round_number == Constants.num_rounds and \ self.participant.vars['treatment'] == 1 and self.participant.vars['onlookers_1'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['be01'] == 1: return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'] ) elif self.participant.vars['be01'] == 0: return dict( plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None class EPC_Likelihood_RMSW_PostS(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 \ and self.round_number == Constants.num_rounds form_model = 'group' def get_form_fields(self): if self.participant.vars['treatment'] != 0 and self.participant.vars['onlook_pres_one'] == 1: return ['e_rank_post', 'onlook_pres_two', 'pass_key'] else: return ['e_rank_post', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post'] = self.group.e_rank_post others = self.player.get_others_in_group() for p in others: p.participant.vars['e_rank_post'] = self.group.e_rank_post if self.participant.vars['treatment'] != 0 and self.participant.vars['onlook_pres_one'] == 1: self.participant.vars['onlook_pres_two'] = self.group.onlook_pres_two class EPC_Likelihood_RMSW_PostS_Pub(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 \ and self.participant.vars['treatment'] != 0 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['e_rank_post_pub', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post_pub'] = self.group.e_rank_post_pub others = self.player.get_others_in_group() for p in others: p.participant.vars['e_rank_post_pub'] = self.group.e_rank_post_pub class EPC_Likelihood_RMSW_PostS_Pub_ActBel(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 \ and self.participant.vars['treatment'] != 0 and self.round_number == Constants.num_rounds \ and self.participant.vars['onlook_pres_two'] == 1 and \ self.participant.vars['elicit_onlook'] == 1 form_model = 'group' form_fields = ['e_rank_post_onl', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post_onl'] = self.group.e_rank_post_pub #Chooser listens to the punishers schedule based on their selection class EPCCScheduleListen(Page): def is_displayed(self): return self.participant.vars['type'] == 1 and self.participant.vars['game_role'] == 0 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' #pass javascript variables to later compute sound selected in page def js_vars(self): return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None class EPC_Onlookers_2(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and \ self.round_number == Constants.num_rounds and self.participant.vars['treatment'] == 1 and \ self.participant.vars['n_onlookers_sound'] == 0 and self.participant.vars['onlookers_1'] == 0 form_model = 'group' form_fields = ['onlookers_2', 'pass_key'] def before_next_page(self): self.participant.vars['onlookers_2'] = self.group.onlookers_2 self.group.pass_key = None def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' class EPC_Onlookers_2_Sound(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 1 and self.round_number == Constants.num_rounds and \ self.participant.vars['treatment'] == 1 and self.participant.vars['onlookers_2'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['be01'] == 1: return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'] ) elif self.participant.vars['be01'] == 0: return dict( plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None ############################################################################### ## EPC ## ## EPC ## ## EPC ## ## EPC ## ## EPC ## ## EPC ## ## EPC ## ## EPC ## ############################################################################### ############################################################################### ## EPH ## ## EPH ## ## EPH ## ## EPH ## ## EPH ## ## EPH ## ## EPH ## ## EPH ## ############################################################################### # The Chooser selects a plate class EPHCselectPlate(Page): def is_displayed(self): return self.participant.vars['game_role'] == 0 and self.participant.vars['type'] == 2 and self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['be01','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be01'] = self.group.be01 others = self.player.get_others_in_group() for p in others: p.participant.vars['be01'] = self.group.be01 self.group.pass_key = None class EPHWaitPageCselectPlate(WaitPage): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == (Constants.likelihood_rounds + 1) class EPHPTemperPre(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['eph_temper_pre'] def before_next_page(self): self.participant.vars['eph_temper_pre'] = self.group.eph_temper_pre class EPHPTemperPreTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.participant.vars['wristband'] == 1 and self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['min_pre_announce','time_pre_two','time_pre','sec_pre_announce','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None # Announcing the chooser's selection to the punisher class EPHPAnnounceCselection(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['time_ann','time_ann_two','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class EPHPTemperPostAnn(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['eph_temper_post_a'] def before_next_page(self): self.participant.vars['eph_temper_post_a'] = self.group.eph_temper_post_a class EPHPTemperPostAnnTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.participant.vars['wristband'] == 1 and self.round_number == (Constants.likelihood_rounds + 1) form_model = 'group' form_fields = ['min_post_announce','sec_post_announce','time_post_ann_two','time_post_ann','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None ######################################################## #### EPH SCHEDULE RANDOMIZATION START################### ######################################################## #Sound class EPHPSoundBad(Page): def is_displayed(self): return self.participant.vars['type'] == 2 and self.participant.vars['game_role'] == 1 and self.round_number == self.participant.vars['task_rounds']["be01aSB"] and self.participant.vars['be01'] == 1 form_model = 'group' form_fields = ['be01a','check_be01a','time_sch','time_sch_two', 'pass_key'] def check_be01a_error_message(self, value): if not value: return 'Please make a selection' def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be01a'] = self.group.be01a others = self.player.get_others_in_group() for p in others: p.participant.vars['be01a'] = self.group.be01a self.group.pass_key = None class EPHPSoundGood(Page): def is_displayed(self): return self.participant.vars['type'] == 2 and self.participant.vars['game_role'] == 1 and self.round_number == self.participant.vars['task_rounds']["be02aSG"] and self.participant.vars['be01'] == 0 form_model = 'group' form_fields = ['be02a','check_be02a','time_sch','time_sch_two','pass_key'] def check_be02a_error_message(self, value): if not value: return 'Please make a selection' def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be02a'] = self.group.be02a others = self.player.get_others_in_group() for p in others: p.participant.vars['be02a'] = self.group.be02a self.group.pass_key = None ######################################################## #### EPH SCHEDULE RANDOMIZATION END##################### ######################################################## class EPHPTemperPostS(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['eph_temper_post_s'] def before_next_page(self): self.participant.vars['eph_temper_post_s'] = self.group.eph_temper_post_s self.participant.vars['onlookers_1'] = self.group.onlookers_1 self.participant.vars['onlookers_2'] = self.group.onlookers_2 self.participant.vars['onlookers_3'] = self.group.onlookers_3 self.participant.vars['onlook_pres_two'] = self.group.onlook_pres_two class EPHPTemperPostSTime(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.participant.vars['wristband'] == 1 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['min_post_sch','sec_post_sch','time_post_sch','time_post_sch_two','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None # Why sound chosen and n of onlookers if public class EPHP_sound_reason(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == (Constants.num_rounds) form_model = 'group' def get_form_fields(self): if self.participant.vars['treatment'] == 0 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other','pass_key'] elif self.participant.vars['treatment'] == 1 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other', 'n_onlookers_sound','pass_key'] elif self.participant.vars['treatment'] == 2 and self.participant.vars['elicit_reason'] == 1: return ['sound_reason_1','sound_reason_2','sound_reason_3','sound_reason_4','sound_reason_5','sound_reason_6','sound_reason_7','sound_reason_8','sound_reason_9','sound_reason_10','sound_reason_11','sound_reason_other', 'n_onlookers_sound','pass_key'] elif self.participant.vars['treatment'] == 1 and self.participant.vars['elicit_reason'] == 0: return ['n_onlookers_sound', 'pass_key'] elif self.participant.vars['treatment'] == 2 and self.participant.vars['elicit_reason'] == 0: return ['n_onlookers_sound', 'pass_key'] else: return ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None if self.participant.vars['treatment'] != 0: self.participant.vars['n_onlookers_sound'] = self.group.n_onlookers_sound class EPH_Onlookers_listen(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == Constants.num_rounds and \ self.participant.vars['treatment'] == 1 and self.participant.vars['n_onlookers_sound'] != 0 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['be01'] == 1: return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'] ) elif self.participant.vars['be01'] == 0: return dict( plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None class EPH_Onlookers_1(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and \ self.round_number == Constants.num_rounds and self.participant.vars['treatment'] != 0 \ and self.participant.vars['n_onlookers_sound'] == 0 form_model = 'group' form_fields = ['onlookers_1', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['onlookers_1'] = self.group.onlookers_1 self.group.pass_key = None class EPH_Onlookers_1_Sound(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == Constants.num_rounds and \ self.participant.vars['treatment'] == 1 and self.participant.vars['onlookers_1'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['be01'] == 1: return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'] ) elif self.participant.vars['be01'] == 0: return dict( plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None class EPH_Likelihood_RMSW_PostS(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 \ and self.round_number == Constants.num_rounds form_model = 'group' def get_form_fields(self): if self.participant.vars['treatment'] != 0 and self.participant.vars['onlook_pres_one'] == 1 : return ['e_rank_post', 'onlook_pres_two', 'pass_key'] else: return ['e_rank_post', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post'] = self.group.e_rank_post others = self.player.get_others_in_group() for p in others: p.participant.vars['e_rank_post'] = self.group.e_rank_post if self.participant.vars['treatment'] != 0 and self.participant.vars['onlook_pres_one'] == 1: self.participant.vars['onlook_pres_two'] = self.group.onlook_pres_two class EPH_Likelihood_RMSW_PostS_Pub(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 \ and self.participant.vars['treatment'] != 0 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['e_rank_post_pub', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post_pub'] = self.group.e_rank_post_pub others = self.player.get_others_in_group() for p in others: p.participant.vars['e_rank_post_pub'] = self.group.e_rank_post_pub class EPH_Likelihood_RMSW_PostS_Pub_ActBel(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 \ and self.participant.vars['treatment'] != 0 and self.round_number == Constants.num_rounds \ and self.participant.vars['onlook_pres_two'] == 1 and \ self.participant.vars['elicit_onlook'] == 1 form_model = 'group' form_fields = ['e_rank_post_onl', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None self.participant.vars['e_rank_post_onl'] = self.group.e_rank_post_pub class EPH_Onlookers_2(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and \ self.round_number == Constants.num_rounds and self.participant.vars['treatment'] != 0 and \ self.participant.vars['n_onlookers_sound'] == 0 and self.participant.vars['onlookers_1'] == 0 form_model = 'group' form_fields = ['onlookers_2', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['onlookers_2'] = self.group.onlookers_2 self.group.pass_key = None class EPH_Onlookers_2_Sound(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == Constants.num_rounds \ and self.participant.vars['treatment'] == 1 and self.participant.vars['onlookers_2'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['be01'] == 1: return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'] ) elif self.participant.vars['be01'] == 0: return dict( plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'] ) def before_next_page(self): self.group.pass_key = None class EPHPRegret(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == Constants.num_rounds and self.participant.vars['eph_elicit_regret'] == 1 form_model = 'group' form_fields = ['be_sound_eph_regret','pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be_sound_eph_regret'] = self.group.be_sound_eph_regret self.group.pass_key = None others = self.player.get_others_in_group() for p in others: p.participant.vars['be_sound_eph_regret'] = self.group.be_sound_eph_regret def js_vars(self): if self.participant.vars['be01'] == 1: return dict( plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'] ) elif self.participant.vars['be01'] == 0: return dict( plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'] ) class EPHPRegretSound(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',0) == 1 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['be_sound_eph_post','check_be_sound_eph_post','pass_key'] def check_be_sound_eph_post_error_message(self, value): if not value: return 'Please make a selection' def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['be_sound_eph_post'] = self.group.be_sound_eph_post self.group.pass_key = None others = self.player.get_others_in_group() for p in others: p.participant.vars['be_sound_eph_post'] = self.group.be_sound_eph_post class EPH_Onlookers_3(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and \ self.round_number == Constants.num_rounds and self.participant.vars['treatment'] != 0 and \ self.participant.vars['n_onlookers_sound'] == 0 and self.participant.vars['onlookers_1'] == 0 and \ self.participant.vars['onlookers_2'] == 0 form_model = 'group' form_fields = ['onlookers_3', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.participant.vars['onlookers_3'] = self.group.field_maybe_none('onlookers_3') self.group.pass_key = None class EPH_Onlookers_3_Sound(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['type'] == 2 and self.round_number == Constants.num_rounds and \ self.participant.vars['treatment'] == 1 and self.participant.vars['onlookers_3'] == 1 form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' # Note: Initial eph_elicit_regret set to 1 so that I don't have to delete it. def js_vars(self): print(self.participant.vars['eph_elicit_regret']) if self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( eph_elicit_regret = self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( eph_elicit_regret = self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) if self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',1) == 0\ and self.participant.vars['be01'] == 1: return dict( eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',1) == 0\ and self.participant.vars['be01'] == 0: return dict( eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',1) == 1\ and self.participant.vars['be01'] == 1: return dict( eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], sound_regret = self.participant.vars['be_sound_eph_post'], ) elif self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',1) == 1\ and self.participant.vars['be01'] == 0: return dict( eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], sound_regret=self.participant.vars['be_sound_eph_post'], ) def before_next_page(self): self.group.pass_key = None #Chooser waits for punisher to select schedule class EPHWaitPagePSchedules(WaitPage): def is_displayed(self): return self.participant.vars['type'] == 2 and self.round_number == Constants.num_rounds #Chooser listens to the punishers schedule based on their selection class EPHCScheduleListen(Page): def is_displayed(self): return self.participant.vars['type'] == 2 and self.participant.vars['game_role'] == 0 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None #pass javascript variables to later compute sound selected in page def js_vars(self): print(self.participant.vars['eph_elicit_regret']) if self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( eph_elicit_regret = self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( eph_elicit_regret = self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) if self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',1) == 0\ and self.participant.vars['be01'] == 1: return dict( eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',1) == 0 and self.participant.vars['be01'] == 0: return dict( eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',1) == 1 and self.participant.vars['be01'] == 1: return dict( eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], sound_regret = self.participant.vars['be_sound_eph_post'], ) elif self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars.get('be_sound_eph_regret',1) == 1 and self.participant.vars['be01'] == 0: return dict( eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], sound_regret=self.participant.vars['be_sound_eph_post'], ) ############################################################################### ## EPH ## ## EPH ## ## EPH ## ## EPH ## ## EPH ## ## EPH ## ## EPH ## ## EPH ## ############################################################################### ############################################################################### #OUTSIDE (IF APPLICABLE) BEAD, SOUND LISTEN AND RESULTS ####################### ############################################################################### class PSoundListenDecide(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.round_number == Constants.num_rounds form_model = 'player' form_fields = ['listen_decide_p', 'pass_key'] def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['type'] != 2 and self.participant.vars['be01'] == 1: return dict ( be_type=self.participant.vars['type'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] != 2 and self.participant.vars['be01'] == 0: return dict ( be_type=self.participant.vars['type'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( be_type = self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( be_type = self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 0 \ and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 1 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], sound_regret = self.participant.vars['be_sound_eph_post'] ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 1 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], sound_regret = self.participant.vars['be_sound_eph_post'] ) def before_next_page(self): self.player.pass_key = None self.participant.vars['listen_decide_p'] = self.player.listen_decide_p class CSoundListenDecide(Page): def is_displayed(self): return self.participant.vars['game_role'] == 0 and self.round_number == Constants.num_rounds form_model = 'player' form_fields = ['listen_decide_c', 'pass_key'] def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['type'] != 2 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] != 2 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( be_type = self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( be_type = self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 1 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], sound_regret = self.participant.vars['be_sound_eph_post'] ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 1 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], sound_regret = self.participant.vars['be_sound_eph_post'] ) # subtreatment=self.session.vars['subtreatment'], # c_outside=self.group.field_maybe_none("be03_c") def before_next_page(self): self.player.pass_key = None self.participant.vars['listen_decide_c'] = self.player.listen_decide_c class PSoundListen(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.player.field_maybe_none('listen_decide_p') == 1 and self.round_number == Constants.num_rounds form_model = 'player' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] !=456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['type'] != 2 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] != 2 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 1 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], sound_regret=self.participant.vars['be_sound_eph_post'] ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 1 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], sound_regret=self.participant.vars['be_sound_eph_post'] ) def before_next_page(self): self.player.pass_key = None class CSoundListen(Page): def is_displayed(self): return self.participant.vars['game_role'] == 0 and self.player.field_maybe_none('listen_decide_c') == 1 and self.round_number == Constants.num_rounds form_model = 'player' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def js_vars(self): if self.participant.vars['type'] != 2 and self.participant.vars['be01'] == 1: return dict( be_type = self.participant.vars['type'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] != 2 and self.participant.vars['be01'] == 0: return dict( be_type = self.participant.vars['type'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( be_type = self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( be_type = self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 0 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 0 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 1 and self.participant.vars['be01'] == 1: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_bad=self.participant.vars['be01a'], sound_regret = self.participant.vars['be_sound_eph_post'] ) elif self.participant.vars['type'] == 2 and self.participant.vars['eph_elicit_regret'] == 1 and self.participant.vars['be_sound_eph_regret'] == 1 and self.participant.vars['be01'] == 0: return dict( be_type=self.participant.vars['type'], eph_elicit_regret=self.participant.vars['eph_elicit_regret'], eph_regret=self.participant.vars['be_sound_eph_regret'], plate_selected=self.participant.vars['be01'], sound_good=self.participant.vars['be02a'], sound_regret = self.participant.vars['be_sound_eph_post'] ) def before_next_page(self): self.player.pass_key = None class WaitPagePreResults(WaitPage): def is_displayed(self): return self.round_number == Constants.num_rounds class PResults(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class CResults(Page): def is_displayed(self): return self.participant.vars['game_role'] == 0 and self.round_number == Constants.num_rounds form_model = 'group' form_fields = ['pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.group.pass_key = None class Income_Onlookers(Page): def is_displayed(self): return self.participant.vars['game_role'] == 1 and self.participant.vars['treatment'] != 0 and self.round_number == Constants.num_rounds and self.participant.vars['onlookers_present'] == 1 form_model = 'player' form_fields = ['income_onlookers', 'pass_key'] def error_message(group, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.player.pass_key = None class E_effort(Page): def is_displayed(self): return self.round_number == Constants.num_rounds form_model = 'player' form_fields = ['effort','pass_key'] def error_message(player, values): if values['pass_key'] != 456: return 'Wrong passcode' def before_next_page(self): self.player.pass_key = None class ThankYou(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [ GroupWaitPage, A_ImportDetails, A_RMSWscore, A_RMSW_Threshold, A_onlookers_present, A_instructions, A_is_transgression, A_responseSample, A_ego_11_rank, A_ego_11_rank_pt2, A_ego_11_rank_pub, A_ego_11_rank_public_act_bel, A_Summary_uq_c, A_CunderstandQ, A_ego_wait, A_Lik_Disob_RM, A_Lik_Disob_NRM, A_Beliefs_Update_RM_Disob_new, A_Chooser_score_reveal, A_Chooser_type_reveal_p, A_Chooser_type_reveal_ch, A_Summary_uq_p, A_PunderstandQ, ##################################### #### START EA ###################### #################################### EATemperPre, EATemperPreTime, EAPSoundBad, EAPSoundGood, EATemperPostS, EATemperPostSTime, EAP_sound_reason, EA_Onlookers_listen, EAWaitPagePSchedules, EACScheduleListen, EACselectPlate, EAWaitPageCselectPlate, EATemperPostAnn, EATemperPostAnnTime, EAPAnnounceCselection, EA_Onlookers_1, EA_Onlookers_1_Sound, EA_Likelihood_RMSW_PostS, EA_Likelihood_RMSW_PostS_Pub, EA_Likelihood_RMSW_PostS_Pub_ActBel, EA_Onlookers_2, EA_Onlookers_2_Sound, ##################################### #### START EPC ###################### #################################### EPCCselectPlate, EPCWaitPageCselectPlate, EPCTemperPre, EPCTemperPreTime, EPCPSoundBad, EPCPSoundGood, EPCTemperPostS, EPCTemperPostSTime, EPCP_sound_reason, EPC_Onlookers_listen, EPCWaitPagePSchedules, EPCPAnnounceCselectionReveal, EPCTemperPostAnn, EPCTemperPostAnnTime, EPC_Onlookers_1, EPC_Onlookers_1_Sound, EPC_Likelihood_RMSW_PostS, EPC_Likelihood_RMSW_PostS_Pub, EPC_Likelihood_RMSW_PostS_Pub_ActBel, EPCCScheduleListen, EPC_Onlookers_2, EPC_Onlookers_2_Sound, ######################################## ###### START EPH ####################### ######################################## EPHCselectPlate, EPHWaitPageCselectPlate, EPHPTemperPre, EPHPTemperPreTime, EPHPAnnounceCselection, EPHPTemperPostAnn, EPHPTemperPostAnnTime, EPHPSoundBad, EPHPSoundGood, EPHPTemperPostS, EPHPTemperPostSTime, EPHP_sound_reason, EPH_Onlookers_listen, EPH_Onlookers_1, EPH_Onlookers_1_Sound, EPH_Likelihood_RMSW_PostS, EPH_Likelihood_RMSW_PostS_Pub, EPH_Likelihood_RMSW_PostS_Pub_ActBel, EPH_Onlookers_2, EPH_Onlookers_2_Sound, EPHPRegret, EPHPRegretSound, EPH_Onlookers_3, EPH_Onlookers_3_Sound, EPHWaitPagePSchedules, EPHCScheduleListen, ##################################################################### # Post schedule and plate selection ##################################################################### PSoundListenDecide, CSoundListenDecide, PSoundListen, CSoundListen, WaitPagePreResults, PResults, CResults, Income_Onlookers, E_effort, ThankYou, ]