from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Consent(Page): form_model = 'player' form_fields = ['pid'] def is_displayed(self) -> bool: return self.round_number == 1 class Intro(Page): def is_displayed(self) -> bool: return self.round_number == 1 def vars_for_template(self) -> dict: return dict( exchange_rate=self.session.config['real_world_currency_per_point'], show_up=self.session.config['prolific_flat'], flat=c(self.session.config['flat']) ) class Quiz(Page): form_model = 'player' form_fields = ['q1', 'q2', 'q3', 'q4', 'q5', 'q6'] def is_displayed(self) -> bool: return self.round_number == 1 def vars_for_template(self) -> dict: return dict( exchange_rate=self.session.config['real_world_currency_per_point'], show_up=self.session.config['participation_fee'], ) class TransitionToDecision (Page): def is_displayed(self) -> bool: return self.round_number == 1 class Decision(Page): form_model = 'player' form_fields = ['work'] def vars_for_template(self) -> dict: return dict( others=Constants.num_of_other_members, work_infected=Constants.payoff_infected[self.player.round_to_play], work_not_infected=Constants.payoff_not_infected[self.player.round_to_play], prob=[int(i * 100) for i in Constants.probability[self.player.round_to_play]], home=Constants.payoff_home[self.player.round_to_play], exchange_rate=self.session.config['real_world_currency_per_point'], show_up=self.session.config['participation_fee'], social_optimal=1 ) class Results(Page): def is_displayed(self) -> bool: return self.round_number == Constants.num_rounds def before_next_page(self): self.participant.vars['work_history'] = self.player.record_work_home_choice() # print('my work history in decision app is', self.participant.vars['work_history']) page_sequence = [ Consent, Intro, Quiz, TransitionToDecision, Decision, Results]