from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants """In pages.py all pages that will be shown to the player during the game are defined. As the content of each page is found in the html-templates, the purpose of pages.py is to define whether and when the page is displayed, whether it has form fields to be filled out by the player and additional waitpages to calculate the input by the players. """ class Consent (Page): #consent form, whether player agrees to conditions of participation def is_displayed(self): #determines whether page is displayed to (all) players return self.round_number == 1 #only gets displayed in the first round of the game form_model = 'player' #content of the form field will be saved in class Player form_fields = ['consent'] #creates formfield for content on page Consent to be filled out by player pass class Instructions_1(Page): def is_displayed(self): return self.round_number == 1 #Instructions: only gets displayed in the first round of the game pass class Instructions_2(Page): def is_displayed(self): return self.round_number == 1 #Instructions: only gets displayed in the first round of the game pass class Instructions_3(Page): def is_displayed(self): return self.round_number == 1 #Instructions: only gets displayed in the first round of the game pass class Instructions_4(Page): def is_displayed(self): return self.round_number == 1 #Instructions: only gets displayed in the first round of the game pass class Instructions_5(Page): def is_displayed(self): return self.round_number == 1 #Instructions: only gets displayed in the first round of the game pass class Decision(Page): #Vaccination Decision form_model = 'player' #content of the form field will be saved in class Player form_fields = ['decision'] #creates formfield for decision on page Decision pass #default value of is_displayed() is true: page will be displayed every round class ResultsWaitPage(WaitPage): #Waitpage to calculate parameters after all players entered their decision def after_all_players_arrive(self): #executes the following functions after all players arrived at this point #all functions on this waitpage are defined in models.py in the class Group self.group.calc_vaccination() self.group.calc_prob_ill() self.group.illness() self.group.sideeffects() self.group.fitnesspoints() body_text = "Waiting for other participants to decide." #gets displayed while players wait for other participants to arrive pass class PayoffWaitPage(WaitPage): #Waitpage to calculate payoff at the end of the game def is_displayed(self): #only gets displayed in the last round return self.round_number == Constants.num_rounds def after_all_players_arrive(self): #executes the following functions after all players arrived at this point #the function on this waitpage is defined in models.py in the class Group self.group.calc_payoff() body_text = "Calculating Payoff." #gets displayed while players wait for other participants to arrive pass class Results(Page): #Page that shows feedback. Gets displayed at the end of each round pass class Payoff_and_Debriefing(Page): #Page that shows payoff and debriefs at the end of the game def is_displayed(self): #only gets displayed in the last round return self.round_number == Constants.num_rounds pass #Here, the sequence in which the pages are to be shown to the players during the game have to be defined. If a page is #not listed in this sequence, it will not be displayed. page_sequence = [ Consent, Instructions_1, Instructions_2, Instructions_3, Instructions_4, Instructions_5, Decision, ResultsWaitPage, Results, PayoffWaitPage, Payoff_and_Debriefing ]