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 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 Math_Instructions(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = ['Math_Instructions_time_spent','Math_Instructions_warnings'] def js_vars(self): return dict( page_name='Math_Instructions', ) def vars_for_template(self): example_diff = Constants.timeout - Constants.example_time example_payoff = example_diff * Constants.time_rate full_payoff = Constants.math_rate * Constants.num_math_tasks return dict(example_diff=example_diff, example_payoff=example_payoff, full_payoff=full_payoff) class MathMemory(Page): pass class MathTask(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 label = Constants.addition_task[self.round_number-1][0] filler = ' = ' return dict( math_1_label=label[0]+filler, math_2_label=label[1]+filler, math_3_label=label[2]+filler, math_4_label=label[3]+filler, math_5_label=label[4]+filler, math_6_label=label[5]+filler, math_7_label=label[6]+filler, math_8_label=label[7]+filler, math_9_label=label[8]+filler, math_10_label=label[9]+filler, ) def js_vars(self): p = self.player sol = Constants.addition_task[self.round_number-1][1] return dict( math_solutions_array=sol, page_name='MathTask', num_math_tasks=Constants.num_math_tasks ) form_model = 'player' form_fields = [ 'timer_task1', 'new_timer_task1', 'math_time', 'total_time', 'math_1', 'math_2', 'math_3', 'math_4', 'math_5', 'math_6', 'math_7', 'math_8', 'math_9', 'math_10', 'math_time', 'math_1_time', 'math_2_time', 'math_3_time', 'math_4_time', 'math_5_time', 'math_6_time', 'math_7_time', 'math_8_time', 'math_9_time', 'math_10_time', 'math_1_tries', 'math_2_tries', 'math_3_tries', 'math_4_tries', 'math_5_tries', 'math_6_tries', 'math_7_tries', 'math_8_tries', 'math_9_tries', 'math_10_tries', 'MathTask_time_spent', 'MathTask_warnings' ] class Concave_Math(MathMemory): pass page_sequence = [ Math_Instructions, StartRound, MathTask ]