from otree.api import Currency as c, currency_range from otree.api import safe_json from ._builtin import Page, WaitPage from .models import Constants import random as random class Intro_Page(Page): def is_displayed(self): return self.round_number == 1 class StartRound(Page): # oTree Timer timer_text = 'Time left until the round starts:' timeout_seconds = 5 def vars_for_template(self): return dict(round_num=self.round_number) def js_vars(self): return dict( page_name='StartRound', ) form_model = 'player' form_fields = ['StartRound_warnings'] class Code_Instructions(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = ['Code_Instructions_time_spent','Code_Instructions_warnings'] def js_vars(self): return dict( page_name='Code_Instructions', ) def vars_for_template(self): example_diff = Constants.timeout - Constants.example_time example_payoff = example_diff * Constants.time_rate full_payoff = Constants.pwd_rate * Constants.num_pwd_tasks return dict(example_diff=example_diff, example_payoff=example_payoff, full_payoff=full_payoff) class MathMemory(Page): pass class CodeTask(Page): # oTree Timer timer_text = 'Time left in this round:' timeout_seconds = Constants.timeout def before_next_page(self): self.player.set_payoff() self.player.save_data() def vars_for_template(self): p = self.player if p.production_profile == 'Linear': label = Constants.linear_task[self.round_number-1][0] elif p.production_profile == 'Convex': label = Constants.convex_task[self.round_number-1][0] return dict( pwd_1_label=label[0], pwd_2_label=label[1], pwd_3_label=label[2], pwd_4_label=label[3], pwd_5_label=label[4], pwd_6_label=label[5], pwd_7_label=label[6], pwd_8_label=label[7], pwd_9_label=label[8], pwd_10_label=label[9] ) def js_vars(self): p = self.player if p.production_profile == 'Linear': sol = Constants.linear_task[self.round_number-1][0] elif p.production_profile == 'Convex': sol = Constants.convex_task[self.round_number-1][0] return dict( pwd_solutions_array=sol, page_name='CodeTask', num_pwd_tasks=Constants.num_pwd_tasks ) form_model = 'player' form_fields = [ 'timer_task1', 'new_timer_task1', 'pwd_time', 'total_time', 'pwd_1', 'pwd_2', 'pwd_3', 'pwd_4', 'pwd_5', 'pwd_6', 'pwd_7', 'pwd_8', 'pwd_9', 'pwd_10', 'pwd_time', 'pwd_1_time', 'pwd_2_time', 'pwd_3_time', 'pwd_4_time', 'pwd_5_time', 'pwd_6_time', 'pwd_7_time', 'pwd_8_time', 'pwd_9_time', 'pwd_10_time', 'pwd_1_tries', 'pwd_2_tries', 'pwd_3_tries', 'pwd_4_tries', 'pwd_5_tries', 'pwd_6_tries', 'pwd_7_tries', 'pwd_8_tries', 'pwd_9_tries', 'pwd_10_tries', 'pwd_1_toggles', 'pwd_2_toggles', 'pwd_3_toggles', 'pwd_4_toggles', 'pwd_5_toggles', 'pwd_6_toggles', 'pwd_7_toggles', 'pwd_8_toggles', 'pwd_9_toggles', 'pwd_10_toggles', 'CodeTask_time_spent', 'CodeTask_warnings' ] page_sequence = [ Code_Instructions, StartRound, CodeTask ]