from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class new_step(Page): pass class p1_consigne(Page): pass class choix_asso(Page): form_model = 'player' form_fields = ['association_choice'] def vars_for_template(self): return { 'associations': self.participant.vars['associations'] } def before_next_page(self): self.player.association_choice = self.request.POST.get('association_choice') self.player.chosen_asso() class new_step2(Page): pass class p2_consigne_normalisation(Page): pass # X NORMALIZATION class normalization_x(Page): form_model = 'player' def get_form_fields(self): return [f'choice_x_{i}' for i in range(1, len(Constants.x1_values) + 1)] def vars_for_template(self): # Préparez les options pour le template options = [] for i, x in enumerate(Constants.x1_values, start=1): option_a = '£'+str(self.participant.vars['x1_me']) option_b = f"£{x}" options.append((i, option_a, option_b)) return {'options': options} def before_next_page(self): # Récupérez les valeurs de choix du joueur pour x et traitez-les self.player.get_choice_values_x1() self.player.min_choice_value_x1() # NORMALISATION DE Y class normalization_y(Page): form_model = 'player' def get_form_fields(self): return [f'choice_y_{i}' for i in range(1, len(Constants.x_filler_values) + 1)] def vars_for_template(self): options = [] for i, x in enumerate(Constants.x_filler_values, start=1): option_a = '£'+str(self.participant.vars['x_filler']) option_b = f"£{x}" options.append((i, option_a, option_b)) return {'options': options} def before_next_page(self): # Récupère les valeurs de choix du joueur et les traite ou les affiche comme nécessaire self.player.get_choice_values_x_filler() self.player.min_choice_value_x_filler() class fin_exley_asso(Page): def vars_for_template(self): self.player.corrector_def() class consigne_générale_exley_others(Page): pass class consigne_entrainement(Page): pass page_sequence = [new_step, p1_consigne, choix_asso, new_step2, p2_consigne_normalisation, normalization_x, normalization_y, fin_exley_asso, consigne_générale_exley_others, consigne_entrainement]