from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): def vars_for_template(self): return dict( conversion=self.session.config['real_world_currency_per_point'] ) class Instructions(Page): pass class RolesWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_roles() class Owner_Offer(Page): form_model = 'player' form_fields = ['offer_fixed_wage', 'offer_bonus', 'offer_effort'] class OfferWaitPage(WaitPage): pass class Expert_Decision(Page): form_model = 'player' form_fields = ['decision'] def vars_for_template(self): p1, p2 = self.group.get_players() if self.player.id_in_group == 1: return dict( offer_fixed_wage_other=p2.offer_fixed_wage, offer_bonus_other=p2.offer_bonus, offer_effort_other=p2.offer_effort, ) else: return dict( offer_fixed_wage_other=p1.offer_fixed_wage, offer_bonus_other=p1.offer_bonus, offer_effort_other=p1.offer_effort, ) class Expert_Effort(Page): form_model = 'player' form_fields = ['chosen_effort'] def is_displayed(self): return self.player.decision def vars_for_template(self): p1, p2 = self.group.get_players() if self.player.id_in_group == 1: return dict( offer_fixed_wage_other=p2.offer_fixed_wage, offer_bonus_other=p2.offer_bonus, offer_effort_other=p2.offer_effort, ) else: return dict( offer_fixed_wage_other=p1.offer_fixed_wage, offer_bonus_other=p1.offer_bonus, offer_effort_other=p1.offer_effort, ) class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Results(Page): pass page_sequence = [ Introduction, Instructions, RolesWaitPage, Owner_Offer, OfferWaitPage, Expert_Decision, Expert_Effort, ResultsWaitPage, Results, ]