# 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 otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants from otreeutils.surveys import SurveyPage, setup_survey_pages import random class SurveyIntro(Page): pass class PegTurning(Page): form_model = 'player' form_fields = ['peg'] def before_next_page(self): total_rounds = int(self.player.peg/32) # player.peg gives the number of clicks. int() gives the total number of full rotations. self.player.payoff += total_rounds*0.10 # Display only for treatment 1 def is_displayed(self): return self.player.treatment == 1 class ShopTutorial(Page): pass class PegTutorial(Page): # Display only for treatment 1 def is_displayed(self): return self.player.treatment == 1 class SurveyPage1(SurveyPage): pass class SurveyPage3(SurveyPage): pass class SurveyPage5(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 = [ SurveyPage1, SurveyPage3, SurveyPage5, ] # Common setup for all pages (will set the questions per page) setup_survey_pages(models.Player, survey_pages) page_sequence = [ SurveyIntro, SurveyPage5, # Consent SurveyPage1, # Demographic Questions PegTutorial, PegTurning, SurveyPage3, ShopTutorial, ]