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','name','age','sex','studentID'] 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()], } 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 class Question(Page): def is_displayed(self): if self.round_number == 2: return True else: False # def vars_for_template(self): # return {'cumulative_payoff': sum([p.sent_amount for p in self.player.in_all_rounds()])*2, # 'self_payoff': 10-sum([p.sent_amount for p in self.player.in_all_rounds()])} form_model = 'player' form_fields = [ 'item3A', 'item3B', 'item3C', 'item3D', 'item3E', 'item3F' ] class Question2(Page): def is_displayed(self): if self.round_number == 2: return True else: False # def vars_for_template(self): # return {'cumulative_payoff': sum([p.sent_amount for p in self.player.in_all_rounds()])*2, # 'self_payoff': 10-sum([p.sent_amount for p in self.player.in_all_rounds()])} form_model = 'player' form_fields = [ 'Davis1', 'Davis2', 'Davis3', 'Davis4', 'Davis5', 'Davis6', 'Davis7', 'Davis8', 'Davis9', 'Davis10', 'Davis11', 'Davis12', 'Davis13', 'Davis14', 'Davis15', 'Davis16', 'Davis17', 'Davis18', 'Davis19', 'Davis20', 'Davis21', 'Davis22', 'Davis23', 'Davis24', 'Davis25', 'Davis26', 'Davis27', 'Davis28' ] class Question3(Page): def is_displayed(self): if self.round_number == 2: return True else: False # def vars_for_template(self): # return {'cumulative_payoff': sum([p.sent_amount for p in self.player.in_all_rounds()])*2, # 'self_payoff': 10-sum([p.sent_amount for p in self.player.in_all_rounds()])} form_model = 'player' form_fields = [ 'FNE1', 'FNE2', 'FNE3', 'FNE4', 'FNE5', 'FNE6', 'FNE7', 'FNE8', 'FNE9', 'FNE10', 'FNE11', 'FNE12', 'FNE13', 'FNE14', 'FNE15', 'FNE16', 'FNE17', 'FNE18', 'FNE19', 'FNE20', 'FNE21', 'FNE22', 'FNE23', 'FNE24', 'FNE25', 'FNE26', 'FNE27', 'FNE28', 'FNE29', 'FNE30', ] class Question4(Page): def is_displayed(self): if self.round_number == 2: return True else: False # def vars_for_template(self): # return {'cumulative_payoff': sum([p.sent_amount for p in self.player.in_all_rounds()])*2, # 'self_payoff': 10-sum([p.sent_amount for p in self.player.in_all_rounds()])} form_model = 'player' form_fields = [ 'Trust1', 'Trust2', 'Trust3', 'Trust4', 'Trust5', 'Trust6' ] class Question5(Page): def is_displayed(self): if self.round_number == 2: return True else: False # def vars_for_template(self): # return {'cumulative_payoff': sum([p.sent_amount for p in self.player.in_all_rounds()])*2, # 'self_payoff': 10-sum([p.sent_amount for p in self.player.in_all_rounds()])} form_model = 'player' form_fields = [ 'BigFive1', 'BigFive2', 'BigFive3', 'BigFive4', 'BigFive5', 'BigFive6', 'BigFive7', 'BigFive8', 'BigFive9', 'BigFive10' ] page_sequence = [Intro, Explain, Quiz, Quiz_Answer, Explain_control, Start_page, StartWaitPage, MyPage, ResultsWaitPage, Results, totalpayoff, Finish, Question, Question2, Question3, Question4, Question5] # page_sequence = [Start_page, StartWaitPage, MyPage, ResultsWaitPage, Results, totalpayoff, Finish]