from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Welcome(Page): form_model = 'player' form_fields = ['infected', ] def vars_for_template(self): return { 'rand_num': self.player.participant.vars['rand_num'], } class Gift_Card(Page): def is_displayed(self): rand_num = self.participant.vars['rand_num'] return rand_num == 0 form_model = 'player' form_fields = ['cq1', 'cq2', 'cq3',] def error_message(self, values): ans1 = 3 ans2 = 2 ans3 = 2 if self.player.incorrect_attempts == None: # counts number of incorret attempts. self.player.incorrect_attempts = 0 if values['cq1'] != ans1 or values['cq2'] != ans2 or values['cq3'] != ans3: self.player.incorrect_attempts += 1 return 'At least one of your answers was not correct. Please check them again or read the instructions once more.' class Gift_Card_2(Page): def is_displayed(self): rand_num = self.participant.vars['rand_num'] return rand_num == 1 form_model = 'player' form_fields = ['gift_card',] class Page0(Page): form_model = 'player' form_fields = ['risk_cafe', 'risk_cafe_others', ] class Page11(Page): form_model = 'player' form_fields = ['risk_gym', 'risk_wedding', 'risk_pubtrans', 'risk_indoor', 'risk_outdoor', ] class Page12(Page): form_model = 'player' form_fields = ['risk_demo', 'risk_supermarket', 'risk_sportevent', 'risk_travel', 'risk_overall_risk', ] class Page2(Page): form_model = 'player' form_fields = [ 'risk_1830', 'risk_70', 'num_infected', ] class Page3(Page): form_model = 'player' form_fields = ['meet_indoor', 'meet_outdoor', 'avoid_meetings', 'avoid_cafes', 'avoid_pubtrans', 'worried_med', 'want_infected', 'concerned_others',] class Page4(Page): form_model = 'player' form_fields = ['approp_cafe', 'approp_gym', 'approp_wedding', 'approp_indoor', 'approp_outdoor', 'approp_pubtrans', 'approp_travel', 'approp_sportevent',] class Page5(Page): form_model = 'player' form_fields = ['num_cafe', 'num_gym', 'num_pubtrans', 'num_indoor', 'num_outdoor', 'num_memrisk',] class Page6(Page): form_model = 'player' form_fields = ['mask', 'mask_you', ] class Page7(Page): form_model = 'player' form_fields = ['gender', 'age', 'patience', 'risk', 'health', 'alcohol', 'smoke', 'exercise', 'severe_loss',] class Last_Page(Page): form_model = 'player' def vars_for_template(self): return { 'compl_code': self.player.participant.vars['compl_code'], 'rand_num': self.player.participant.vars['rand_num'], } page_sequence = [ Welcome, Gift_Card, Page0, Page11, Page12, Page2, Page3, Page4, Page5, Page6, Page7, Gift_Card_2, Last_Page, ]