from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class InstructionsPart2(Page): def is_displayed(self): return self.round_number == 1 def vars_for_template(self): return { 'piece_rate': c(self.player.current_fixed()['piece_pay']), 'task_example': 100, 'decision_number1': Constants.num_pt1_rounds+1, 'decision_number2': Constants.num_pt1_rounds+2, } class TreatmentChoices(Page): form_model = 'player' form_fields = ['tasks_1','checkslider1'] def vars_for_template(self): return { 'min_range': Constants.min_tasks, 'max_range': Constants.max_tasks, 'step': 1, 'rate_piece': self.player.current_fixed()['piece_pay'], 'rate_fixed': self.player.current_fixed()['fixed_pay'], } def checkslider1_error_message(self, value): if not value: return 'Please move the slider for Slider 1 before submitting.' def checkslider2_error_message(self, value): if not value: return 'Please move the slider for Slider 2 before submitting.' def before_next_page(self): if self.round_number == Constants.num_rounds: self.player.TaskRandomization() self.player.getPayoff() self.player.decision_that_counts=str(self.participant.vars['paying_round']) class Moral_Hazard_Treatment(Page): form_model = 'player' form_fields = ['tasks_1','checkslider1'] def vars_for_template(self): return { 'min_range': Constants.min_tasks, 'max_range': Constants.max_tasks, 'step': 1, 'rate_piece': self.player.current_fixed()['piece_pay'], 'rate_fixed': self.player.current_fixed()['fixed_pay'], } def checkslider1_error_message(self, value): if not value: return 'Please move the slider for Slider 1 before submitting.' def checkslider2_error_message(self, value): if not value: return 'Please move the slider for Slider 2 before submitting.' def before_next_page(self): if self.round_number == Constants.num_rounds: self.player.TaskRandomization() self.player.getPayoff() self.player.decision_that_counts=str(self.participant.vars['paying_round']) class ResultsSummary(Page): def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): return { 'paying_round': self.participant.vars['paying_round']+1, 'numTasks_todo': self.participant.vars['tasks_chosen'], 'wage_realized': self.participant.vars['wage_final'], 'show_up_fee': self.session.config['participation_fee'], 'total_earnings': self.participant.payoff_plus_participation_fee(), 'potential_wage_low': self.participant.vars['wage_potential_l'], 'potential_wage_high': self.participant.vars['wage_potential_h'], 'fixed_possible': self.participant.vars['fixed_chosen'] } page_sequence = [ InstructionsPart2, TreatmentChoices, ResultsSummary ]