from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants class Consent(Page): form_model = 'player' form_fields = [ 'consent', 'window_height', 'window_width', 'user_agent', 'is_iPad', ] def js_vars(self): return dict(page_name='Consent') def before_next_page(self): self.player.prolific_id = self.participant.label self.participant.vars['prolific_id'] = self.player.prolific_id class Intro(Page): form_model = 'player' form_fields = [ 'Intro_warnings', 'Intro_time_spent', ] def js_vars(self): return dict(page_name='Intro') def vars_for_template(self): conversion = self.session.config['real_world_currency_per_point'] participation_fee = self.session.config['participation_fee'] points = 100 money = (points*conversion)*100 reward = self.session.config['prolific_reward'] return dict(conversion=conversion, participation_fee=participation_fee, points=c(points), money=money, reward=reward) class ScreenOutConsent(Page): """ Page to screen out participants who do not consent. """ def is_displayed(self): return self.player.consent == 0 class ScreenOutDevice(Page): """ Page to screen out participants who do not have proper device. """ def is_displayed(self): if any(x in self.player.user_agent for x in [ 'iPhone', 'iPad', 'Android', 'Mobi', 'PlayBook', 'BlackBerry', 'Edge', 'MSIE', 'Trident' ]) or self.player.is_iPad is True: return True else: return False page_sequence = [ Consent, ScreenOutConsent, ScreenOutDevice, Intro, ]