from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from . import models class charts(Page): form_model = models.Player form_fields = ['percentage_rf', 'percentage_market', ] # @staticmethod # def error_message(player, values): # print('values is', values) # if values['percentage_rf'] + values['percentage_market'] != 100: # return 'The numbers must add up to 100%' # @staticmethod # def investtherest(player, values): # values['percentage_rf'] = float(1 -values['percentage_rf']) # return values['percentage_rf'] # def is_displayed(self): # return: True # def vars_for_template(self) : # specify info for task progress section = int(1) section_total = int(4) section_progress = int(section / section_total * 100) # specify info for progress bar total = Constants.num_rounds page = self.subsession.round_number progress = int(page / total * 100) return { 'section': section, 'section_total': section_total, 'section_progress': section_progress, 'page': page, 'total': total, 'progress': progress, } def js_vars(player): numbers = Constants.returnstest highcharts_series = player.round_number return highcharts_series class treatmentpage(Page): form_model = models.Player form_fields = ['tm_percentage_rf', 'tm_percentage_decoy', 'tm_percentage_market', 'sum_percentage' ] def error_message(self, values): print('values is', values) if values['tm_percentage_rf'] + values['tm_percentage_decoy'] + values['tm_percentage_market'] != 100: return 'Stellen Sie sicher dass Sie genau 100% der 10000€ verteilt haben' # @staticmethod # def error_message(player, values) : # print('values is', values) # if values['tm_percentage_rf'] + values['tm_percentage_decoy'] + values['tm_percentage_market'] != 100: # return 'The numbers must add up to 100%' def vars_for_template(self) : # specify info for task progress section = int(1) section_total = int(4) section_progress = int(section / section_total * 100) # specify info for page progress bar total = 2 page = 2 progress = int(page / total * 100) # sum_percent = sum(self.player.participant.vars['tm_percentage_rf'], self.player.participant.vars['tm_percentage_decoy'], self.player.participant.vars['tm_percentage_market']) return { 'section' : section, 'section_total' : section_total, 'section_progress' : section_progress, 'page' : page, 'total' : total, 'progress' : progress, # 'sum_percent' : sum_percent } class ResultsWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [charts, treatmentpage, ]