from django.http import HttpResponseRedirect from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants from otreeutils.pages import ExtendedPage import logging logger = logging.getLogger(__name__) class BigFive(ExtendedPage): custom_name_in_url = '53' form_model = 'player' form_fields = ['bigfive'] timeout_seconds = 300 def before_next_page(self): # print(self.player.bigfive) self.player.my_bret_payoff = self.player.participant.vars['my_bret_payoff'] self.player.my_memory_payoff = self.player.participant.vars['payoff_memory'] self.player.bret_memory = self.player.participant.vars['payoff_memory'] + \ self.player.participant.vars['my_bret_payoff'] self.player.stars_total = self.player.participant.vars['num_correct'] if self.timeout_happened: self.player.timeout = 1 # participant is excluded from study if time runs out self.player.timeout_in_bigfive = 1 else: for i in Constants.bigfive_categories: setattr(self.player, i, getattr(self.player, 'conversion')(i)) def post(self): # print(self.request.POST) return super().post() class Humility(ExtendedPage): custom_name_in_url = '55' form_model = 'player' form_fields = ['humility'] timeout_seconds = 300 def before_next_page(self): # print(self.player.bigfive) if self.timeout_happened: self.player.timeout = 1 # participant is excluded from study if time runs out else: self.player.humility_calc() def post(self): # print(self.request.POST) return super().post() class Follow_Up(ExtendedPage): custom_name_in_url = '52' form_model = 'player' form_fields = ['Follow_up_1', 'Follow_up_2'] timeout_seconds = 300 # def vars_for_template(self): # self.player.prev_app_grab() def before_next_page(self): logger.info(f"on survey 1 going to survey 2") #if self.timeout_happened: # self.player.timeout = 1 # participant is excluded from study if time runs out class More_comments(ExtendedPage): custom_name_in_url = '10' form_model = 'player' form_fields = ['Follow_up_3', 'Follow_up_4', 'Follow_up_5', 'Follow_up_6', 'Follow_up_x'] timeout_seconds = 300 def before_next_page(self): logger.info(f"Moved from survey 1 to survey 2 and now going to thank you page") #if self.timeout_happened: # self.player.timeout = 1 # participant is excluded from study if time runs out class TimeOutNew(ExtendedPage): # shown if timeout custom_name_in_url = 'time_out' def is_displayed(self): return self.player.timeout == 1 # the participant is kicked out of the experiment if the timer runs out class ThankYou(Page): custom_name_in_url = 'thank_you' timeout_seconds = 300 def vars_for_template(self): self.player.bomb_consequential = self.player.participant.vars['bomb_consequential'] self.player.boxes_collected_consequential = self.participant.vars['boxes_collected_consequential'] logger.info(f"was there a bomb?{self.player.bomb_consequential}") self.participant.vars['payment_completing_experiment'] = Constants.payment_completing_experiment self.participant.vars['payoff_of_study'] = self.participant.vars['payment_completing_experiment'] + \ self.player.participant.vars['payoff_memory'] + \ self.player.participant.vars['my_bret_payoff'] def post(self): return HttpResponseRedirect('https://app.prolific.co/submissions/complete?cc=18441592') # redirecting implies importing a method at the beginning of pages.py: # from django.http import HttpResponseRedirect # GO TO PROLIFIC PAGE - NEW STUDY - SECTION: # "To prove that participants have completed your study, we require that you redirect them to the following special URL on our site:" # COPY & PASTE LINK ABOVE # When you first install oTree, The entire admin interface is accessible without a password. # However, when you are ready to deploy to your audience, you should password protect the admin. # f you are launching an experiment and want visitors to only be able to play your app # if you provided them with a start link, set the environment variable OTREE_AUTH_LEVEL to STUDY. # https://otree.readthedocs.io/en/latest/admin.html?fbclid=IwAR3wbtO7pdJq7K2CNeV_LDrZjOcgK4tcVj30R9v8x5LwkeGldH2r8FqGznI#participant-labels page_sequence = [ BigFive, TimeOutNew, Humility, TimeOutNew, Follow_Up, More_comments, ThankYou ]