from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Instruction_1(Page): pass class Instruction_2(Page): pass class Instruction_3(Page): pass class Instruction_4(Page): pass class Comprehension(Page): form_model = 'player' form_fields = ['answer1','answer2','answer3','answer4','answer5','answer6','answer7'] class Contribution(Page): form_model = 'player' form_fields = ['contribution'] def vars_for_template(self): #player_in_previous_rounds = self.player.in_previous_rounds() #group_in_all_rounds = self.group.in_all_rounds() return { 'initial': Constants.players_per_group*Constants.endowment, 'maximal':(Constants.players_per_group*Constants.endowment*Constants.num_rounds)/2, 'player_in_previous_rounds': self.player.in_previous_rounds(), 'total_payoff': sum( [p.contribution for p in self.player.in_previous_rounds()]), 'total_group_payoff': self.group.total_contribution, #'group_in_previous_rounds': self.group.in_previous_rounds(), 'total_group_payoff2': sum( [group.total_contribution for group in self.group.in_previous_rounds()]), } class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): group = self.group players = group.get_players() group.total_contribution = sum([p.contribution for p in players]) class SummaryResults(Page): # def is_displayed(self): # return self.round_number == Constants.num_rounds def vars_for_template(self): player_in_all_rounds = self.player.in_all_rounds() group_in_all_rounds = self.group.in_all_rounds() return { 'group_in_all_rounds': group_in_all_rounds, 'player_in_previous_rounds': self.player.in_previous_rounds(), 'total_payoff': sum( [p.contribution for p in self.player.in_all_rounds()]), 'total_group_payoff': self.group.total_contribution, 'player_in_all_rounds': player_in_all_rounds, 'total_group_payoff2': sum ( [group.total_contribution for group in group_in_all_rounds]), } page_sequence = [ Instruction_1, Instruction_2, Instruction_3, Instruction_4, Comprehension, Contribution, ResultsWaitPage, #Results, SummaryResults ]