import sys sys.path.append("..") from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from utils import composer #Throws error in IDE but works ;) class SelectionPage(Page): def is_displayed(self): return self.participant.vars['quiz_successful'] def vars_for_template(self): treatment = self.participant.vars['treatment'] part_set = self.participant.vars['part_set_sequence'][self.round_number-1] round_capacity = 0 decision_table = '' (decision_table, round_capacity) = composer.build_table(part_set, treatment) return{ 'round_part_set_number' : part_set, 'round_capacity' : round_capacity, 'decision_table': decision_table, 'treatment' : self.participant.vars['treatment'], # 'part_that_will_be_drawn' : self.participant.vars['parts_drawn'][self.round_number-1] } form_model = 'player' form_fields = ['round_weight', 'round_value', 'round_selection', 'total_weight', 'total_value'] def before_next_page(self): self.participant.vars['rounds'] = self.round_number self.participant.vars['weight_' + str(self.round_number)] = int(self.player.total_weight) self.participant.vars['value_'+ str(self.round_number)] = int(self.player.total_value) #self.participant.payoff = int(self.player.total_value)/100 self.player.payoff = int(self.player.total_value)/100 page_sequence = [ SelectionPage ]