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 { 'round': self.round_number, 'num_questions': num_rounds, 'radio_amounts': zip(Constants.list2, Constants.list1), } class IntroLottery(Page): def is_displayed(self): return self.round_number == 1 and self.participant.vars['tests_passed'] def vars_for_template(self): return shared_vars(self) class LotteryList(Page): def is_displayed(self): return self.participant.vars['tests_passed'] def vars_for_template(self): return { 'table_length1': self.player.table_length1(), **shared_vars(self) } form_model = 'player' form_fields = ['switching_point'] def before_next_page(self): self.player.set_switching_point_and_indicator() class LotteryValuation(Page): def is_displayed(self): return self.participant.vars['tests_passed'] def vars_for_template(self): return { 'val_up': int(self.player.switching_point), 'val_low': int(self.player.switching_point - Constants.steps), **shared_vars(self) } form_model = 'player' form_fields = ['confidence'] class Wait(Page): def is_displayed(self): return self.round_number != Constants.num_rounds and self.participant.vars['tests_passed'] def vars_for_template(self): return shared_vars(self) timeout_seconds = 2 page_sequence = [ IntroLottery, LotteryList, LotteryValuation, Wait, ]