from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): def is_displayed(self): return self.round_number == 1 class TGQuestion(Page): form_model = models.Player form_fields = ['submitted_answer'] def submitted_answer_choices(self): qc = self.player.current_question() return [ qc['key1'], qc['key2'], qc['key3'], ] def before_next_page(self): self.player.check_correct() class Results(Page): def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): player_in_all_rounds = self.player.in_all_rounds() return { 'player_in_all_rounds': player_in_all_rounds, 'questions_correct': sum([p.is_correct for p in player_in_all_rounds]) } page_sequence = [ Introduction, TGQuestion, Results ]