from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants import time import random from django import forms from django.http import HttpResponseRedirect from django.shortcuts import render class ScreenOut(Page): timeout_seconds = 60 * 4 form_model = 'player' form_fields = ['consent', ] def is_displayed(self): return self.group.id_in_subsession > 1 and self.round_number == 1 def before_next_page(self): self.participant.payoff = 0 self.player.prolific_id = self.participant.label if self.round_number == 1: self.player.random_n = round(random.random() * 100) self.player.in_round(2).random_n = self.player.random_n self.player.in_round(3).random_n = self.player.random_n self.player.in_round(4).random_n = self.player.random_n self.player.in_round(5).random_n = self.player.random_n self.player.in_round(6).random_n = self.player.random_n self.player.in_round(7).random_n = self.player.random_n self.player.in_round(8).random_n = self.player.random_n self.player.in_round(9).random_n = self.player.random_n self.player.in_round(10).random_n = self.player.random_n # class MTurkPreview(Page): # def is_displayed(self): # return self.round_number == 1 and self.group.id_in_subsession == 1 # # pass class Welcome(Page): timeout_seconds = 60 * 2.5 form_model = 'player' form_fields = ['consent', ] def vars_for_template(self): return {'max': Constants.max, 'avg': Constants.avg, 'min': Constants.min, 'time': Constants.time, } def is_displayed(self): return self.round_number == 1 and self.group.id_in_subsession == 1 class timemoney0(Page): timeout_seconds = 0.01 def before_next_page(self): self.player.stamp = round(time.time()) self.player.prolific_id = self.participant.label return self.player.stamp def is_displayed(self): return self.round_number == 1 and self.group.id_in_subsession == 1 class Welcome2(Page): timeout_seconds = 60 * 2.5 def vars_for_template(self): return {'time': Constants.time, } def before_next_page(self): if self.timeout_happened: self.player.passive = 1 self.group.dead = 1 self.participant.vars['passive'] = 1 self.player.firstwaiting_time_start = round(time.time()) self.participant.vars['wait_page_arrival'] = time.time() return self.player.firstwaiting_time_start def is_displayed(self): return self.round_number == 1 and self.group.id_in_subsession == 1 class MTurkPassiveSTD(Page): timeout_seconds = (10 * 60) + 30 def vars_for_template(self): return {'stamp': self.player.stamp, 'n_stamps': self.group.my_page_timeout_seconds(), 'money': round((time.time() - self.player.firstwaiting_time_start) / 500, 2), 'refresh_n': round((time.time() - self.player.firstwaiting_time_start) / 15, ), 'minutes': round((time.time() - self.player.firstwaiting_time_start) / 60, 1), 'max': self.player.max + 1.50, 'death': self.group.dead, } def is_displayed(self): return self.round_number == 1 and self.group.id_in_subsession == 1 class timemoney(Page): timeout_seconds = 0.01 def before_next_page(self): self.player.timewaiting_end = round(time.time()) self.group.in_round(2).dead = self.group.dead self.group.in_round(3).dead = self.group.dead self.group.in_round(4).dead = self.group.dead self.group.in_round(5).dead = self.group.dead self.group.in_round(6).dead = self.group.dead self.group.in_round(7).dead = self.group.dead self.group.in_round(8).dead = self.group.dead self.group.in_round(9).dead = self.group.dead self.group.in_round(10).dead = self.group.dead if self.round_number == 1: self.player.random_n = round(random.random() * 100) + round(random.random() * 100) self.player.in_round(2).random_n = self.player.random_n self.player.in_round(3).random_n = self.player.random_n self.player.in_round(4).random_n = self.player.random_n self.player.in_round(5).random_n = self.player.random_n self.player.in_round(6).random_n = self.player.random_n self.player.in_round(7).random_n = self.player.random_n self.player.in_round(8).random_n = self.player.random_n self.player.in_round(9).random_n = self.player.random_n self.player.in_round(10).random_n = self.player.random_n return self.player.timewaiting_end and self.player.random_n def is_displayed(self): return self.round_number == 1 and self.group.id_in_subsession == 1 class ResultsWaitPageDead(WaitPage): after_all_players_arrive = 'set_payoffs' title_text = "Unfortunately, not enough MTurkers joined this session." body_text = "You will now be redirected to the Questionnaire Part 1. " def is_displayed(self): return (self.group.dead == 1 and self.round_number == 1) class DeadPage(Page): timeout_seconds = 90 form_model = 'player' def vars_for_template(self): return { 'payoff': self.participant.payoff, 'waiting_time': self.player.waiting_time(), 'total': Constants.showing_up_fee + self.player.waiting_time(), 'top_up': self.player.payoff } def is_displayed(self): return self.group.dead == 1 and self.group.id_in_subsession == 1 and self.round_number == 1 class Instructions_NI(Page): timeout_seconds = 60 * 3 def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and self.group.grp_treat == 'No-Intergen-low' and self.group.id_in_subsession == 1 class Instructions_NIH(Page): timeout_seconds = 60 * 3 def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and self.group.grp_treat == 'No-Intergen-high' and self.group.id_in_subsession == 1 class Instructions_I(Page): timeout_seconds = 60 * 3 def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and self.group.grp_treat == 'Intergen-low' and self.group.id_in_subsession == 1 class Instructions_IH(Page): timeout_seconds = 60 * 3 def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and self.group.grp_treat == 'Intergen-high' and self.group.id_in_subsession == 1 class Instructions_NI2(Page): timeout_seconds = 60 * 3 def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and ( self.group.grp_treat == 'No-Intergen-low' or self.group.grp_treat == 'No-Intergen-high') and self.group.id_in_subsession == 1 class Instructions_I2(Page): timeout_seconds = 60 * 3 def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and ( self.group.grp_treat == 'Intergen-low' or self.group.grp_treat == 'Intergen-high') and self.group.id_in_subsession == 1 class Test1_HNI(Page): timeout_seconds = 60 * 2 form_model = 'player' form_fields = ['test_growth_rate', 'test_conversion_rate', 'test_options_available', 'test_earnings_high'] def is_displayed(self): return self.group.dead == 0 and self.group.id_in_subsession == 1 and self.group.grp_treat == 'No-Intergen-high' \ and self.round_number == 1 class Test2_HNI(Page): timeout_seconds = 60 * 1 form_model = 'player' def get_form_fields(self): if self.player.test_growth_rate != 2: if self.player.test_conversion_rate != 1: if self.player.test_options_available != 3: if self.player.test_earnings_high != 2: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2', 'test_earnings_high2'] else: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2'] else: if self.player.test_earnings_high != 2: return ['test_growth_rate2', 'test_conversion_rate2', 'test_earnings_high2'] else: return ['test_growth_rate2', 'test_conversion_rate2'] else: if self.player.test_options_available != 3: if self.player.test_earnings_high != 2: return ['test_growth_rate2', 'test_options_available2', 'test_earnings_high2'] else: return ['test_growth_rate2', 'test_options_available2'] else: if self.player.test_earnings_high != 2: return ['test_growth_rate2', 'test_earnings_high2'] else: return ['test_growth_rate2'] else: if self.player.test_conversion_rate != 1: if self.player.test_options_available != 3: if self.player.test_earnings_high != 2: return ['test_conversion_rate2', 'test_options_available2', 'test_earnings_high2'] else: return ['test_conversion_rate2', 'test_options_available2'] else: if self.player.test_earnings_high != 2: return ['test_conversion_rate2', 'test_earnings_high2'] else: return ['test_conversion_rate2'] else: if self.player.test_options_available != 3: if self.player.test_earnings_high != 2: return ['test_options_available2', 'test_earnings_high2'] else: return ['test_options_available2'] else: if self.player.test_earnings_high != 2: return ['test_earnings_high2'] def is_displayed(self): return (self.player.test_growth_rate != 2 or self.player.test_conversion_rate != 1 or self.player.test_options_available != 3 or self.player.test_earnings_high != 2) \ and self.group.dead == 0 and self.group.id_in_subsession == 1 and self.group.grp_treat == 'No-Intergen-high' \ and self.round_number == 1 def error_message(self, values): print('value is', values) if self.player.test_growth_rate != 2: if values['test_growth_rate2'] != 2: return 'Question A is not correct. Please remember: The resources for next round will be equal to: (' \ 'Current resources - total amount extracted by participants) * 1.3. ' if self.player.test_conversion_rate != 1: if values['test_conversion_rate2'] != 1: return 'Question B is not correct. Please remember: The conversion rate is 10 units = $1.' if self.player.test_options_available != 3: if values['test_options_available2'] != 3: return 'Question C is not correct. Please remember: You can either extract 0%, 5%' \ 'or 11% of the resources from the pool. ' if self.player.test_earnings_high != 2: if values['test_earnings_high2'] != 2: return 'Question E is not correct. Please remember: The earning from option A will be equal to ' \ 'Extracted resources / 10 + premium ' class Test1_HI(Page): timeout_seconds = 60 * 2 form_model = 'player' form_fields = ['test_growth_rate', 'test_conversion_rate', 'test_options_available', 'test_threshold', 'test_earnings_high'] def is_displayed(self): return self.group.dead == 0 and self.group.id_in_subsession == 1 and self.group.grp_treat == 'Intergen-high' \ and self.round_number == 1 class Test2_HI(Page): timeout_seconds = 60 * 1 form_model = 'player' def get_form_fields(self): if self.player.test_growth_rate != 2: if self.player.test_conversion_rate != 1: if self.player.test_options_available != 3: if self.player.test_earnings_high != 2: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2', 'test_earnings_high2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2', 'test_earnings_high2'] else: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2'] else: if self.player.test_earnings_high != 2: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_conversion_rate2', 'test_earnings_high2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_conversion_rate2', 'test_earnings_high2'] else: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_conversion_rate2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_conversion_rate2'] else: if self.player.test_options_available != 3: if self.player.test_earnings_high != 2: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_options_available2', 'test_earnings_high2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_options_available2', 'test_earnings_high2'] else: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_options_available2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_options_available2'] else: if self.player.test_earnings_high != 2: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_earnings_high2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_earnings_high2'] else: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_threshold2'] else: return ['test_growth_rate2'] else: if self.player.test_conversion_rate != 1: if self.player.test_options_available != 3: if self.player.test_earnings_high != 2: if self.player.test_threshold != 3: return ['test_conversion_rate2', 'test_options_available2', 'test_earnings_high2', 'test_threshold2'] else: return ['test_conversion_rate2', 'test_options_available2', 'test_earnings_high2'] else: if self.player.test_threshold != 3: return ['test_conversion_rate2', 'test_options_available2', 'test_threshold2'] else: return ['test_conversion_rate2', 'test_options_available2'] else: if self.player.test_earnings_high != 2: if self.player.test_threshold != 3: return ['test_conversion_rate2', 'test_earnings_high2', 'test_threshold2'] else: return ['test_conversion_rate2', 'test_earnings_high2'] else: if self.player.test_threshold != 3: return ['test_conversion_rate2', 'test_threshold2'] else: return ['test_conversion_rate2'] else: if self.player.test_options_available != 3: if self.player.test_earnings_high != 2: if self.player.test_threshold != 3: return ['test_options_available2', 'test_earnings_high2', 'test_threshold2'] else: return ['test_options_available2', 'test_earnings_high2'] else: if self.player.test_threshold != 3: return ['test_options_available2', 'test_threshold2'] else: return ['test_options_available2'] else: if self.player.test_earnings_high != 2: if self.player.test_threshold != 3: return ['test_earnings_high2', 'test_threshold2'] else: return ['test_earnings_high2'] else: if self.player.test_threshold != 3: return ['test_threshold2'] def is_displayed(self): return (self.player.test_growth_rate != 2 or self.player.test_conversion_rate != 1 or self.player.test_options_available != 3 or self.player.test_earnings_high != 2 or self.player.test_threshold != 3) \ and self.group.dead == 0 and self.group.id_in_subsession == 1 and self.group.grp_treat == 'Intergen-high' \ and self.round_number == 1 def error_message(self, values): print('value is', values) if self.player.test_growth_rate != 2: if values['test_growth_rate2'] != 2: return 'Question A is not correct. Please remember: The resources for next round will be equal to: (' \ 'Current resources - total amount extracted by participants) * 1.3. ' if self.player.test_conversion_rate != 1: if values['test_conversion_rate2'] != 1: return 'Question B is not correct. Please remember: The conversion rate is 10 units = $1.' if self.player.test_options_available != 3: if values['test_options_available2'] != 3: return 'Question C is not correct. Please remember: You can either extract 0%, 5%' \ 'or 11% of the resources from the pool. ' if self.player.test_threshold != 3: if values['test_threshold2'] != 3: return 'Question D is not correct. Please remember: If the pool of resources you left is less than ' \ 'the threshold of 20 units, the new group will not be able to start the game and will not be ' \ 'able to earn any bonus from it. ' if self.player.test_earnings_high != 2: if values['test_earnings_high2'] != 2: return 'Question E is not correct. Please remember: The earning from option A will be equal to ' \ 'Extracted resources / 10 + premium ' class Test1_I(Page): timeout_seconds = 60 * 2 form_model = 'player' form_fields = ['test_growth_rate', 'test_conversion_rate', 'test_options_available', 'test_threshold'] def is_displayed(self): return self.group.dead == 0 and self.group.id_in_subsession == 1 and self.group.grp_treat == 'Intergen-low' \ and self.round_number == 1 class Test2_I(Page): timeout_seconds = 60 * 1 form_model = 'player' def get_form_fields(self): if self.player.test_growth_rate != 2: if self.player.test_conversion_rate != 1: if self.player.test_options_available != 3: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2'] else: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_conversion_rate2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_conversion_rate2'] else: if self.player.test_options_available != 3: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_options_available2', 'test_threshold2'] else: return ['test_growth_rate2', 'test_options_available2'] else: if self.player.test_threshold != 3: return ['test_growth_rate2', 'test_threshold2'] else: return ['test_growth_rate2'] else: if self.player.test_conversion_rate != 1: if self.player.test_options_available != 3: if self.player.test_threshold != 3: return ['test_conversion_rate2', 'test_options_available2', 'test_threshold2'] else: return ['test_conversion_rate2', 'test_options_available2'] else: if self.player.test_threshold != 3: return ['test_conversion_rate2', 'test_threshold2'] else: return ['test_conversion_rate2'] else: if self.player.test_options_available != 3: if self.player.test_threshold != 3: return ['test_options_available2', 'test_threshold2'] else: return ['test_options_available2'] else: if self.player.test_threshold != 3: return ['test_threshold2'] def is_displayed(self): return (self.player.test_growth_rate != 2 or self.player.test_conversion_rate != 1 or self.player.test_options_available != 3 or self.player.test_threshold != 3) \ and self.group.dead == 0 and self.group.id_in_subsession == 1 and self.group.grp_treat == 'Intergen-low' \ and self.round_number == 1 def error_message(self, values): print('value is', values) if self.player.test_growth_rate != 2: if values['test_growth_rate2'] != 2: return 'Question A is not correct. Please remember: The resources for next round will be equal to: (' \ 'Current resources - total amount extracted by participants) * 1.3. ' if self.player.test_conversion_rate != 1: if values['test_conversion_rate2'] != 1: return 'Question B is not correct. Please remember: The conversion rate is 10 units = $1.' if self.player.test_options_available != 3: if values['test_options_available2'] != 3: return 'Question C is not correct. Please remember: You can either extract 0%, 5%' \ 'or 11% of the resources from the pool. ' if self.player.test_threshold != 3: if values['test_threshold2'] != 3: return 'Question D is not correct. Please remember: If the pool of resources you left is less than ' \ 'the threshold of 20 units, the new group will not be able to start the game and will not be ' \ 'able to earn any bonus from it. ' class Test1_NI(Page): timeout_seconds = 60 * 2 form_model = 'player' form_fields = ['test_growth_rate', 'test_conversion_rate', 'test_options_available'] def is_displayed(self): return self.group.dead == 0 and self.group.id_in_subsession == 1 and self.group.grp_treat == 'No-Intergen-low' \ and self.round_number == 1 class Test2_NI(Page): timeout_seconds = 60 * 1 form_model = 'player' def get_form_fields(self): if self.player.test_growth_rate != 2: if self.player.test_conversion_rate != 1: if self.player.test_options_available != 3: return ['test_growth_rate2', 'test_conversion_rate2', 'test_options_available2'] else: return ['test_growth_rate2', 'test_conversion_rate2'] else: if self.player.test_options_available != 3: return ['test_growth_rate2', 'test_options_available2'] else: return ['test_growth_rate2'] else: if self.player.test_conversion_rate != 1: if self.player.test_options_available != 3: return ['test_conversion_rate2', 'test_options_available2'] else: return ['test_conversion_rate2'] else: if self.player.test_options_available != 3: return ['test_options_available2'] def is_displayed(self): return (self.player.test_growth_rate != 2 or self.player.test_conversion_rate != 1 or self.player.test_options_available != 3) and self.round_number == 1 \ and self.group.dead == 0 and self.group.id_in_subsession == 1 and self.group.grp_treat == 'No-Intergen-low' def error_message(self, values): print('value is', values) if self.player.test_growth_rate != 2: if values['test_growth_rate2'] != 2: return 'Question A is not correct. Please remember: The resources for next round will be equal to: (' \ 'Current resources - total amount extracted by participants) * 1.3. ' if self.player.test_conversion_rate != 1: if values['test_conversion_rate2'] != 1: return 'Question B is not correct. Please remember: The conversion rate is 10 units = $1.' if self.player.test_options_available != 3: if values['test_options_available2'] != 3: return 'Question C is not correct. Please remember: You can either extract 0%, 5%' \ 'or 11% of the resources from the pool. ' class InstructionsWaitPage(WaitPage): title_text = "Please wait for the other participants to read the instructions." body_text = "The game will start as soon as all participants arrive." def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and self.group.id_in_subsession == 1 class DL(Page): timeout_seconds = 40 def is_displayed(self): return self.group.dead == 0 and self.group.id_in_subsession == 1 and ( self.group.grp_treat == 'Intergen-low' or self.group.grp_treat == 'No-Intergen-low') form_model = 'player' form_fields = ['extraction'] title_text = "Please wait for the other participants to make their decision." body_text = "Thank you for your patience." def before_next_page(self): if self.timeout_happened: self.player.active = 0 self.player.extraction = random.choice([Constants.sustainable, Constants.non_sustainable, 0]) def vars_for_template(self): if self.round_number == 1: return dict( non_sust_extraction=format(Constants.environment * Constants.non_sustainable, '.2f'), sust_extraction=format(Constants.environment * Constants.sustainable, '.2f'), no_extraction=0, non_sust_payoff=format(Constants.environment * Constants.non_sustainable / 10, '.2f'), sust_payoff=format(Constants.environment * Constants.sustainable / 10, '.2f'), current_env=Constants.environment ) else: return dict( non_sust_extraction=format(self.group.in_round(self.round_number - 1).environment * Constants.non_sustainable, '.2f'), sust_extraction=format(self.group.in_round(self.round_number - 1).environment * Constants.sustainable, '.2f'), non_sust_payoff=format(self.group.in_round(self.round_number - 1).environment * Constants.non_sustainable / 10, '.2f'), sust_payoff=format(self.group.in_round(self.round_number - 1).environment * Constants.sustainable / 10, '.2f'), current_env=self.group.in_round(self.round_number - 1).environment, ) class DH(Page): timeout_seconds = 40 def is_displayed(self): return self.group.dead == 0 and self.group.id_in_subsession == 1 and ( self.group.grp_treat == 'Intergen-high' or self.group.grp_treat == 'No-Intergen-high') form_model = 'player' form_fields = ['extraction'] title_text = "Please wait for the other participants to make their decision." body_text = "Thank you for your patience." def before_next_page(self): if self.timeout_happened: self.player.active = 0 self.player.extraction = random.choice([Constants.sustainable, Constants.non_sustainable, 0]) def vars_for_template(self): if self.round_number == 1: return dict( non_sust_extraction=format(Constants.environment * Constants.non_sustainable, '.2f'), sust_extraction=format(Constants.environment * Constants.sustainable, '.2f'), no_extraction=0, current_env=Constants.environment, non_sust_payoff=format(Constants.environment * Constants.non_sustainable / 10, '.2f'), sust_payoff=format(Constants.environment * Constants.sustainable * Constants.high_incentives / 10, '.2f'), sust_ext_minus_incentives=format(Constants.environment * Constants.sustainable / 10, '.3f'), incentives=format((Constants.environment * Constants.sustainable * 1 / 3) / 10, '.3f'), ) else: return dict( non_sust_extraction=format(self.group.in_round(self.round_number - 1).environment * Constants.non_sustainable, '.2f'), sust_extraction=format(self.group.in_round(self.round_number - 1).environment * Constants.sustainable, '.2f'), non_sust_payoff=format(self.group.in_round(self.round_number - 1).environment * Constants.non_sustainable / 10, '.2f'), sust_payoff=format((self.group.in_round(self.round_number - 1).environment * Constants.sustainable) * Constants.high_incentives / 10, '.2f'), current_env=self.group.in_round(self.round_number - 1).environment, sust_ext_minus_incentives=format(self.group.in_round(self.round_number - 1).environment * Constants.sustainable / 10, '.3f'), incentives=format((self.group.in_round(self.round_number - 1).environment * Constants.sustainable * 1 / 3) / 10, '.3f'), ) class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' title_text = "Please wait for the other participants to make their decision." body_text = "Thank you for your patience." def is_displayed(self): return self.group.dead == 0 and self.round_number != 10 and self.group.id_in_subsession == 1 class Results_1NI(Page): timeout_seconds = 60 def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and self.group.id_in_subsession == 1 and ( self.group.grp_treat == 'No-Intergen-low' or self.group.grp_treat == 'No-Intergen-high') def vars_for_template(self): return dict( total_earnings=format(self.group.total_extraction, '.2f') ) class Results_1I(Page): timeout_seconds = 60 def is_displayed(self): return self.group.dead == 0 and self.round_number == 1 and self.group.id_in_subsession == 1 and ( self.group.grp_treat == 'Intergen-low' or self.group.grp_treat == 'Intergen-high') def vars_for_template(self): return dict( total_earnings=format(self.group.total_extraction, '.2f') ) class Results_NI(Page): timeout_seconds = 40 def is_displayed(self): return self.round_number != 1 and self.round_number != 10 and self.group.dead == 0 \ and self.group.id_in_subsession == 1 and ( self.group.grp_treat == 'No-Intergen-low' or self.group.grp_treat == 'No-Intergen-high') def vars_for_template(self): cumulative_payoff = sum([p.rounds_payoff for p in self.player.in_all_rounds()]) return dict( total_earnings=format(self.group.total_extraction, '.2f'), cumulative_payoff=format(cumulative_payoff, '.2f'), ) class Results_I(Page): timeout_seconds = 40 def is_displayed(self): return self.round_number != 1 and self.round_number != 10 and self.group.dead == 0 \ and self.group.id_in_subsession == 1 and ( self.group.grp_treat == 'Intergen-low' or self.group.grp_treat == 'Intergen-high') def vars_for_template(self): cumulative_payoff = sum([p.rounds_payoff for p in self.player.in_all_rounds()]) return dict( total_earnings=format(self.group.total_extraction, '.2f'), cumulative_payoff=format(cumulative_payoff, '.2f'), ) class ResultsWaitPageFinal(WaitPage): after_all_players_arrive = 'set_payoffs' title_text = "Please wait for the other participants to make their decision." body_text = "Thank you for your patience." def is_displayed(self): return self.group.dead == 0 and self.round_number == 10 and self.group.id_in_subsession == 1 class Final_Results_I(Page): timeout_seconds = 40 form_model = 'player' def is_displayed(self): return self.round_number == 10 and self.group.dead == 0 and ( self.group.grp_treat == 'Intergen-low' or self.group.grp_treat == 'Intergen-high') \ and self.group.id_in_subsession == 1 def vars_for_template(self): total_payoff = sum([p.rounds_payoff for p in self.player.in_all_rounds()]) return dict( total_payoff=format(total_payoff, '.2f'), ) class Final_Results_NI(Page): timeout_seconds = 40 form_model = 'player' def is_displayed(self): return self.round_number == 10 and self.group.dead == 0 and ( self.group.grp_treat == 'No-Intergen-low' or self.group.grp_treat == 'No-Intergen-high') \ and self.group.id_in_subsession == 1 def vars_for_template(self): total_payoff = sum([p.rounds_payoff for p in self.player.in_all_rounds()]) return dict( total_payoff=format(total_payoff, '.2f'), ) class Last_NI(Page): timeout_seconds = 60 form_model = 'player' def vars_for_template(self): total_payoff = sum([p.rounds_payoff for p in self.player.in_all_rounds()]) total = total_payoff + Constants.showing_up_fee + self.player.waiting_time() return { 'payoff': self.participant.payoff, 'waiting_time': self.player.waiting_time(), 'total': total_payoff + Constants.showing_up_fee + self.player.waiting_time(), 'top_up': self.player.payoff, 'total_payoff': format(total_payoff, '.2f'), 'surplus': total - Constants.payoff_max, } def is_displayed(self): return self.round_number == 10 and self.group.dead == 0 and ( self.group.grp_treat == 'No-Intergen-low' or self.group.grp_treat == 'No-Intergen-high') \ and self.group.id_in_subsession == 1 class Last_I(Page): timeout_seconds = 60 form_model = 'player' def vars_for_template(self): total_payoff = sum([p.rounds_payoff for p in self.player.in_all_rounds()]) total = total_payoff + Constants.showing_up_fee + self.player.waiting_time() return { 'payoff': self.participant.payoff, 'waiting_time': self.player.waiting_time(), 'total': total_payoff + Constants.showing_up_fee + self.player.waiting_time(), 'top_up': self.player.payoff, 'total_payoff': format(total_payoff, '.2f'), 'surplus': total - Constants.payoff_max, } def is_displayed(self): return self.round_number == 10 and self.group.dead == 0 and ( self.group.grp_treat == 'Intergen-low' or self.group.grp_treat == 'Intergen-high') \ and self.group.id_in_subsession == 1 class END(Page): timeout_seconds = 90 form_model = 'player' form_fields = ['comment', 'contact'] def is_displayed(self): return (self.round_number == 10 and self.group.dead == 0) or ( self.group.dead == 1 and self.round_number == 1) or ( self.group.id_in_subsession > 1 and self.round_number == 1) class Our_questions_political(Page): form_model = 'player' form_fields = ['political_orientation', 'liberal'] def is_displayed(self): return (self.round_number == 10 and self.group.dead == 0 and self.group.id_in_subsession == 1) or ( self.group.id_in_subsession > 1 and self.round_number == 1) or ( self.group.dead == 1 and self.round_number == 1) class Our_questions_scientists(Page): form_model = 'player' form_fields = ['trust_scientists'] def is_displayed(self): return (self.round_number == 10 and self.group.dead == 0 and self.group.id_in_subsession == 1) or ( self.group.id_in_subsession > 1 and self.round_number == 1) or ( self.group.dead == 1 and self.round_number == 1) class Our_questions_environment(Page): form_model = 'player' form_fields = ['environment_worry', 'environment_responsibility', 'environment_natural_process'] def is_displayed(self): return (self.round_number == 10 and self.group.dead == 0 and self.group.id_in_subsession == 1) or ( self.group.id_in_subsession > 1 and self.round_number == 1) or ( self.group.dead == 1 and self.round_number == 1) class Transition_page(Page): def is_displayed(self): return (self.round_number == 10 and self.group.dead == 0) or ( self.group.dead == 1 and self.round_number == 1) or ( self.group.id_in_subsession > 1 and self.round_number == 1) class Q1(Page): form_model = 'player' def is_displayed(self): return (self.round_number == 10 and self.group.id_in_subsession == 1 and self.group.dead == 0) or ( self.group.dead == 1 and self.round_number == 1) or ( self.group.id_in_subsession > 1 and self.round_number == 1) class Demographics(Page): form_model = 'player' form_fields = ['gender', 'age', 'ethnic_min', 'prole', 'education'] def is_displayed(self): return ((self.round_number == 10 and self.group.id_in_subsession == 1 and self.group.dead == 0) or ( self.group.dead == 1 and self.round_number == 1) or ( self.group.id_in_subsession > 1 and self.round_number == 1)) class Completion(Page): form_model = 'player' def is_displayed(self): return (self.round_number == 10 and self.group.id_in_subsession == 1 and self.group.dead == 0) or ( self.group.dead == 1 and self.round_number == 1) or ( self.group.id_in_subsession > 1 and self.round_number == 1) page_sequence = [ ScreenOut, Welcome, Welcome2, timemoney0, MTurkPassiveSTD, timemoney, ResultsWaitPageDead, Instructions_I, Instructions_NI, Instructions_NIH, Instructions_IH, Instructions_I2, Instructions_NI2, Test1_HI, Test1_I, Test1_HNI, Test1_NI, Test2_HI, Test2_I, Test2_HNI, Test2_NI, InstructionsWaitPage, DL, DH, ResultsWaitPage, Results_1I, Results_1NI, Results_NI, Results_I, ResultsWaitPageFinal, Final_Results_I, Final_Results_NI, Last_I, Last_NI, DeadPage, Our_questions_political, Our_questions_scientists, Our_questions_environment, Q1, Demographics, END, Completion]