from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Intro(Page): def is_displayed(self): return self.round_number == 1 def vars_for_template(self): return { 'N_rounds': Constants.num_rounds } class Question(Page): form_model = 'player' form_fields = ['answer', 'confidence'] def answer_choices(self): q = self.player.participant.vars['rounds_order'][self.round_number] return Constants.questions[q]['choices'] def vars_for_template(self): q = self.player.participant.vars['rounds_order'][self.round_number] return { 'round': self.round_number, 'N_rounds': Constants.num_rounds, 'question_text': Constants.questions[q]['text'], 'table': Constants.questions[q]['table'] } def before_next_page(self): q = self.player.participant.vars['rounds_order'][self.round_number] self.player.question = q self.player.solution = Constants.questions[q]['solution'] self.player.answer_correct = self.player.answer == self.player.solution class Confidence(Page): form_model = 'player' form_fields = ['confidence_2', 'confidence_4', 'confidence_6', 'confidence_8'] def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): return { 'N_rounds': Constants.num_rounds, } class End(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [ Intro, Question, Confidence, End ]