from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class Part1_Intro(Page): def is_displayed(self): return self.round_number == 1 def vars_for_template(self): return { 'example_fixed_rate': c(0.15), 'example_piece_rate_l': c(0.1), 'example_piece_rate_h': c(0.2), 'show_up_fee': self.session.config['participation_fee'], 'example_tasks_chosen': 50, 'earnings_fixed': c(0.15)*50, 'total_pay_fixed': c(0.15)*50+self.session.config['participation_fee'], 'earnings_piece': c(0.2)*50, 'total_pay_piece': c(0.2)*50+self.session.config['participation_fee'], 'low_rate': c(0), 'hi_rate': c(0.4), } class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): pass class EffortChoices(Page): form_model = 'player' form_fields = ['tasks_2', 'checkslider'] def vars_for_template(self): return { 'min_range': Constants.min_tasks, 'max_range': Constants.max_tasks, 'step': 1, 'rate_low': self.player.current_wage()['wage_low'], 'rate_high': self.player.current_wage()['wage_high'], 'rate_high_check': self.player.current_wage()['wage_high'] != 0, 'decision_num': self.round_number } def checkslider_error_message(self, value): if not value: return 'Please move the slider before submitting.' def before_next_page(self): if self.round_number == Constants.num_rounds: self.player.ListifyHighWages() self.player.ListifyLowWages() self.player.ListifyTasks1() page_sequence = [ Part1_Intro, EffortChoices, ]