from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): form_model = 'player' def is_displayed(self): if self.round_number == 1: return True else: return False def vars_for_template(self): treatment = self.participant.vars['treatment'] return dict(treatment = treatment) class Introduction_2(Page): form_model = 'player' def is_displayed(self): if self.round_number == 1: return True else: return False def vars_for_template(self): treatment = self.participant.vars['treatment'] return dict(treatment = treatment) class Math(Page): form_model = 'player' form_fields = ['answer', 'skip_button'] def vars_for_template(self): data = self.session.vars['data'] this_periods_randoms = data[self.round_number-1] # minus one to line up with zero index return dict(this_periods_randoms = this_periods_randoms) class Results(Page): form_model = 'player' def is_displayed(self): if self.player.skip_button == 'Yes': return True elif self.player.skip_button == 'yes': return True elif self.round_number == 600: return True else: return False def vars_for_template(self): payoff_list = [] x = 0 for x in range (0,600): x +=1 payoff_list.append(self.player.in_round(x).set_payoffs()) treatment = self.participant.vars['treatment'] return dict(payoff_list = sum(payoff_list), treatment = treatment) def js_vars(self): payoff_list = [] x = 0 for x in range (0,600): x +=1 payoff_list.append(self.player.in_round(x).set_payoffs()) return dict(payoff = sum(payoff_list)) def app_after_this_page(self, upcoming_apps): return upcoming_apps[0] page_sequence = [Introduction, Introduction_2, Math, Results]