from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Task_Intro(Page): def is_displayed(self): return self.round_number == 1 def vars_for_template(self): return { '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(), 'example_task': self.session.vars['task_example'], 'example_num_zeros': self.session.vars['example_num_zeros'], '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'] } class MainTables(Page): form_model = 'player' form_fields = ['table_submitted_answer'] def vars_for_template(self): player_in_all_rounds = self.player.in_all_rounds() return { 'player_in_all_rounds': player_in_all_rounds, 'number_correct': sum([p.is_correct for p in player_in_all_rounds]), 'target': self.participant.vars['tasks_chosen'], 'attempts': self.player.tries, 'correct_answer': self.player.number_zeros(), 'task_table': self.player.current_table(), } def before_next_page(self): self.player.check_correct() def error_message(self, values): correct = values['table_submitted_answer'] == self.player.number_zeros() if (self.player.tries < 3): if not correct: self.player.tries += 1 return "Incorrect, please try again." def is_displayed(self): player_in_all_rounds = self.player.in_all_rounds() bool1 = sum([p.is_correct for p in player_in_all_rounds]) < self.participant.vars['tasks_chosen'] return bool1 class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): pass class Results(Page): form_model = 'player' form_fields = ['year', 'major', 'gender'] def is_displayed(self): player_in_all_rounds = self.player.in_all_rounds() bool2 = sum([p.is_correct for p in player_in_all_rounds]) == self.participant.vars['tasks_chosen'] return bool2 class Results2(Page): def is_displayed(self): player_in_all_rounds = self.player.in_all_rounds() bool3 = sum([p.is_correct for p in player_in_all_rounds]) == self.participant.vars['tasks_chosen'] return bool3 def vars_for_template(self): return { '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(), } class Goodbye_Page(Page): def is_displayed(self): player_in_all_rounds = self.player.in_all_rounds() bool4 = sum([p.is_correct for p in player_in_all_rounds]) == self.participant.vars['tasks_chosen'] return bool4 page_sequence = [ Task_Intro, MainTables, Results, Results2, Goodbye_Page ]