@@ -45,6 +45,61 @@ public function __construct(
45
45
parent ::__construct ($ em , $ eventLogService , $ dj , $ kernel );
46
46
}
47
47
48
+ #[Route(path: '/clarifications/by-problem/{probId<\d+>} ' , name: 'team_clarification_by_prob ' )]
49
+ public function viewByProblemAction (Request $ request , int $ probId ): Response
50
+ {
51
+ $ user = $ this ->dj ->getUser ();
52
+ $ team = $ user ->getTeam ();
53
+ $ teamId = $ team ->getTeamid ();
54
+ $ contest = $ this ->dj ->getCurrentContest ($ teamId );
55
+
56
+ $ problem = $ this ->em ->getRepository (Problem::class)->find ($ probId );
57
+ if ($ problem === null ) {
58
+ throw new NotFoundHttpException (sprintf ('Problem %d not found ' , $ probId ));
59
+ }
60
+ $ contestProblem = $ problem ->getContestProblems ();
61
+ $ foundProblemInContest = false ;
62
+ foreach ($ contestProblem as $ cp ) {
63
+ if ($ cp ->getContest ()->getCid () === $ contest ->getCid ()) {
64
+ $ foundProblemInContest = true ;
65
+ break ;
66
+ }
67
+ }
68
+ if (!$ foundProblemInContest ) {
69
+ throw new NotFoundHttpException (sprintf ('Problem %d not in current contest ' , $ probId ));
70
+ }
71
+
72
+ /** @var Clarification[] $clarifications */
73
+ $ clarifications = $ this ->em ->createQueryBuilder ()
74
+ ->from (Clarification::class, 'c ' )
75
+ ->leftJoin ('c.problem ' , 'p ' )
76
+ ->leftJoin ('c.sender ' , 's ' )
77
+ ->leftJoin ('c.recipient ' , 'r ' )
78
+ ->select ('c ' , 'p ' )
79
+ ->andWhere ('c.contest = :contest ' )
80
+ ->andWhere ('c.sender IS NULL ' )
81
+ ->andWhere ('c.recipient = :team OR c.recipient IS NULL ' )
82
+ ->andWhere ('c.problem = :problem ' )
83
+ ->setParameter ('contest ' , $ contest )
84
+ ->setParameter ('team ' , $ team )
85
+ ->setParameter ('problem ' , $ problem )
86
+ ->addOrderBy ('c.submittime ' , 'DESC ' )
87
+ ->addOrderBy ('c.clarid ' , 'DESC ' )
88
+ ->getQuery ()
89
+ ->getResult ();
90
+
91
+ $ data = [
92
+ 'clarifications ' => $ clarifications ,
93
+ 'team ' => $ team ,
94
+ 'problem ' => $ problem ,
95
+ ];
96
+ if ($ request ->isXmlHttpRequest ()) {
97
+ return $ this ->render ('team/clarifications_by_problem_modal.html.twig ' , $ data );
98
+ } else {
99
+ return $ this ->render ('team/clarifications_by_problem.html.twig ' , $ data );
100
+ }
101
+ }
102
+
48
103
/**
49
104
* @throws NonUniqueResultException
50
105
*/
0 commit comments