from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class PaymentInfo(Page): def is_displayed(self): return self.round_number==1 form_model = 'player' form_fields = ['paypal_mail'] pass class Introduction(Page): def is_displayed(self): return self.round_number==1 pass class PracticeQuestions(Page): def is_displayed(self): return self.round_number==1 form_model = 'player' form_fields = ['q1_1', 'q1_2', 'q1_3','q1_4', 'q2_1', 'q2_2', 'q2_3','q2_4', 'q3_1', 'q3_2','q3_3','q3_4', 'q4' ] pass class WaitCorr(WaitPage): def is_displayed(self): return self.round_number==1 def after_all_players_arrive(self): for p in self.group.get_players(): p.correct_ans() pass class CorrectQ(Page): def is_displayed(self): return self.player.inc_q=="None" and self.round_number==1 pass class IncorrectQ(Page): def is_displayed(self): return self.player.inc_q!="None" and self.round_number==1 pass class Decision(Page): def is_displayed(self): return self.player.participant.vars['active']==1 timeout_seconds = 60 form_model = 'player' form_fields = ['choice'] def before_next_page(self): if self.timeout_happened: self.player.choice = '-9' self.player.participant.vars['active'] = 0 def vars_for_template(self): return { 'three': self.player.connections==3, } pass class Inactive(Page): def is_displayed(self): return self.player.participant.vars['active']==0 timeout_seconds = 60 def before_next_page(self): if self.timeout_happened: self.player.act = 0 self.player.choice = '-9' else: self.player.act = 1 self.player.participant.vars['active'] = 1 pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoff() pass class Results(Page): def is_displayed(self): return self.player.choice != '-9' and self.group.no_net != 'True' def vars_for_template(self): return{ 'act': self.player.choice=='active', } pass class NoNet(Page): def is_displayed(self): return self.group.no_net=='True' and self.player.choice!='-9' pass class EndPractice(Page): def is_displayed(self): return self.round_number==Constants.num_rounds def before_next_page(self): for p in self.group.get_players(): p.participant.payoff=0 pass page_sequence = [ PaymentInfo, Introduction, PracticeQuestions, WaitCorr, CorrectQ, IncorrectQ, #Inactive, #Decision, #ResultsWaitPage, #Results, #NoNet, EndPractice ]