import math from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class MyPage(Page): form_model = 'player' form_fields = ['Preferencia1'] pass class MyPage0(Page): form_model = 'player' pass class MyPage2(Page): form_model = 'player' form_fields = ['Preferencia2'] pass class MyPage3(Page): form_model = 'player' form_fields = ['Preferencia3'] pass class MyPage4(Page): form_model = 'player' form_fields = ['Preferencia4'] pass class MyPage5(Page): form_model = 'player' form_fields = ['Preferencia5'] pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.subsession.set_groups() pass class Results(Page): pass class MyPage6(Page): form_model = 'player' def vars_for_template(self): return dict( grupo=self.player.participant.vars['grupo'], numero=self.session.num_participants/2 ) pass class MyPage6b(Page): form_model = 'player' form_fields = ['Artista1', 'Artista2'] def before_next_page(self): for p in self.subsession.get_players(): if p.Artista1=="Klee"and p.Artista2=="Kandisky": p.participant.vars['foo'] = 2 elif p.Artista1=="Klee"and p.Artista2=="Klee" or p.Artista1=="Kandisky"and p.Artista2=="Kandisky": p.participant.vars['foo'] = 1 else: p.participant.vars['foo'] = 0 pass class MyPage7(Page): form_model = 'player' def vars_for_template(self): parte_decimal, parte_entera = math.modf(self.player.id_in_group / 4) return dict( num=(self.player.id_in_group/4-parte_entera)*4+1 ) def before_next_page(self): parte_decimal, parte_entera = math.modf(self.player.id_in_group / 4) self.player.participant.vars['num']=(self.player.id_in_group/4-parte_entera)*4+1 pass class A1_Informed_Consent(Page): form_model = 'player' form_fields = ['city_3', 'day_3', 'month_3', 'year_3', 'hour_3', 'minutes_3', 'ampm', 'name_3', 'signature_3', 'idcard_3', 'citycard_3'] pass class I_Intro(Page): pass page_sequence = [ I_Intro, A1_Informed_Consent, MyPage0, MyPage, MyPage2, MyPage3, MyPage4, MyPage5, ResultsWaitPage, Results, MyPage6, MyPage6b, MyPage7 ]