from .models import * class GatheringResults(WaitPage): after_all_players_arrive = 'set_earnings_data' class MyPage(Page): form_model = 'player' class CognitiveReflectionTest(Page): form_model = 'player' form_fields = ['probabilitytest', 'expectedvaluetest', 'lossaversion'] class MyPage2(Page): form_model = 'player' form_fields = ['riskaversion'] class Demographics(Page): form_model = 'player' form_fields = ['gender', 'yearincollege'] def before_next_page(self): timeout_happened = self.timeout_happened player = self.player import random import math if player.probabilitytest == 25: player.finalearnings = player.finalearnings + .5 player.questionsearnings = player.questionsearnings + .5 if player.expectedvaluetest == 20: player.finalearnings = player.finalearnings + .5 player.questionsearnings = player.questionsearnings + .5 if player.lossaversion == "Yes": laoutcome = random.random() if laoutcome < .5: player.finalearnings = player.finalearnings - 2 player.lossaversionearnings = player.lossaversionearnings - 2 else: player.finalearnings = player.finalearnings + 3 player.lossaversionearnings = player.lossaversionearnings + 3 riskoutcome = random.randint(1,10) if player.riskaversion < riskoutcome: boutcome = random.randint(1,10) if riskoutcome >= boutcome: player.finalearnings = player.finalearnings + 3.85 player.riskaversionearnings = player.riskaversionearnings + 3.85 player.finalearnings = math.ceil(player.finalearnings) else: player.finalearnings = player.finalearnings + .1 player.riskaversionearnings = player.riskaversionearnings + .1 player.finalearnings = math.ceil(player.finalearnings) else: aoutcome = random.randint(1,10) if riskoutcome >= aoutcome: player.finalearnings = player.finalearnings + 2 player.riskaversionearnings = player.riskaversionearnings + 2 player.finalearnings = math.ceil(player.finalearnings) else: player.finalearnings = player.finalearnings + 1.6 player.riskaversionearnings = player.riskaversionearnings + 1.6 player.finalearnings = math.ceil(player.finalearnings) class MyPage3(Page): form_model = 'player' page_sequence = [GatheringResults, MyPage, CognitiveReflectionTest, MyPage2, Demographics, MyPage3]