from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random import json # Pages to display always (common pages) class treatment_choice(Page): form_model = "group" form_fields = ["type", "treatment", "subtreatment"] class Instruction_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.round_number == 1 class Instruction_man(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.round_number == 1 form_model = "group" form_fields = ["slider_practice"] class Treatment(Page): def is_displayed(self): return self.round_number == 1 form_model = "player" form_fields = ["enumerator_ID", "practice", "HHID", "person_id"] ### EX ANTE ########################################################################################## class pe_intropractice_woman_EA(Page): def is_displayed(self): return self.group.type == 'EA' and self.player.id_in_group == 1 and self.round_number == 1 class pe_intropractice_woman_EA_2(Page): def is_displayed(self): return self.group.type == 'EA' and self.player.id_in_group == 1 and self.round_number == 1 class pe_exante_1_w(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EA' and self.round_number == 1 class pe_exante_1_m(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.round_number == 1 class pe_exante_preschedule(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.round_number == 1 # PAGE RANDOMIZATION FOR EXANTE STARTS HERE class pe_exante_schedule_1(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.round_number == self.participant.vars['task_rounds']['1'] form_model = "player" form_fields = ["be01a_man"] def before_next_page(self): self.player.guess_be01a_man() class pe_exante_schedule_2(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.group.subtreatment == 1 and self.round_number == self.participant.vars['task_rounds']['2'] form_model = "player" form_fields = ["be01b_man"] def before_next_page(self): self.player.guess_be01b_man() class pe_exante_schedule_3(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.round_number == self.participant.vars['task_rounds']['3'] form_model = "player" form_fields = ["be02a_man"] def before_next_page(self): self.player.guess_be02a_CAZZO_man() class pe_exante_schedule_4(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA'and self.group.subtreatment == 1 and self.round_number == self.participant.vars['task_rounds']['4'] form_model = "player" form_fields = ["be02b_man"] def before_next_page(self): self.player.guess_be02b_man() ### SPITE PAGES class pe_exante_m_plate_spite(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.round_number == Constants.num_rounds class pe_exante_schedule_sound_spite(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["sound_spite"] class pe_exante_schedule_money_spite(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.group.subtreatment == 1 and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["money_spite"] class ScheduleWaitPage_FAKE(WaitPage): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EA' and self.round_number == Constants.num_rounds title_text = "Waiting for spite 1" body_text = "Waiting for the real schedule 1" ################################ # END RANDOMIZATION EX ANTE class ScheduleWaitPage(WaitPage): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EA' and self.round_number == Constants.num_rounds title_text = "Waiting for spite 2" body_text = "Waiting for the real schedule 2" class pe_exante_2_w(Page): def vars_for_template(self): return self.player.vars_for_template() form_model = "group" form_fields = ["be01"] def before_next_page(self): self.participant.vars['be01'] = self.group.be01 def is_displayed(self): return self.player.id_in_group == 1 and self.group.subtreatment != 1 and self.group.type == 'EA' and self.round_number == Constants.num_rounds class pe_exante_2tr_w(Page): def vars_for_template(self): return self.player.vars_for_template() form_model = "group" form_fields = ["be01"] def before_next_page(self): self.participant.vars['be01'] = self.group.be01 def is_displayed(self): return self.player.id_in_group == 1 and self.group.subtreatment == 1 and self.group.type == 'EA' and self.round_number == Constants.num_rounds class pe_exante_2_w_spite(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EA' and self.round_number == Constants.num_rounds def vars_for_template(self): return self.player.vars_for_template() class RiceWaitPage(WaitPage): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.round_number == Constants.num_rounds title_text = "Waiting for spite 3" body_text = "Waiting for the real schedule 3" class pe_exante_w_outside(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.subtreatment == 2 and self.group.type =='EA' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be03_w"] class pe_exante_3_w_10tk(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EA' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be02"] class pe_exante_4_w(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EA' and self.round_number == Constants.num_rounds class pe_exante_men_jar(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EA' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be03"] class Waitforjar(WaitPage): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EA' and self.round_number == Constants.num_rounds title_text = "Waiting for spite 4" body_text = "Waiting for the real schedule 4" class outside_waitpage(WaitPage): def is_displayed(self): return self.player.id_in_group == 2 and self.group.subtreatment == 2 and self.group.type == 'EA' and self.round_number == Constants.num_rounds title_text = "Waiting for outside 5" body_text = "Waiting for outside 5" ### EX ANTE END ######################################################################################################## ### EX POST COLD ####################################################################################################### class pe_expostcold_1_man(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPC' and self.round_number == 1 class pe_expost_intropractice_woman_EPC(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == 1 form_model = "group" form_fields = ["riceplate_practice"] class pe_expost_intropractice_woman_EPC_2(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == 1 class pe_expostcold_intro_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == 1 class pe_expostcold_1_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be01"] class RiceWaitPage2(WaitPage): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds title_text = "Waiting 6" body_text = "Waiting for the woman to make her choice6" class RiceWaitPage2_round1(WaitPage): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPC' and self.round_number == 1 title_text = "Waiting 7" body_text = "Waiting for the woman to make her choice 7" # fake page only to give the impression to the man that he is actually waiting for smt class pe_man_prerandomization_EPC(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPC' and self.round_number == 1 ### EX POST COLD RANDOMIZATION START class pe_expostcold_2_man(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPC' and self.round_number == self.participant.vars['task_rounds']['1'] form_model = "player" form_fields = ["be01a_man"] class pe_expostcold_2_man_transfer(Page): def is_displayed(self): return self.group.type == 'EPC' and self.group.subtreatment == 1 and self.player.id_in_group == 2 and self.round_number == self.participant.vars['task_rounds']['2'] form_model = "player" form_fields = ["be01b_man"] class pe_expostcold_3_man(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPC' and self.round_number == self.participant.vars['task_rounds']['3'] form_model = "player" form_fields = ["be02a_man"] class pe_expostcold_3_man_transfer(Page): def is_displayed(self): return self.group.type == 'EPC' and self.group.subtreatment == 1 and self.player.id_in_group == 2 and self.round_number == self.participant.vars['task_rounds']['4'] form_model = "group" form_fields = ["be02b_man"] ### EX POST COLD RANDOMIZATION END class ScheduleWaitPage2(WaitPage): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds title_text = "Waiting 8" body_text = "Waiting to get how much you have to listen to the sound 8" class pe_expostcold_2_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds class pe_expostcold_10taka_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be02"] class pe_expostcold_3_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds class pe_expostcold_3_woman_outside(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.group.subtreatment == 2 and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be03_w"] class pe_expostcold_4_man(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be03"] class Waitforjar2(WaitPage): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds title_text = "Waiting 9" body_text = "Waiting for jar 9" class outside_waitpage2(WaitPage): def is_displayed(self): return self.player.id_in_group == 2 and self.group.subtreatment == 2 and self.group.type == 'EPC' and self.round_number == Constants.num_rounds title_text = "Waiting 10" body_text = "Waiting for outside 10" ### EX POST COLD END ################################################################################################### ### EX POST HOT START ################################################################################################## class pe_exposthot_intro_man(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPH' and self.round_number == 1 class pe_expost_intropractice_woman_EPH(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPH' and self.round_number == 1 form_model = "group" form_fields = ["riceplate_practice"] class pe_expost_intropractice_woman_EPH_2(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPH' and self.round_number == 1 class pe_exposthot_1_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be01"] class RiceWaitPage3(WaitPage): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds title_text = "Waiting 11" body_text = "Waiting for the woman to make her choice 11" class pe_exposthot_1_man(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPH' and self.round_number == 1 ### EX POST HOT RANDOMIZATION ########################################################################################## class pe_exposthot_2_man_good1(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPH' and self.round_number == self.participant.vars['task_rounds']['1'] form_model = "group" form_fields = ["be02a_man"] class pe_exposthot_2_man_bad1(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPH' and self.round_number == self.participant.vars['task_rounds']['2'] form_model = "group" form_fields = ["be01a_man"] class pe_exposthot_2_man_good1_transfer(Page): def is_displayed(self): return self.group.type == 'EPH' and self.group.subtreatment == 1 and self.player.id_in_group == 2 and self.round_number == self.participant.vars['task_rounds']['3'] form_model = "group" form_fields = ["be02b_man"] class pe_exposthot_2_man_bad1_transfer(Page): def is_displayed(self): return self.group.type == 'EPH' and self.group.subtreatment == 1 and self.player.id_in_group == 2 and self.round_number == self.participant.vars['task_rounds']['4'] form_model = "group" form_fields = ["be01b_man"] class ScheduleWaitPage3(WaitPage): def is_displayed(self): return self.player.id_in_group == 1 and self.round_number == Constants.num_rounds title_text = "Waiting 12" body_text = "Waiting to get how much you have to listen to the sound 12" class pe_exposthot_3_man(Page): def is_displayed(self): return self.player.id_in_group == 2 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be03"] class Waitforjar3(WaitPage): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds title_text = "Waiting 13" body_text = "Waiting to get how much you have to listen to the sound 13" class pe_exposthot_2a_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds class pe_exposthot_2_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be02"] class pe_exposthot_3_woman(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds class pe_exposthot_3_woman_outside(Page): def is_displayed(self): return self.player.id_in_group == 1 and self.group.subtreatment == 2 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds form_model = "group" form_fields = ["be03_w"] class outside_waitpage3(WaitPage): def is_displayed(self): return self.player.id_in_group == 2 and self.group.subtreatment == 2 and self.group.type == 'EPH' and self.round_number == Constants.num_rounds title_text = "Waiting 14" body_text = "Waiting outside 14" ### EX POST HOT END #################################################################################################### ### END COMMON PAGES ################################################################################################### class pe_end(Page): def vars_for_template(self): return self.player.vars_for_template() def is_displayed(self): return self.group.subtreatment != 1 and self.round_number == Constants.num_rounds class pe_end_tr(Page): def vars_for_template(self): return self.player.vars_for_template() def is_displayed(self): return self.group.subtreatment == 1 and self.round_number == Constants.num_rounds class thank_you(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [ Treatment, Instruction_woman, Instruction_man, pe_intropractice_woman_EA, pe_intropractice_woman_EA_2, pe_exante_1_w, pe_exante_1_m, pe_exante_preschedule, pe_exante_schedule_1, pe_exante_schedule_2, pe_exante_schedule_3, pe_exante_schedule_4, ScheduleWaitPage, pe_exante_2_w, pe_exante_2tr_w, RiceWaitPage, ### SPITE pe_exante_m_plate_spite, pe_exante_schedule_sound_spite, pe_exante_schedule_money_spite, ScheduleWaitPage_FAKE, pe_exante_2_w_spite, ## pe_exante_men_jar, Waitforjar, pe_exante_w_outside, outside_waitpage, pe_exante_3_w_10tk, pe_exante_4_w, # Treatment, # Instruction_woman, # Instruction_man, pe_expostcold_1_man, pe_expost_intropractice_woman_EPC, pe_expost_intropractice_woman_EPC_2, pe_expostcold_intro_woman, pe_expostcold_1_woman, RiceWaitPage2_round1, RiceWaitPage2, pe_man_prerandomization_EPC, pe_expostcold_2_man, pe_expostcold_2_man_transfer, pe_expostcold_3_man, pe_expostcold_3_man_transfer, ScheduleWaitPage2, pe_expostcold_2_woman, pe_expostcold_3_woman_outside, pe_expostcold_10taka_woman, pe_expostcold_3_woman, pe_expostcold_4_man, outside_waitpage2, Waitforjar2, # Treatment, # Instruction_woman, # Instruction_man, pe_exposthot_intro_man, pe_expost_intropractice_woman_EPH, pe_expost_intropractice_woman_EPH_2, pe_exposthot_1_woman, RiceWaitPage3, pe_exposthot_1_man, pe_exposthot_2_man_bad1, pe_exposthot_2_man_bad1_transfer, pe_exposthot_2_man_good1, pe_exposthot_2_man_good1_transfer, pe_exposthot_3_man, Waitforjar3, pe_exposthot_2a_woman, pe_exposthot_3_woman_outside, pe_exposthot_2_woman, pe_exposthot_3_woman, outside_waitpage3, pe_end, pe_end_tr, thank_you ]