from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class kicked_for_quiz(Page): def is_displayed(self): return 'quiz_fail' in self.participant.vars class kicked_for_time_out(Page): def is_displayed(self): return 'participant_left' in self.participant.vars class kicked_for_collegue(Page): def is_displayed(self): return 'collegue_left' in self.participant.vars and 'participant_left' not in self.participant.vars def vars_for_template(self): add_payment=(self.participant.vars["kicked_out_period"]-1)*Constants.pay_per_round self.participant.payoff=add_payment return dict( usd_payoff=self.participant.payoff_plus_participation_fee().to_real_world_currency(self.session), no_periods=self.participant.vars["kicked_out_period"]-1, is_first=self.participant.vars["kicked_out_period"]==1, add_payment=add_payment.to_real_world_currency(self.session), participation_fee=self.session.config['participation_fee'], ) class final_page(Page): def vars_for_template(self): return dict( payoff=self.participant.payoff_plus_participation_fee(), payoff_usd=self.participant.payoff_plus_participation_fee().to_real_world_currency(self.session), fixed_usd=self.session.config['participation_fee'].to_real_world_currency(self.session), bonus_usd= self.participant.payoff.to_real_world_currency(self.session) ) page_sequence = [ kicked_for_quiz, kicked_for_time_out, kicked_for_collegue, final_page ]