from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import pandas as pd bookkeeper_odds_df = pd.read_excel('prescreening_UK/bookkeeper_odds_part2.xlsx') class Part3Intro(Page): form_model = 'player' form_fields = ['Part3Intro_time'] class MatchBeliefs_a(Page): form_model = 'player' form_fields = ['match_1_win', 'match_1_lose', 'match_1_sum', 'MatchBeliefs_a_time'] def vars_for_template(self): return dict( match_num = 1, home_team1=bookkeeper_odds_df['match1_home_team'].iloc[0], away_team1=bookkeeper_odds_df['match1_away_team'].iloc[0], home_team1_abbv=bookkeeper_odds_df['match1_home_team_abbv'].iloc[0], away_team1_abbv=bookkeeper_odds_df['match1_away_team_abbv'].iloc[0], ) def error_message(self, values): for field_name in ['match_1_win', 'match_1_lose']: if values[field_name] > 99 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' def before_next_page(self): self.player.participant.vars['part2_match_1_win'] = self.player.match_1_win self.player.participant.vars['part2_match_1_lose'] = self.player.match_1_lose class MatchBeliefs_b(Page): form_model = 'player' form_fields = ['match_2_win', 'match_2_lose', 'match_2_sum', 'MatchBeliefs_b_time'] def vars_for_template(self): return dict( match_num = 2, home_team2=bookkeeper_odds_df['match2_home_team'].iloc[0], away_team2=bookkeeper_odds_df['match2_away_team'].iloc[0], home_team2_abbv=bookkeeper_odds_df['match2_home_team_abbv'].iloc[0], away_team2_abbv=bookkeeper_odds_df['match2_away_team_abbv'].iloc[0], ) def error_message(self, values): for field_name in ['match_2_win', 'match_2_lose']: if values[field_name] > 99 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' def before_next_page(self): self.player.participant.vars['part2_match_2_win'] = self.player.match_2_win self.player.participant.vars['part2_match_2_lose'] = self.player.match_2_lose class MatchBeliefs_c(Page): form_model = 'player' form_fields = ['match_3_win', 'match_3_lose', 'match_3_sum', 'MatchBeliefs_c_time'] def vars_for_template(self): return dict( match_num = 3, home_team3=bookkeeper_odds_df['match3_home_team'].iloc[0], away_team3=bookkeeper_odds_df['match3_away_team'].iloc[0], home_team3_abbv=bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], away_team3_abbv=bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] ) def error_message(self, values): for field_name in ['match_3_win', 'match_3_lose']: if values[field_name] > 99 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' def before_next_page(self): self.player.participant.vars['part2_match_3_win'] = self.player.match_3_win self.player.participant.vars['part2_match_3_lose'] = self.player.match_3_lose class MatchBeliefs_d(Page): form_model = 'player' form_fields = ['match_4_win', 'match_4_lose', 'match_4_sum', 'MatchBeliefs_d_time'] def vars_for_template(self): return dict( match_num = 4, home_team4=bookkeeper_odds_df['match4_home_team'].iloc[0], away_team4=bookkeeper_odds_df['match4_away_team'].iloc[0], home_team4_abbv=bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], away_team4_abbv=bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] ) def error_message(self, values): for field_name in ['match_4_win', 'match_4_lose']: if values[field_name] > 99 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' def before_next_page(self): self.player.participant.vars['part2_match_4_win'] = self.player.match_4_win self.player.participant.vars['part2_match_4_lose'] = self.player.match_4_lose page_sequence = [ Part3Intro, MatchBeliefs_a, MatchBeliefs_b, MatchBeliefs_c, MatchBeliefs_d, # MatchBeliefs_e, # MatchBeliefs_f, ]