from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants def shared_vars(self): num_rounds = Constants.num_rounds return { #'gains': self.player.gains, 'radio_amounts': zip(Constants.list2, Constants.list1), 'round': self.round_number, 'num_questions': num_rounds, } class IntroElicitation(Page): form_model = 'player' form_fields = ['clicked_payoff_info'] def is_displayed(self): return self.player.round_number == 1 and not self.participant.vars['failed_comprehension'] def vars_for_template(self): return shared_vars(self) # def before_next_page(self): # self.player.tests_passed = self.participant.vars['tests_passed'] class ElicitList(Page): def is_displayed(self): return not self.participant.vars['failed_comprehension'] def vars_for_template(self): return shared_vars(self) form_model = 'player' form_fields = ['switching_point'] def before_next_page(self): self.player.set_payoffs() class ElicitValuation(Page): def is_displayed(self): return not self.participant.vars['failed_comprehension'] def vars_for_template(self): return { 'val_up': self.player.switching_point + 1, 'val_low': self.player.switching_point - 1, 'val_up2': self.player.switching_point + 2, 'val_low2': self.player.switching_point - 2, **shared_vars(self) } form_model = 'player' form_fields = ['confidence'] class Wait(Page): def is_displayed(self): return self.round_number != Constants.num_rounds and not self.participant.vars['failed_comprehension'] def vars_for_template(self): return shared_vars(self) timeout_seconds = 2 page_sequence = [ IntroElicitation, ElicitList, ElicitValuation, Wait, ]