from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class DecisionPlan1woDel(Page): form_model = "player" form_fields = ["plan1"] def plan1_choices(self): choices = [[1,"찬성"],[2,"반대"]] return choices def is_displayed(self): return self.round_number == 1 class DecisionPlan2woDel(Page): form_model = "player" form_fields = ["plan2_1", "plan2_2"] def plan2_1_choices(self): choices = [[1,"찬성"],[2,"반대"]] return choices def plan2_2_choices(self): choices = [[1,"찬성"],[2,"반대"]] return choices def is_displayed(self): return self.round_number == 1 class ResultsWaitPage1(WaitPage): title_text = "결과를 계산하는 중입니다." body_text = "결과를 계산하는 중입니다. 기다려주세요." def after_all_players_arrive(self): self.group.make_results_wo_del() def is_displayed(self): return self.round_number == 1 class DecisionPlan1(Page): form_model = "player" form_fields = ["plan1"] def plan1_choices(self): choices = [[1,"찬성"],[2,"반대"],[3,"위임"]] return choices def is_displayed(self): return self.round_number == 2 class DecisionPlan2(Page): form_model = "player" form_fields = ["plan2_1", "plan2_2"] def plan2_1_choices(self): choices = [[1, "찬성"], [2, "반대"], [3, "위임"]] return choices def plan2_2_choices(self): choices = [[1, "찬성"], [2, "반대"], [3, "위임"]] return choices def is_displayed(self): return self.round_number == 2 class ResultsWaitPage2(WaitPage): title_text = "결과를 계산하는 중입니다." body_text = "결과를 계산하는 중입니다. 기다려주세요." def after_all_players_arrive(self): self.group.make_results() def is_displayed(self): return self.round_number == 2 class Results(Page): def vars_for_template(self): p1 = self.group.get_player_by_id(1) p2 = self.group.get_player_by_id(2) p3 = self.group.get_player_by_id(3) if self.round_number ==1: return { 'informed_players':self.player.informed_players(), 'player1_decision':p1.plan_fi, 'player2_decision':p2.plan_fi, 'player3_decision':p3.plan_fi, 'votes_for_YES':self.group.votes_for_yes, } elif self.round_number ==2: return { 'final_payoff': self.participant.payoff, 'informed_players': self.player.informed_players(), 'player1_decision': p1.plan_fi, 'player2_decision': p2.plan_fi, 'player3_decision': p3.plan_fi, 'votes_for_YES': self.group.votes_for_yes, } page_sequence = [ DecisionPlan1woDel, DecisionPlan2woDel, ResultsWaitPage1, DecisionPlan1, DecisionPlan2, ResultsWaitPage2, Results ]