# 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): # Display page on the first round def is_displayed(self): return self.round_number == 1 class PegTurning(Page): form_model = 'player' form_fields = ['peg'] def before_next_page(self): total_rounds = int(self.player.peg/8) # player.peg gives the number of clicks. int() gives the total number of full rotations. self.player.payoff += total_rounds*0.05 # Display page on the first round and # only for treatment 1 def is_displayed(self): return self.round_number == 1 and self.player.treatment == 1 class ShopTutorial(Page): # Display page on the first round def is_displayed(self): return self.round_number == 1 class PegTutorial(Page): # Display page on the first round and # only for treatment 1 def is_displayed(self): return self.round_number == 1 and self.player.treatment == 1 class ShoppingList(Page): # Display page on the first round def is_displayed(self): return self.round_number == 1 class ExtraShop01(Page): form_model = 'player' form_fields = ['extra_01'] def is_displayed(self): return self.round_number == self.participant.vars['round']['ES01'] def before_next_page(self): shop2value = {0: 0, 1: 0.4, 2: 0.2, 3: 0.7, 4: 0, 5: 0.6, 6: 0.1, 7: 0.3, 8: 0.5}; self.player.payoff += shop2value[self.player.extra_01] class ExtraShop02(Page): form_model = 'player' form_fields = ['extra_02'] def is_displayed(self): return self.round_number == self.participant.vars['round']['ES02'] def before_next_page(self): shop2value = {0: 0, 1: -0.4, 2: -0.1, 3: -0.2, 4: -0.3, 5: 0.1, 6: 0.4, 7: 0.2, 8: 0.3}; self.player.payoff += shop2value[self.player.extra_02] class ExtraShop03(Page): form_model = 'player' form_fields = ['extra_03'] def is_displayed(self): return self.round_number == self.participant.vars['round']['ES03'] def before_next_page(self): shop2value = {0: 0, 1: -0.1, 2: -0.4, 3: 0.3, 4: 0.2, 5: -0.3, 6: -0.2, 7: 0.1, 8: 0.4}; self.player.payoff += shop2value[self.player.extra_03] class ExtraShop04(Page): form_model = 'player' form_fields = ['extra_04'] def is_displayed(self): return self.round_number == self.participant.vars['round']['ES04'] def before_next_page(self): shop2value = {0: 0, 1: 0, 2: 0, 3: -0.2, 4: 0.4, 5: -0.3, 6: -0.2, 7: 0.2, 8: 0.2}; self.player.payoff += shop2value[self.player.extra_04] class ExtraShop05(Page): form_model = 'player' form_fields = ['extra_05'] def is_displayed(self): return self.round_number == self.participant.vars['round']['ES05'] def before_next_page(self): shop2value = {0: 0, 1: 0.1, 2: 0.4, 3: 0.1, 4: 0.7, 5: 0, 6: 0.1, 7: 0.5, 8: 0.6}; self.player.payoff += shop2value[self.player.extra_05] class ExtraShop06(Page): form_model = 'player' form_fields = ['extra_06'] def is_displayed(self): return self.round_number == self.participant.vars['round']['ES06'] def before_next_page(self): shop2value = {0: 0, 1: -0.3, 2: 0.3, 3: -0.1, 4: 0.3, 5: 0, 6: 0.1, 7: -0.2, 8: 0.1}; self.player.payoff += shop2value[self.player.extra_06] class ListShop01(Page): form_model = 'player' form_fields = ['list_01'] def is_displayed(self): return self.round_number == self.participant.vars['round']['LS01'] def before_next_page(self): shop2value = {1: 0, 2: 0.6, 3: 0.5, 4: 0.3, 5: 0.1, 6: 0.7, 7: 0.2, 8: 0.4}; self.player.payoff += shop2value[self.player.list_01] class ListShop02(Page): form_model = 'player' form_fields = ['list_02'] def is_displayed(self): return self.round_number == self.participant.vars['round']['LS02'] def before_next_page(self): shop2value = {1: 0.7, 2: 0.1, 3: 0.4, 4: 0, 5: 0.2, 6: 0.5, 7: 0.6, 8: 0.2}; self.player.payoff += shop2value[self.player.list_02] class ListShop03(Page): form_model = 'player' form_fields = ['list_03'] def is_displayed(self): return self.round_number == self.participant.vars['round']['LS03'] def before_next_page(self): shop2value = {1: 0.6, 2: 0.7, 3: 0.4, 4: 0.1, 5: 0.3, 6: 0.2, 7: 0, 8: 0.4}; self.player.payoff += shop2value[self.player.list_03] class ListShop04(Page): form_model = 'player' form_fields = ['list_04'] def is_displayed(self): return self.round_number == self.participant.vars['round']['LS04'] def before_next_page(self): shop2value = {1: 0.6, 2: 0.3, 3: 0.4, 4: 0.2, 5: 0.6, 6: 0.1, 7: 0, 8: 0.4}; self.player.payoff += shop2value[self.player.list_04] class Feedback(Page): form_model = 'player' form_fields = ['feedback'] # Display page after shopping sequence def is_displayed(self): return self.round_number == Constants.num_rounds class SurveyPage1(SurveyPage): def is_displayed(self): return self.round_number == 1 class SurveyPage2(SurveyPage): def is_displayed(self): return self.round_number == Constants.num_rounds class SurveyPage3(SurveyPage): def is_displayed(self): return self.round_number == 1 class SurveyPage4(SurveyPage): def is_displayed(self): return self.round_number == Constants.num_rounds class SurveyPage5(SurveyPage): def is_displayed(self): return self.round_number == 1 class StateBoredomAfter(SurveyPage): def is_displayed(self): return self.round_number == Constants.num_rounds # 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, SurveyPage2, SurveyPage3, SurveyPage4, SurveyPage5, StateBoredomAfter, ] # 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, ] shop_sequence = [ ExtraShop01, #Potato-Impuls #ExtraShop02, #Corkscrew-Impuls #ExtraShop03, #Flower-Impuls #ExtraShop04, #Napkins-Impuls #ExtraShop05, #Onion-Impuls #ExtraShop06, #Tiramisu-Impuls #ListShop01, #Salmon-List #ListShop02, #White Wine-List #ListShop03, #Lettuce-List #ListShop04, #Tomato-List ] #random.shuffle(shop_sequence) page_sequence.extend(shop_sequence) page_sequence_ = [ #SurveyPage4, # IBT Scale #SurveyPage2, # Boredom Proneness Scale #StateBoredomAfter, # State Boredom Scale (After) #Feedback, ] page_sequence.extend(page_sequence_)