from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Intro(Page): form_model = 'player' form_fields = ['consent_btn'] def is_displayed(self): return self.round_number == 1 class Quiz(Page): form_model = 'player' form_fields = [ 'item1A', 'item2A' ] def get_form_fields(self): fields = self.form_fields return fields def is_displayed(self): return self.round_number == 1 class Quiz_Answer(Page): def is_displayed(self): return self.round_number == 1 class Explain_control(Page): def is_displayed(self): return self.round_number == 1 class Explain(Page): def is_displayed(self): return self.round_number == 1 class Start_page(Page): def is_displayed(self): return self.round_number == 1 class StartWaitPage(WaitPage): def is_displayed(self): return self.round_number == 1 class MyPage(Page): form_model = 'player' form_fields = ['decision'] class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' class Results(Page): def vars_for_template(self): group = self.group players = group.get_players() otherplayer = self.player otherpy = otherplayer.get_others_in_group() # print(players) # print(players[0].id_in_group) # print(players[0].payoff) # print(players[0].curr_cumu_payoffs) # print(group.get_player_by_id(1).payoff) # print(otherpy[0].id_in_group) # print(otherpy[0].curr_cumu_payoffs) # print(self.player.get_others_in_group()[0].curr_cumu_payoffs) #print(self.player.id_in_group) #print(self.player.curr_cumu_payoffs) return { 'IDname1': self.player.id_in_group, 'cumu_payoffs1': [p.curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname2': otherpy[0].id_in_group, 'cumu_payoffs2': [p.get_others_in_group()[0].curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname3': otherpy[1].id_in_group, 'cumu_payoffs3': [p.get_others_in_group()[1].curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname4': otherpy[2].id_in_group, 'cumu_payoffs4': [p.get_others_in_group()[2].curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname5': otherpy[3].id_in_group, 'cumu_payoffs5': [p.get_others_in_group()[3].curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname6': otherpy[4].id_in_group, 'cumu_payoffs6': [p.get_others_in_group()[4].curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname7': otherpy[5].id_in_group, 'cumu_payoffs7': [p.get_others_in_group()[5].curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname8': otherpy[6].id_in_group, 'cumu_payoffs8': [p.get_others_in_group()[6].curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname9': otherpy[7].id_in_group, 'cumu_payoffs9': [p.get_others_in_group()[7].curr_cumu_payoffs for p in self.player.in_all_rounds()], 'IDname10': otherpy[8].id_in_group, 'cumu_payoffs10': [p.get_others_in_group()[8].curr_cumu_payoffs for p in self.player.in_all_rounds()], } class totalpayoff(WaitPage): def after_all_players_arrive(self): if self.round_number == C.NUM_ROUNDS: self.group.total_payoff() else: pass class Finish(Page): def is_displayed(self): return self.round_number == C.NUM_ROUNDS page_sequence = [Explain, Explain_control, Start_page, StartWaitPage, MyPage, ResultsWaitPage, Results, totalpayoff, Finish] # page_sequence = [Start_page, StartWaitPage, MyPage, ResultsWaitPage, Results, totalpayoff, Finish]