from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Intro_Personnel(Page): pass class Control_Question(Page): form_model = 'player' form_fields = ['control1', 'control2', 'control3'] # Before the player reaches the next page, it is evaluated which questions were answered correctly def before_next_page(self): self.player.set_is_control1_correct() self.player.set_is_control2_correct() self.player.set_is_control3_correct() self.player.set_control_score() self.player.set_control_passed() class Candidates_TableAgg_B(Page): form_model = 'player' form_fields = ['candidate1', 'candidate2', 'candidate3', 'complex_buildPortfolio', 'current_C1', 'all_C1', 'all_C2', 'all_C3'] # Here is an error message if the player tries to hire the same candidate for more than one position def error_message(self, values): if (values['candidate1'] == values['candidate2']) or (values['candidate1'] == values['candidate3']) or (values['candidate2'] == values['candidate3']): self.player.error_counter = True return "Please choose three different candidates." class Portfolio_TableAgg_B(Page): form_model = 'player' form_fields = ['choice_selectPortfolio', 'complex_selectPortfolio', 'all_teams', 'current_team'] def before_next_page(self): player = self.player # Before the player reaches the next page, the utility of his portfolio building is calculated for x in [1, 2, 3, 4, 5, 6, 7, 8, 9]: if player.candidate1 == x: player.u_buildPortfolio = player.u_buildPortfolio + Constants.candidate_u_B[x-1] if player.candidate2 == x: player.u_buildPortfolio = player.u_buildPortfolio + Constants.candidate_u_B[x-1] if player.candidate3 == x: player.u_buildPortfolio = player.u_buildPortfolio + Constants.candidate_u_B[x-1] # Before the player reaches the next page, the utility of his portfolio selection is calculated for i in [1, 2, 3]: if player.choice_selectPortfolio == i: player.u_selectPortfolio = player.u_selectPortfolio + Constants.team_u_B[i-1] # Before player reaches next page, calculate payoff player.set_bonuspoints() def app_after_this_page(self, upcoming_apps): if self.participant.vars['treatment'] == 'agg_B': return upcoming_apps[1] page_sequence = [Intro_Personnel, Control_Question, Candidates_TableAgg_B, Portfolio_TableAgg_B]