from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): pass def is_displayed(self) -> bool: return self.round_number == Constants.num_rounds class Results(Page): def is_displayed(self) -> bool: return self.round_number == Constants.num_rounds class InstructionsSubsession(Page): form_model = 'player' def js_vars(self): return dict( treatment=self.subsession.treatment, returns=Constants.returns, N=Constants.players_per_group, participant=self.participant.id_in_session, round=self.round_number, practice_rounds=Constants.practice_rounds, ) def is_displayed(self) -> bool: return (self.round_number <= 12 and self.round_number % Constants.practice_rounds == 1) or (self.round_number>12 and (self.round_number-12)%Constants.sample_size == 1) class Instructions(Page): form_model = 'player' def js_vars(self): return dict( returns = Constants.returns, N = Constants.players_per_group, participant = self.participant.id_in_session, round = self.round_number, player = self.player.id_in_group, ) def is_displayed(self) -> bool: return self.round_number % Constants.sample_size == 1 class InvestmentGame(Page): form_model = 'player' form_fields = ['choice'] def js_vars(self): return dict( treatment = self.subsession.treatment, returns = Constants.returns, N = Constants.players_per_group, participant = self.participant.id_in_session, round = self.round_number, practice_rounds = Constants.practice_rounds, ) def is_displayed(self) -> bool: return self.round_number > 3*Constants.practice_rounds class Practice(Page): form_model = 'player' form_fields = ['practice_question'] def js_vars(self): return dict( treatment = self.subsession.treatment, returns = Constants.returns, N = Constants.players_per_group, participant = self.participant.id_in_session, round = self.round_number, practice_rounds = Constants.practice_rounds, practice_question_text = self.subsession.practice_question_text, practice_question_answer = self.subsession.practice_question_answer, practice_question_x = self.subsession.practice_question_x, ) def is_displayed(self) -> bool: return self.round_number <= 3*Constants.practice_rounds page_sequence = [Instructions, InstructionsSubsession, Practice, InvestmentGame, ResultsWaitPage, Results]