from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants class Player1(Page): form_model = 'group' form_fields = ['p1sel'] timeout_seconds = Constants.totime timeout_submission = {'p1sel': 'Do not delete any link'} def p1sel_choices(self): lremain = [] if self.group.AB == 1: lremain.append('Delete the link with Participant ' + Constants.player2); if self.group.AC == 1: lremain.append('Delete the link with Participant ' + Constants.player3); if self.group.AD == 1: lremain.append('Delete the link with Participant ' + Constants.player4); if self.group.AE == 1: lremain.append('Delete the link with Participant ' + Constants.player5); if self.group.AF == 1: lremain.append('Delete the link with Participant ' + Constants.player6); lremain.append('Do not delete any link'); return lremain def is_displayed(self): return self.player.id_in_group == 1 and self.group.CO < Constants.players_per_group class Player2(Page): form_model = 'group' form_fields = ['p2sel'] timeout_seconds = Constants.totime timeout_submission = {'p2sel': 'Do not delete any link'} def p2sel_choices(self): lremain = [] if self.group.BA == 1: lremain.append('Delete the link with Participant ' + Constants.player1); if self.group.BC == 1: lremain.append('Delete the link with Participant ' + Constants.player3); if self.group.BD == 1: lremain.append('Delete the link with Participant ' + Constants.player4); if self.group.BE == 1: lremain.append('Delete the link with Participant ' + Constants.player5); lremain.append('Do not delete any link'); return lremain def is_displayed(self): return self.player.id_in_group == 2 and self.group.CO < Constants.players_per_group class Player3(Page): form_model = 'group' form_fields = ['p3sel'] timeout_seconds = Constants.totime timeout_submission = {'p3sel': 'Do not delete any link'} def p3sel_choices(self): lremain = [] if self.group.CA == 1: lremain.append('Delete the link with Participant ' + Constants.player1); if self.group.CB == 1: lremain.append('Delete the link with Participant ' + Constants.player2); if self.group.CD == 1: lremain.append('Delete the link with Participant ' + Constants.player4); if self.group.CE == 1: lremain.append('Delete the link with Participant ' + Constants.player5); lremain.append('Do not delete any link'); return lremain def is_displayed(self): return self.player.id_in_group == 3 and self.group.CO < Constants.players_per_group class Player4(Page): form_model = 'group' form_fields = ['p4sel'] timeout_seconds = Constants.totime timeout_submission = {'p4sel': 'Do not delete any link'} def p4sel_choices(self): lremain = [] if self.group.DA == 1: lremain.append('Delete the link with Participant ' + Constants.player1); if self.group.DB == 1: lremain.append('Delete the link with Participant ' + Constants.player2); if self.group.DC == 1: lremain.append('Delete the link with Participant ' + Constants.player3); if self.group.DE == 1: lremain.append('Delete the link with Participant ' + Constants.player5); if self.group.DF == 1: lremain.append('Delete the link with Participant ' + Constants.player6); if self.group.DG == 1: lremain.append('Delete the link with Participant ' + Constants.player7); lremain.append('Do not delete any link'); return lremain def is_displayed(self): return self.player.id_in_group == 4 and self.group.CO < Constants.players_per_group class Player5(Page): form_model = 'group' form_fields = ['p5sel'] timeout_seconds = Constants.totime timeout_submission = {'p5sel': 'Do not delete any link'} def p5sel_choices(self): lremain = [] if self.group.EA == 1: lremain.append('Delete the link with Participant ' + Constants.player1); if self.group.EB == 1: lremain.append('Delete the link with Participant ' + Constants.player2); if self.group.EC == 1: lremain.append('Delete the link with Participant ' + Constants.player3); if self.group.ED == 1: lremain.append('Delete the link with Participant ' + Constants.player4); if self.group.EG == 1: lremain.append('Delete the link with Participant ' + Constants.player7); lremain.append('Do not delete any link'); return lremain def is_displayed(self): return self.player.id_in_group == 5 and self.group.CO < Constants.players_per_group class Player6(Page): form_model = 'group' form_fields = ['p6sel'] timeout_seconds = Constants.totime timeout_submission = {'p6sel': 'Do not delete any link'} def p6sel_choices(self): lremain = [] if self.group.FA == 1: lremain.append('Delete the link with Participant ' + Constants.player1); if self.group.FD == 1: lremain.append('Delete the link with Participant ' + Constants.player4); if self.group.FG == 1: lremain.append('Delete the link with Participant ' + Constants.player7); lremain.append('Do not delete any link'); return lremain def is_displayed(self): return self.player.id_in_group == 6 and self.group.CO < Constants.players_per_group class Player7(Page): form_model = 'group' form_fields = ['p7sel'] timeout_seconds = Constants.totime timeout_submission = {'p7sel': 'Do not delete any link'} def p7sel_choices(self): lremain = [] if self.group.GD == 1: lremain.append('Delete the link with Participant ' + Constants.player4); if self.group.GE == 1: lremain.append('Delete the link with Participant ' + Constants.player5); if self.group.FG == 1: lremain.append('Delete the link with Participant ' + Constants.player6); lremain.append('Do not delete any link'); return lremain def is_displayed(self): return self.player.id_in_group == 7 and self.group.CO < Constants.players_per_group class ResultsWaitPage(WaitPage): template_name = 'seven_clique_t5/MyWaitPage.html' def after_all_players_arrive(self): self.group.set_var_1() def is_displayed(self): return self.group.CO < Constants.players_per_group class ResultsWaitPage2(WaitPage): template_name = 'seven_clique_t5/MyWaitPage.html' def after_all_players_arrive(self): self.group.set_var_2() def is_displayed(self): return self.group.CO < Constants.players_per_group class ResultsWaitPage3(WaitPage): template_name = 'seven_clique_t5/MyWaitPage.html' def after_all_players_arrive(self): self.group.set_var_3() def is_displayed(self): return self.group.CO < Constants.players_per_group class ResultsWaitPage4(WaitPage): template_name = 'seven_clique_t5/MyWaitPage.html' def after_all_players_arrive(self): self.group.set_var_4() def is_displayed(self): return self.group.CO < Constants.players_per_group class ResultsWaitPage5(WaitPage): template_name = 'seven_clique_t5/MyWaitPage.html' def after_all_players_arrive(self): self.group.set_var_5() def is_displayed(self): return self.group.CO < Constants.players_per_group class ResultsWaitPage6(WaitPage): template_name = 'seven_clique_t5/MyWaitPage.html' def after_all_players_arrive(self): self.group.set_var_6() def is_displayed(self): return self.group.CO < Constants.players_per_group class ResultsWaitPage7(WaitPage): template_name = 'seven_clique_t5/MyWaitPage.html' def after_all_players_arrive(self): self.group.set_var_7() def is_displayed(self): return self.group.CO < Constants.players_per_group class Calculating(WaitPage): def after_all_players_arrive(self): if self.group.CO == Constants.players_per_group: self.group.set_payoff() def is_displayed(self): return self.group.done < 2 class Results(Page): timeout_seconds = 30 def is_displayed(self): return self.group.CO >= Constants.players_per_group and self.group.done < 2 def before_next_page(self): for g in self.group.in_rounds(self.round_number, Constants.num_rounds): g.done = 2 class ShuffleWaitPage(WaitPage): wait_for_all_groups = True def after_all_players_arrive(self): # https://otree.readthedocs.io/en/latest/multiplayer/groups.html#shuffling-during-the-session self.subsession.assortative_grouping() for subsession in self.subsession.in_rounds(2, Constants.num_rounds): subsession.group_like_round(1) def is_displayed(self): return self.round_number == 1 class EndOfRound_WaitPage(WaitPage): template_name = 'seven_clique_t5/MyWaitPage.html' wait_for_all_groups = True def after_all_players_arrive(self): pass #def is_displayed(self): # return self.group.CO >= Constants.players_per_group and self.group.done < 2 page_sequence = [ #have to pre-randomize ShuffleWaitPage, Player1, ResultsWaitPage, Player3, ResultsWaitPage3, Player2, ResultsWaitPage2, Player5, ResultsWaitPage5, Player4, ResultsWaitPage4, Player6, ResultsWaitPage6, Player7, ResultsWaitPage7, Calculating, Results, #EndOfRound_WaitPage ]