from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Welcome(Page): pass class Consent(Page): form_model = 'player' form_fields = ['ProlificID', 'accept'] class Instructions(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'G1G2' form_model = 'player' form_fields = ['q1', 'q2', 'q3'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}.png", image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) def before_next_page(self): if self.group.random_game == 1: self.player.check_answers_g1() elif self.group.random_game == 2 and Constants.excluded_payoff == 10: self.player.check_answers_other_r() elif self.group.random_game == 2 and Constants.other_NS: self.player.check_answers_other_ns() else: self.player.check_answers_g2() class InstructionsBase(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'Baseline' form_model = 'player' form_fields = ['q1', 'q2_base', 'q3'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}{self.player.random_parameters}.png" ) def before_next_page(self): self.player.check_answers_base() class Incorrect(Page): def is_displayed(self): return self.player.accept and self.player.answers_correct < 3 and \ self.session.config['G1G2treatment'] == 'G1G2' form_model = 'player' form_fields = ['q1a', 'q2a', 'q3a'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}.png", image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) def before_next_page(self): if self.group.random_game == 1: self.player.check_answers_g1a() elif self.group.random_game == 2 and Constants.excluded_payoff == 10: self.player.check_answers_other_ra() elif self.group.random_game == 2 and Constants.other_NS: self.player.check_answers_other_nsa() else: self.player.check_answers_g2a() class IncorrectBase(Page): def is_displayed(self): return self.player.accept and self.player.answers_correct < 3 and self.session.config[ 'G1G2treatment'] == 'Baseline' form_model = 'player' form_fields = ['q1a', 'q2_base_a', 'q3a'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}{self.player.random_parameters}.png" ) def before_next_page(self): self.player.check_answers_base_a() class Answers(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'G1G2' \ and self.player.answers_correct < 3 and self.player.answers_correct_a < 3 class AnswersBase(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'Baseline' \ and self.player.answers_correct < 3 and self.player.answers_correct_a < 3 class PreTask(Page): def is_displayed(self): return self.player.accept class TaskA(Page): def is_displayed(self): return self.player.accept and self.player.id_in_group == 1 and self.session.config['G1G2treatment'] == 'G1G2' form_model = 'player' form_fields = ['impose_fee'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee_text.png" ) class TaskB(Page): def is_displayed(self): return self.session.config['G1G2treatment'] == 'G1G2' and self.player.accept and self.player.id_in_group == 2 form_model = 'player' def get_form_fields(self): if self.player.random_order == 1: return ['project_choice_pun', 'project_choice_nopun'] else: return ['project_choice_nopun', 'project_choice_pun'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) # class TaskB2(Page): # def is_displayed(self): # return self.session.config['G1G2treatment'] == 'G1G2' and self.player.accept and self.player.id_in_group == 2 # # form_model = 'player' # form_fields = ['project_choice_nopun'] # # def vars_for_template(self): # return dict( # image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" # ) class TaskBBase(Page): def is_displayed(self): return self.session.config[ 'G1G2treatment'] == 'Baseline' and self.player.accept and self.player.id_in_group == 2 \ and not Constants.base_pilot form_model = 'player' form_fields = ['project_choice_nopun'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}.png" ) class TaskC1(Page): def is_displayed(self): return self.player.accept and self.player.id_in_group == 3 and self.session.config['G1G2treatment'] == 'G1G2' \ and self.player.random_order == 1 form_model = 'player' form_fields = ['norm1_pun_EP', 'norm1_nopun_EP', 'norm1_pun_CP', 'norm1_nopun_CP'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) class TaskC12(Page): def is_displayed(self): return self.player.accept and self.player.id_in_group == 3 and self.session.config['G1G2treatment'] == 'G1G2' \ and self.player.random_order == 2 form_model = 'player' form_fields = ['norm1_pun_EP', 'norm1_nopun_EP', 'norm1_pun_CP', 'norm1_nopun_CP'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) class TaskC2(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot and \ self.player.id_in_group == 3 and self.session.config['G1G2treatment'] == 'G1G2' \ and self.player.random_order == 1 form_model = 'player' form_fields = ['norm2_pun_EP', 'norm2_nopun_EP', 'norm2_pun_CP', 'norm2_nopun_CP'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) class TaskC22(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot and \ self.player.id_in_group == 3 and self.session.config['G1G2treatment'] == 'G1G2' \ and self.player.random_order == 2 form_model = 'player' form_fields = ['norm2_pun_EP', 'norm2_nopun_EP', 'norm2_pun_CP', 'norm2_nopun_CP'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) class TaskC3(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot \ and self.player.id_in_group == 3 and self.session.config['G1G2treatment'] == 'G1G2' form_model = 'player' form_fields = ['more_info_norm'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) class TaskC3Info(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot \ and self.player.id_in_group == 3 and self.session.config['G1G2treatment'] == 'G1G2' \ and self.player.more_info_norm form_model = 'player' form_fields = ['more_info_norm_report'] class TaskC3NoInfo(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot \ and self.player.id_in_group == 3 and self.session.config['G1G2treatment'] == 'G1G2' \ and self.player.random_order == 1 form_model = 'player' form_fields = ['emp_norm_pun_EP', 'emp_norm_nopun_EP'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) class TaskC3NoInfo2(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot \ and self.player.id_in_group == 3 and self.session.config['G1G2treatment'] == 'G1G2' \ and self.player.random_order == 2 form_model = 'player' form_fields = ['emp_norm_pun_EP', 'emp_norm_nopun_EP'] def vars_for_template(self): return dict( image_path_fee=f"instructions/game{self.group.random_game}_fee_nofee.png" ) class TaskCBase1(Page): def is_displayed(self): return self.player.accept and self.player.id_in_group == 3 and self.session.config[ 'G1G2treatment'] == 'Baseline' and not Constants.base_pilot form_model = 'player' form_fields = ['norm1_nopun_EP', 'norm1_nopun_CP'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}.png" ) class TaskCBase2(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot \ and self.player.id_in_group == 3 and self.session.config[ 'G1G2treatment'] == 'Baseline' and not Constants.base_pilot form_model = 'player' form_fields = ['norm2_nopun_EP', 'norm2_nopun_CP'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}.png" ) class TaskCBase3(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot \ and self.player.id_in_group == 3 and self.session.config[ 'G1G2treatment'] == 'Baseline' and not Constants.base_pilot form_model = 'player' form_fields = ['more_info_norm'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}.png" ) class TaskCBase3Info(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot \ and self.player.id_in_group == 3 and self.session.config[ 'G1G2treatment'] == 'Baseline' and self.player.more_info_norm and not Constants.base_pilot form_model = 'player' form_fields = ['more_info_norm_report'] class TaskCBase3NoInfo(Page): def is_displayed(self): return self.player.accept and not Constants.pre_pilot \ and self.player.id_in_group == 3 and self.session.config[ 'G1G2treatment'] == 'Baseline' and not Constants.base_pilot form_model = 'player' form_fields = ['emp_norm_nopun_EP'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}.png" ) class TaskPassive(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'G1G2' and not Constants.base_pilot \ and self.player.id_in_group == 3 or \ (self.player.accept and self.session.config[ 'G1G2treatment'] == 'Baseline' and self.player.id_in_group != 2) and not Constants.base_pilot class BasePilot1(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'Baseline' and Constants.base_pilot form_model = 'player' form_fields = ['base_norm1_EP', 'base_norm1_CP'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}{self.player.random_parameters}.png" ) class BasePilot2(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'Baseline' and Constants.base_pilot form_model = 'player' form_fields = ['base_norm2_EP', 'base_norm2_CP'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}{self.player.random_parameters}.png" ) class BasePilot3(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'Baseline' and Constants.base_pilot form_model = 'player' form_fields = ['base_emp_norm_EP'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}{self.player.random_parameters}.png" ) class BasePilot4(Page): def is_displayed(self): return self.player.accept and self.session.config['G1G2treatment'] == 'Baseline' and Constants.base_pilot form_model = 'player' form_fields = ['base_norm1_min'] def vars_for_template(self): return dict( image_path=f"instructions/game{self.group.random_game}_question.png" ) class Survey(Page): def is_displayed(self): return self.player.accept form_model = 'player' form_fields = ['gender', 'age', 'education', 'religiosity', 'income', 'political', 'open_ended', 'feedback'] class End(Page): def is_displayed(self): return self.player.accept page_sequence = [ # Welcome, Consent, Instructions, InstructionsBase, Incorrect, IncorrectBase, Answers, AnswersBase, PreTask, TaskA, TaskB, TaskBBase, TaskC1, TaskC12, TaskC2, TaskC22, TaskC3, TaskC3Info, TaskC3NoInfo, TaskC3NoInfo2, TaskCBase1, TaskCBase2, TaskCBase3, TaskCBase3Info, TaskCBase3NoInfo, TaskPassive, BasePilot1, BasePilot2, BasePilot3, BasePilot4, Survey, End ]