22
33namespace App \Controller ;
44
5+ use App \DataTransferObject \SubmissionRestriction ;
56use App \Entity \Contest ;
67use App \Entity \ContestProblem ;
78use App \Entity \Team ;
1112use App \Service \EventLogService ;
1213use App \Service \ScoreboardService ;
1314use App \Service \StatisticsService ;
15+ use App \Service \SubmissionService ;
1416use Doctrine \ORM \EntityManagerInterface ;
1517use Doctrine \ORM \NonUniqueResultException ;
1618use Symfony \Component \HttpFoundation \RedirectResponse ;
@@ -33,6 +35,7 @@ public function __construct(
3335 protected readonly ConfigurationService $ config ,
3436 protected readonly ScoreboardService $ scoreboardService ,
3537 protected readonly StatisticsService $ stats ,
38+ protected readonly SubmissionService $ submissionService ,
3639 EntityManagerInterface $ em ,
3740 EventLogService $ eventLog ,
3841 KernelInterface $ kernel ,
@@ -79,6 +82,18 @@ public function scoreboardAction(
7982
8083 if ($ static ) {
8184 $ data ['hide_menu ' ] = true ;
85+ $ submissions = $ this ->submissionService ->getSubmissionList (
86+ [$ contest ->getCid () => $ contest ],
87+ new SubmissionRestriction (valid: true ),
88+ paginated: false
89+ )[0 ];
90+
91+ $ submissionsPerTeamAndProblem = [];
92+ foreach ($ submissions as $ submission ) {
93+ $ submissionsPerTeamAndProblem [$ submission ->getTeam ()->getTeamid ()][$ submission ->getProblem ()->getProbid ()][] = $ submission ;
94+ }
95+ $ data ['submissionsPerTeamAndProblem ' ] = $ submissionsPerTeamAndProblem ;
96+ $ data ['verificationRequired ' ] = $ this ->config ->get ('verification_required ' );
8297 }
8398
8499 $ data ['current_contest ' ] = $ contest ;
@@ -267,4 +282,54 @@ protected function getBinaryFile(int $probId, callable $response): StreamedRespo
267282
268283 return $ response ($ probId , $ contest , $ contestProblem );
269284 }
285+
286+ #[Route(path: '/submissions/team/{teamId<\d+>}/problem/{problemId<\d+>} ' , name: 'public_submissions ' )]
287+ public function submissionsAction (Request $ request , int $ teamId , int $ problemId ): Response
288+ {
289+ $ contest = $ this ->dj ->getCurrentContest (onlyPublic: true );
290+
291+ if (!$ contest ) {
292+ throw $ this ->createNotFoundException ('No active contest found ' );
293+ }
294+
295+ /** @var Team|null $team */
296+ $ team = $ this ->em ->getRepository (Team::class)->find ($ teamId );
297+ if ($ team && $ team ->getCategory () && !$ team ->getCategory ()->getVisible ()) {
298+ $ team = null ;
299+ }
300+
301+ if (!$ team ) {
302+ throw $ this ->createNotFoundException ('Team not found ' );
303+ }
304+
305+ /** @var ContestProblem|null $problem */
306+ $ problem = $ this ->em ->getRepository (ContestProblem::class)->find ([
307+ 'problem ' => $ problemId ,
308+ 'contest ' => $ contest ,
309+ ]);
310+
311+ if (!$ problem ) {
312+ throw $ this ->createNotFoundException ('Problem not found ' );
313+ }
314+
315+ $ submissions = $ this ->submissionService ->getSubmissionList (
316+ [$ contest ->getCid () => $ contest ],
317+ new SubmissionRestriction (teamId: $ teamId , problemId: $ problemId , valid: true ),
318+ paginated: false
319+ )[0 ];
320+
321+ $ data = [
322+ 'contest ' => $ contest ,
323+ 'problem ' => $ problem ,
324+ 'team ' => $ team ,
325+ 'submissions ' => $ submissions ,
326+ 'verificationRequired ' => $ this ->config ->get ('verification_required ' ),
327+ ];
328+
329+ if ($ request ->isXmlHttpRequest ()) {
330+ return $ this ->render ('public/team_submissions_modal.html.twig ' , $ data );
331+ }
332+
333+ return $ this ->render ('public/team_submissions.html.twig ' , $ data );
334+ }
270335}
0 commit comments