from ._builtin import Page, WaitPage from .models import Constants class pretest(Page): pass class Info_Consent(Page): form_model = 'player' form_fields = ['consent'] def before_next_page(self): self.player.UserAgent = self.request.META.get('HTTP_USER_AGENT') class consent_out(Page): def is_displayed(self): return self.player.consent == 0 class mobile_end(Page): def is_displayed(self): user_agent = self.request.META['HTTP_USER_AGENT'] is_mobile = False for substring in ['Mobi', 'Android']: if substring in user_agent: is_mobile = True return is_mobile class Instructions(Page): pass class general_study_Instructions(Page): form_model = 'player' form_fields = ['P_ID'] class general_study_Instructions2(Page): pass class Introduction(Page): pass class situation_description(Page): pass class manipulation_check(Page): form_model = 'player' form_fields = ['m_check_1'] class manipulation_check_feedback(Page): pass class dictator_game(Page): # set payoff if participant opted in def before_next_page(self): self.player.set_payoffs() form_model = 'player' form_fields = ['offer', 'kept','kept_history'] class second_order_belief(Page): form_model = 'player' form_fields = ['second_order_belief'] class Results(Page): def vars_for_template(self): return { 'kept': round(self.player.kept, 0), 'offer': round((10 - self.player.kept), 0), } page_sequence = [ #mobile_end, #Info_Consent, #consent_out, general_study_Instructions, general_study_Instructions2, situation_description, manipulation_check, manipulation_check_feedback, dictator_game, Results, second_order_belief, ]