2
2
3
3
namespace App \Controller ;
4
4
5
+ use App \DataTransferObject \SubmissionRestriction ;
5
6
use App \Entity \Contest ;
6
7
use App \Entity \ContestProblem ;
7
8
use App \Entity \Team ;
11
12
use App \Service \EventLogService ;
12
13
use App \Service \ScoreboardService ;
13
14
use App \Service \StatisticsService ;
15
+ use App \Service \SubmissionService ;
14
16
use Doctrine \ORM \EntityManagerInterface ;
15
17
use Doctrine \ORM \NonUniqueResultException ;
16
18
use Symfony \Component \HttpFoundation \RedirectResponse ;
@@ -33,6 +35,7 @@ public function __construct(
33
35
protected readonly ConfigurationService $ config ,
34
36
protected readonly ScoreboardService $ scoreboardService ,
35
37
protected readonly StatisticsService $ stats ,
38
+ protected readonly SubmissionService $ submissionService ,
36
39
EntityManagerInterface $ em ,
37
40
EventLogService $ eventLog ,
38
41
KernelInterface $ kernel ,
@@ -79,6 +82,18 @@ public function scoreboardAction(
79
82
80
83
if ($ static ) {
81
84
$ 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 ' );
82
97
}
83
98
84
99
$ data ['current_contest ' ] = $ contest ;
@@ -267,4 +282,54 @@ protected function getBinaryFile(int $probId, callable $response): StreamedRespo
267
282
268
283
return $ response ($ probId , $ contest , $ contestProblem );
269
284
}
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
+ }
270
335
}
0 commit comments