from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): pass class Offer(Page): def is_displayed(self): return self.player.role() == 'principal' form_model = 'group' form_fields = ['agent_fixed_pay', 'agent_return_share'] class OfferWaitPage(WaitPage): def vars_for_template(self): if self.player.role() == 'agent': body_text = "You are Participant B. Waiting for Participant A to propose a contract." else: body_text = "Waiting for Participant B." return {'body_text': body_text} class Accept(Page): def is_displayed(self): return self.player.role() == 'agent' form_model = 'group' form_fields = ['contract_accepted', 'agent_work_effort'] def error_message(self, values): if values['contract_accepted'] and values['agent_work_effort'] == None: return 'If you accept the contract, you must select a level of effort.' class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Results(Page): pass page_sequence = [Introduction, Offer, OfferWaitPage, Accept, ResultsWaitPage, Results]