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 Initial_Brochure(Page): pass class Predator_Instructions_1(Page): def is_displayed(self): return self.player.id_in_group % 2 != 0 class Prey_Instructions_1(Page): def is_displayed(self): return self.player.id_in_group % 2 == 0 class Predator_Instructions_2(Page): def is_displayed(self): return self.player.id_in_group % 2 != 0 class Prey_Instructions_2(Page): def is_displayed(self): return self.player.id_in_group % 2 == 0 class Predator_Test(Page): def is_displayed(self): return self.player.id_in_group % 2 != 0 form_model = models.Player form_fields = ['test_question_{}'. format(ii) for ii in range(1, 5)] def test_question_1_error_message(self, value): if value != 'TRUE': return 'Incorrect Answer' # if self.form_fields[0] != 'TRUE': # return 'Incorrect Answer' def test_question_2_error_message(self): if self.form_fields[1] != 'TRUE': return 'Incorrect Answer' def test_question_3_error_message(self): if self.form_fields[2] != 'TRUE': return 'Incorrect Answer' def test_question_4_error_message(self): if self.form_fields[3] != 'TRUE': return 'Incorrect Answer' class Prey_Test(Page): def is_displayed(self): return self.player.id_in_group % 2 == 0 class Results(Page): pass class Send(Page): form_model = models.Player form_fields = ['player_invest'] class WaitForP1(WaitPage): pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() page_sequence = [ Initial_Brochure, Predator_Instructions_1, Prey_Instructions_1, Predator_Instructions_2, Prey_Instructions_2, Predator_Test, Prey_Test, Send, WaitForP1, ResultsWaitPage, Results, ]