from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants def vars_for_all_templates(self): num_rounds = Constants.num_rounds set = Constants.decisions return { 'fee': c(self.session.config['participation_fee']), 'round': self.round_number, 'exp_duration': self.session.config['exp_duration'], 'num_questions': num_rounds, 'max_duration': self.session.config['max_duration'], 'task': self.player.task_identifier, 'endowment': c(self.player.endowment), 'every_xth_person_paid': self.session.config['every_xth_person_paid'], 'load_incentive': c(self.session.config['load_incentive']), 'type': set[self.player.task_number]['type'], } class Welcome(Page): def is_displayed(self): return self.round_number == 1 class Consent(Page): def is_displayed(self): return self.round_number == 1 class Payment(Page): def is_displayed(self): return self.round_number == 1 class InstructionsPart1(Page): def is_displayed(self): return self.player.round_number == 1 class InstructionsPart2(Page): def is_displayed(self): return self.player.round_number == 1 class InstructionsConfidence(Page): def is_displayed(self): return self.player.part_round_number == Constants.num_lotteries + 1 class BeginStudy(Page): def is_displayed(self): return self.player.round_number == 1 and not self.participant.vars['failed_comprehension'] and not self.participant.vars['condition_load'] class BeginStudyLoad(Page): def is_displayed(self): return self.player.round_number == 1 and not self.participant.vars['failed_comprehension'] and self.participant.vars['condition_load'] # class InstructionsBinary(Page): # def is_displayed(self): # return self.player.part_round_number == Constants.baseline_decisions + Constants.repeated_lotteries + 1 class LoadSumEntry(Page): def is_displayed(self): return not self.participant.vars['failed_comprehension'] and self.participant.vars['condition_load'] form_model = 'player' form_fields = ['load_guess'] class PriceListStandardLoad(Page): def is_displayed(self): return not self.participant.vars['failed_comprehension'] def vars_for_template(self): return { 'table_length1': self.player.table_length1(), } form_model = 'player' form_fields = [ 'switching_point', # 'load_sum' ] def before_next_page(self): self.player.set_switching_point_and_indicator() if self.player.on_paying_round: self.player.set_payoffs() class Valuation(Page): form_model = 'player' form_fields = ['confidence'] def vars_for_template(self): return { 'val_up': int(self.player.switching_point), 'val_low': int(self.player.switching_point - 1), } def is_displayed(self): return not self.participant.vars['failed_comprehension'] def before_next_page(self): if self.round_number == Constants.num_rounds: self.player.payoff = 2 class Wait(Page): def is_displayed(self): return not self.participant.vars['failed_comprehension'] and not self.participant.vars['condition_load'] timeout_seconds = 3 class WaitLoad(Page): def is_displayed(self): return not self.participant.vars['failed_comprehension'] and self.participant.vars['condition_load'] timeout_seconds = 5 class ComprehensionCheck(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = [ 'qn_lottery', 'qn_list', 'qn_confidence', ] def qn_lottery_error_message(self, value): if value != 1: self.player.qn_lottery_got_wrong = True self.player.failed_comprehension = True self.participant.vars['failed_comprehension'] = True # if value != 1 and self.player.qn_lottery_got_wrong is False and self.player.qn_list_got_wrong is False and self.player.qn_confidence_got_wrong is False: # self.player.qn_lottery_got_wrong = True # return 'This is incorrect. Please try again. You have one more attempt.' # if value != 1 and (self.player.qn_lottery_got_wrong is True or self.player.qn_list_got_wrong is True or self.player.qn_confidence_got_wrong is True): # self.participant.vars['failed_comprehension'] = True # self.player.failed_comprehension = True def qn_list_error_message(self, value): if value != 1: self.player.qn_list_got_wrong = True self.player.failed_comprehension = True self.participant.vars['failed_comprehension'] = True # if value != 1 and self.player.qn_lottery_got_wrong is False and self.player.qn_list_got_wrong is False and self.player.qn_confidence_got_wrong is False: # self.player.qn_list_got_wrong = True # return 'This is incorrect. Please try again. You have one more attempt.' # if value != 1 and (self.player.qn_lottery_got_wrong is True or self.player.qn_list_got_wrong is True or self.player.qn_confidence_got_wrong is True): # self.participant.vars['failed_comprehension'] = True # self.player.failed_comprehension = True def qn_confidence_error_message(self, value): if value != 12: self.player.qn_confidence_got_wrong = True self.player.failed_comprehension = True self.participant.vars['failed_comprehension'] = True # if value != 6 and self.player.qn_lottery_got_wrong is False and self.player.qn_list_got_wrong is False and self.player.qn_confidence_got_wrong is False: # self.player.qn_confidence_got_wrong = True # return 'This is incorrect. Please try again. You have one more attempt.' # if value != 6 and (self.player.qn_lottery_got_wrong is True or self.player.qn_list_got_wrong is True or self.player.qn_confidence_got_wrong is True): # self.participant.vars['failed_comprehension'] = True # self.player.failed_comprehension = True page_sequence = [ Welcome, Consent, InstructionsPart1, InstructionsPart2, Payment, ComprehensionCheck, BeginStudy, BeginStudyLoad, PriceListStandardLoad, LoadSumEntry, Valuation, Wait, WaitLoad, ]