from ._builtin import Page from .models import Constants import random class Loading(Page): timeout_seconds = 0.5 def before_next_page(self): if self.round_number == 1: randomized_problems = random.sample(Constants.problems, len(Constants.problems)) self.player.participant.vars['randomized_problems3'] = randomized_problems problem_data = self.player.current_problem() self.player.problem_id = int(problem_data['id']) self.player.problem = problem_data['problem'] class Instructions(Page): def is_displayed(self): return self.round_number == 1 class PracticeSituation1(Page): form_model = 'player' form_fields = ['practice_submitted_choice1'] timeout_seconds = 60.0 def is_displayed(self): return self.round_number == 1 class PracticeSituation2(Page): def is_displayed(self): return self.round_number == 1 class PracticeSituation3(Page): form_model = 'player' form_fields = ['practice_submitted_choice2'] timeout_seconds = 60.0 def is_displayed(self): return self.round_number == 1 class PracticeSituation4(Page): def is_displayed(self): return self.round_number == 1 class Start(Page): def is_displayed(self): return self.round_number == 1 class DecisionSituation(Page): form_model = 'player' form_fields = ['submitted_choice', 'submitted_time'] timeout_seconds = 60.0 class End(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [ Loading, Instructions, PracticeSituation1, PracticeSituation2, PracticeSituation3, PracticeSituation4, Start, DecisionSituation, End ]