from ._builtin import Page import random class Error(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 Consent(Page): form_model = 'player' form_fields = ['start_time', 'consent'] def before_next_page(self): if (self.player.id_in_group % 2) != 0: self.player.reciprocity = "Positive" if (self.player.id_in_group % 2) == 0: self.player.reciprocity = "Negative" self.player.participant.vars['reciprocity'] = self.player.reciprocity self.player.colors_reversed = random.randint(0, 1) self.player.participant.vars['colors_reversed'] = self.player.colors_reversed self.player.roles_reversed = random.randint(0, 1) self.player.participant.vars['roles_reversed'] = self.player.roles_reversed class End(Page): def is_displayed(self): return self.player.consent == 2 class Caution(Page): pass class GeneralInstructions1(Page): pass class GeneralInstructions2(Page): pass page_sequence = [ Error, Consent, End, Caution, GeneralInstructions1, GeneralInstructions2 ]