# Definition of views/pages for the survey. # Please note: When using oTree 2.x, this file should be called "pages.py" instead of "views.py" # from . import models from ._builtin import Page, WaitPage from .models import Constants from otree.api import Currency as c, currency_range, widgets from otreeutils.surveys import SurveyPage, setup_survey_pages import random from otreeutils.surveys import SurveyPage, setup_survey_pages class SurveyPage4(SurveyPage): pass class BigFive(Page): form_model = 'player' form_fields = ['BFI_O1', 'BFI_O2', 'BFI_C1', 'BFI_C2', 'BFI_E1', 'BFI_E2', 'BFI_A1', 'BFI_A2', 'BFI_N1', 'BFI_N2'] page_sequence = [ ] class SurveyIntro(Page): pass # let's create the survey pages here # unfortunately, it's not possible to create them dynamically class BigFive(SurveyPage): def before_next_page(self): self.player.extraversion = ((6 - self.player.BFI_E1) + self.player.BFI_E2)/2 self.player.agreeableness = (self.player.BFI_A1 + (6 - self.player.BFI_A2))/2 self.player.conscientiousness = ((6 - self.player.BFI_C1) + self.player.BFI_C2)/2 self.player.neuroticism = ((6 - self.player.BFI_N1) + self.player.BFI_N2)/2 self.player.openness = ((6-self.player.BFI_O1) + self.player.BFI_O2)/2 class SelfOtherInterestInventorySelfInterestSubscale(SurveyPage): form_model = 'player' form_fields = ['Good_Bad_Attn_Check'] def before_next_page(self): self.player.SI_score = (self.player.SOII_SI1 + self.player.SOII_SI2 + self.player.SOII_SI3 + self.player.SOII_SI4 + self.player.SOII_SI5 + self.player.SOII_SI6 + self.player.SOII_SI7 + self.player.SOII_SI8 + self.player.SOII_SI9)/9 class SelfOtherInterestInventoryOtherInterestSubscale(SurveyPage): def before_next_page(self): self.player.OI_score = (self.player.SOII_OI1 + self.player.SOII_OI2 + self.player.SOII_OI3 + self.player.SOII_OI4 + self.player.SOII_OI5 + self.player.SOII_OI6 + self.player.SOII_OI7 + self.player.SOII_OI8 + self.player.SOII_OI9) / 9 if self.player.onlineStudyAttnCheck < 4: self.participant.vars['onlineStudyAttnCheck'] = False else: self.participant.vars['onlineStudyAttnCheck'] = True class CurrentVisceralState(SurveyPage): pass # Create a list of survey pages. # The order is important! The survey questions are taken in the same order # from the SURVEY_DEFINITIONS in models.py survey_pages = [ BigFive, SelfOtherInterestInventorySelfInterestSubscale, CurrentVisceralState, SelfOtherInterestInventoryOtherInterestSubscale ] # Common setup for all pages (will set the questions per page) setup_survey_pages(models.Player, survey_pages) page_sequence = [ ] # add the survey pages to the page sequence list page_sequence.extend(survey_pages)