from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class TaskGInstructionsRound1(Page): template_name = 'reduced_sel/GritInstructionsRound1.html' form_model = 'player' form_fields = ['grit_decision_round1'] def vars_for_template(self): return { 'not_creteil': (not self.participant.vars.get('is_creteil')), } class TaskGInstructionsRound2(Page): template_name = 'reduced_sel/GritInstructionsRound2.html' form_model = 'player' form_fields = ['grit_decision_round2'] class TaskG(Page): template_name = 'reduced_sel/GritTask.html' timeout_seconds = 60 * Constants.grit_time_for_task form_model = 'player' class TaskGRound1(TaskG): form_fields = ['grit_num_correct_round1'] def vars_for_template(self): return { 'round1': True, 'grit_choice': self.player.get_grit_round1_realized_choice(), 'table_easy': self.participant.vars['table_easy_round1'], 'table_difficult': self.participant.vars['table_difficult_round1'], } def before_next_page(self): self.player.set_grit_payoff_round1() class TaskGRound2(TaskG): form_fields = ['grit_num_correct_round2'] def vars_for_template(self): return { 'round1': False, 'grit_choice': self.player.grit_decision_round2, 'table_easy': self.participant.vars['table_easy_round2'], 'table_difficult': self.participant.vars['table_difficult_round2'], } def before_next_page(self): self.player.set_grit_payoff_round2() class TaskGResultsRound1(Page): template_name = 'reduced_sel/GritFeedbackRound1.html' def vars_for_template(self): return { 'grit_choice': self.player.get_grit_round1_realized_choice(), 'grit_num_correct': self.player.grit_num_correct_round1, 'grit_payoff': self.player.grit_payoff_round1, } class TaskGResultsRound2(Page): template_name = 'reduced_sel/GritFeedbackRound2.html' def vars_for_template(self): return { 'grit_choice': self.player.grit_decision_round2, 'grit_num_correct': self.player.grit_num_correct_round2, 'grit_payoff': self.player.grit_payoff_round2, } page_sequence = [ TaskGInstructionsRound1, TaskGRound1, TaskGResultsRound1, TaskGInstructionsRound2, TaskGRound2, TaskGResultsRound2, ]