from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants class MyPage(Page): pass class age_gender(Page): def is_displayed(self): return self.round_number == 1 form_model = models.Player form_fields = ['gender', 'age'] class ENG_Initial_Brochure(Page): def is_displayed(self): return self.round_number == 1 class ENG_Predator_Instructions_1(Page): def vars_for_template(self): self.player.whole_shebang() def is_displayed(self): return (self.player.id_in_group % 2 != 0 and self.round_number == 1) or ( self.player.id_in_group % 2 == 0 and self.round_number == (Constants.num_rounds / 4 + 1)) class ENG_Prey_Instructions_1(Page): def vars_for_template(self): self.player.whole_shebang() # self.subsession.ppg_mu_perc() def is_displayed(self): return (self.player.id_in_group % 2 == 0 and self.round_number == 1) or ( self.player.id_in_group % 2 != 0 and self.round_number == (Constants.num_rounds / 4 + 1)) class ENG_Predator_Instructions_2(Page): def is_displayed(self): return (self.player.id_in_group % 2 != 0 and self.round_number == 1) or ( self.player.id_in_group % 2 == 0 and self.round_number == (Constants.num_rounds / 4 + 1)) class ENG_Prey_Instructions_2(Page): def is_displayed(self): return (self.player.id_in_group % 2 == 0 and self.round_number == 1) or ( self.player.id_in_group % 2 != 0 and self.round_number == (Constants.num_rounds / 4 + 1)) class ENG_Predator_Test(Page): def is_displayed(self): return (self.player.id_in_group % 2 != 0 and self.round_number == 1) or ( self.player.id_in_group % 2 == 0 and self.round_number == (Constants.num_rounds / 4 + 1)) form_model = models.Player form_fields = ['test_question_{}'. format(ii) for ii in range(1, 8)] def test_question_1_error_message(self, value): if not (value == 'TRUE'): return 'Incorrect Answer' def test_question_2_error_message(self, value): if not (value == 'TRUE'): return 'Incorrect Answer' def test_question_3_error_message(self, value): if not (value == 'TRUE'): return 'Incorrect Answer' def test_question_4_error_message(self, value): if not (value == 11): return 'Incorrect Answer' def test_question_5_error_message(self, value): if not (value == 0): return 'Incorrect Answer' def test_question_6_error_message(self, value): if not (value == 8): return 'Incorrect Answer' def test_question_7_error_message(self, value): if not (value == 5): return 'Incorrect Answer' class ENG_Prey_Test(Page): def is_displayed(self): return (self.player.id_in_group % 2 == 0 and self.round_number == 1) or ( self.player.id_in_group % 2 != 0 and self.round_number == (Constants.num_rounds / 4 + 1)) form_model = models.Player form_fields = ['test_question_{}'. format(ii) for ii in range(1, 8)] def test_question_1_error_message(self, value): if not (value == 'TRUE'): return 'Incorrect Answer' def test_question_2_error_message(self, value): if not (value == 'TRUE'): return 'Incorrect Answer' def test_question_3_error_message(self, value): if not (value == 'TRUE'): return 'Incorrect Answer' def test_question_4_error_message(self, value): if not (value == 5): return 'Incorrect Answer' def test_question_5_error_message(self, value): if not (value == 6): return 'Incorrect Answer' def test_question_6_error_message(self, value): if not (value == 0): return 'Incorrect Answer' def test_question_7_error_message(self, value): if not (value == 13): return 'Incorrect Answer' class ENG_Results(Page): pass class ENG_Send(Page): form_model = models.Player form_fields = ['player_invest'] def before_next_page(self): self.player.give_me_role() class WaitForP1(WaitPage): pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Switch(Page): def is_displayed(self): return self.round_number == 16 or self.round_number == 31 or self.round_number == 46 class Payout(Page): def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): self.player.whole_shebang() # def after_all_players_arrive(self): self.player.whole_shebang() class Final_page(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [ age_gender, ENG_Initial_Brochure, Switch, ENG_Predator_Instructions_1, ENG_Prey_Instructions_1, ENG_Predator_Instructions_2, ENG_Prey_Instructions_2, ENG_Predator_Test, ENG_Prey_Test, ENG_Send, WaitForP1, ResultsWaitPage, ENG_Results, Payout, Final_page, ]