from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class MyPage(Page): pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): pass class Results(Page): pass class instruction1(Page): pass class instruction2(Page): def vars_for_template(self): A_failure_prob = Constants.num_Afailure/(Constants.num_Afailure + Constants.num_Bfailure)*100 B_failure_prob = Constants.num_Bfailure/(Constants.num_Afailure + Constants.num_Bfailure)*100 A_failure_prob = int(A_failure_prob) B_failure_prob = int(B_failure_prob) return { 'A_prob': A_failure_prob, 'B_prob': B_failure_prob, 'death_lost': -Constants.period_income_death, } class instruction3(Page): pass class instruction4(Page): def vars_for_template(self): return { 'passed_minutes': Constants.minutes_for_endofround - Constants.minutes_for_dice } class instruction5(Page): def vars_for_template(self): return { 'alive_payoff': Constants.endowment + Constants.period_income_healthy, 'death_payoff': Constants.endowment + Constants.period_income_death, } class summary(Page): def vars_for_template(self): return { 'alive_payoff': Constants.endowment+Constants.period_income_healthy, 'death_payoff': Constants.endowment+Constants.period_income_death, } class quiz(Page): form_model = 'player' form_fields = ['quiz1', 'quiz2', 'quiz3'] def vars_for_template(self): return { 'alive_payoff': Constants.endowment+Constants.period_income_healthy, 'death_payoff': Constants.endowment+Constants.period_income_death, } def error_message(self, values): if values["quiz1"] is None or values["quiz2"] is None or values["quiz3"] is None: return "Please answer all the questions before proceed." elif values["quiz1"] != Constants.quiz1ans or values["quiz2"] != Constants.quiz2ans or values["quiz3"] != Constants.quiz3ans: return "You did not answer all the questions correctly. Please try again." def before_next_page(self): self.player.set_payoff() class ACTION_after_quiz_wait(Page): pass page_sequence = [ instruction1, instruction2, instruction3, instruction4, instruction5, summary, quiz, #ACTION_after_quiz_wait, ]