from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import time class P0_effort_monitor(Page): def is_displayed(self): return self.round_number == 1 class p1_consigne(Page): def is_displayed(self): return self.round_number == 1 class new_step(Page): def is_displayed(self): return self.round_number == 1 class income(Page): def vars_for_template(self): self.player.income_participant() def is_displayed(self): return self.round_number == Constants.num_rounds class initialize(Page): timeout_seconds = 0 def before_next_page(self): self.player.puzzle_a_resoudre_initialise() self.participant.vars['expiry2'] = Constants.time_experiment + time.time() self.player.income_participant() def is_displayed(self): return self.round_number == 1 class MyPage(Page): form_model = 'player' form_fields = ['reponse'] def error_message(self, values): if values['reponse'].lower() != self.player.solution.lower(): self.participant.vars['history_juste'] = 0 self.player.in_round(Constants.num_rounds).history_juste = self.player.in_round(Constants.num_rounds).history_juste + ',' + 'Round' + ':' + str(self.round_number) + ':' + str(self.participant.vars['history_juste']) self.player.erreur = self.player.erreur + 1 self.participant.vars['reussi'] = self.participant.vars['reussi'] + 0 return 'Vous avez fait une erreur. Veuillez réessayer' elif values['reponse'] is None: self.participant.vars['history_juste'] = 0 self.player.in_round(Constants.num_rounds).history_juste = self.player.in_round(Constants.num_rounds).history_juste + ',' + 'Round' + ':' + str(self.round_number) + ':' + str(self.participant.vars['history_juste']) self.player.erreur = self.player.erreur + 1 self.participant.vars['reussi'] = self.participant.vars['reussi'] + 0 return 'Vous n\'avez pas donné de réponse. Veuillez réessayer' else: self.participant.vars['reussi'] = self.participant.vars['reussi'] + 1 self.participant.vars['history_juste'] = 1 self.player.in_round(Constants.num_rounds).history_juste = self.player.in_round(Constants.num_rounds).history_juste + ',' + 'Round' + ':' + str(self.round_number) + ':' + str(self.participant.vars['history_juste']) def before_next_page(self): self.player.is_bonne_reponse() self.player.puzzle_a_resoudre() self.player.income_participant() def vars_for_template(self): self.player.timing_response() def is_displayed(self): return self.round_number < Constants.num_rounds class FIN_partie1(Page): def is_displayed(self): return self.round_number == Constants.num_rounds class Results(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [new_step, p1_consigne, initialize, MyPage, income]