from typing import List from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import numpy as np class Introduction(Page): def is_displayed(self): return self.round_number == 1 class WaitForInstructionsA(Page): def is_displayed(self): return self.round_number == 1 class Practice(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = ['practice_response1', 'practice_response2', 'practice_response3', 'practice_response4', 'practice_response5', 'practice_response6', 'true_false1', 'true_false2'] class Control(Page): timeout_seconds = 30 def is_displayed(self): return self.round_number == Constants.num_rounds/3+1 pass class Bonus(Page): timeout_seconds = 30 def is_displayed(self): return self.round_number == Constants.num_rounds/3+1 pass class CharityLow(Page): timeout_seconds = 30 def is_displayed(self): return self.round_number == Constants.num_rounds/3+1 pass class CharityHigh(Page): timeout_seconds = 30 def is_displayed(self): return self.round_number == Constants.num_rounds/3+1 pass class Reversion(Page): timeout_seconds = 30 def is_displayed(self): return self.round_number == Constants.num_rounds*2/3+1 pass class Round(Page): form_model = 'player' form_fields = ['submitted_answer1', 'submitted_answer2', 'submitted_answer3', 'submitted_answer4', 'reflection'] timeout_seconds = 60 def before_next_page(self): self.player.check_correct() self.player.sum_sentences() pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() pass class Results(Page): timeout_seconds = 15 def vars_for_template(self): return { 'player_in_previous_rounds': self.player.in_previous_rounds(), } class Questionnaire(Page): def is_displayed(self): return self.round_number == Constants.num_rounds form_model='player' form_fields = ['age', 'gender', 'race', 'major', 'religion', 'volunteer', 'donate'] class WaitForInstructionsB(Page): def is_displayed(self): return self.round_number == Constants.num_rounds class FinalPayment(Page): form_model = 'player' form_fields = ['confirm_payment'] def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): return { 'paying_round1': self.session.vars['paying_round1'], 'paying_round2': self.session.vars['paying_round2'], 'paying_round3': self.session.vars['paying_round3'], 'payoff_1': self.player.in_round(1).payoff, 'payoff_2': self.player.in_round(2).payoff, 'payoff_3': self.player.in_round(3).payoff, 'total_payoff': sum([p.payoff for p in self.player.in_rounds(1, 3)]) } page_sequence = [ Introduction, WaitForInstructionsA, Practice, WaitForInstructionsA, Control, # Bonus, # CharityLow, # CharityHigh, Reversion, Round, ResultsWaitPage, Results, Questionnaire, WaitForInstructionsB, FinalPayment ]