@@ -88,6 +88,13 @@ public function indexAction(): Response
88
88
'type ' => ['title ' => 'type ' , 'sort ' => true ],
89
89
];
90
90
91
+ if ($ this ->isGranted ('ROLE_ADMIN ' )) {
92
+ $ table_fields = array_merge (
93
+ ['checkbox ' => ['title ' => '<input type="checkbox" class="select-all" title="Select all problems"> ' , 'sort ' => false , 'search ' => false , 'raw ' => true ]],
94
+ $ table_fields
95
+ );
96
+ }
97
+
91
98
$ contestCountData = $ this ->em ->createQueryBuilder ()
92
99
->from (ContestProblem::class, 'cp ' )
93
100
->select ('COUNT(cp.shortname) AS count ' , 'p.probid ' )
@@ -109,6 +116,28 @@ public function indexAction(): Response
109
116
$ p = $ row [0 ];
110
117
$ problemdata = [];
111
118
$ problemactions = [];
119
+
120
+ if ($ this ->isGranted ('ROLE_ADMIN ' )) {
121
+ $ problemIsLocked = false ;
122
+ foreach ($ p ->getContestProblems () as $ contestProblem ) {
123
+ if ($ contestProblem ->getContest ()->isLocked ()) {
124
+ $ problemIsLocked = true ;
125
+ break ;
126
+ }
127
+ }
128
+
129
+ if (!$ problemIsLocked ) {
130
+ $ problemdata ['checkbox ' ] = [
131
+ 'value ' => sprintf (
132
+ '<input type="checkbox" name="ids[]" value="%s" class="problem-checkbox"> ' ,
133
+ $ p ->getProbid ()
134
+ )
135
+ ];
136
+ } else {
137
+ $ problemdata ['checkbox ' ] = ['value ' => '' ];
138
+ }
139
+ }
140
+
112
141
// Get whatever fields we can from the problem object itself.
113
142
foreach ($ table_fields as $ k => $ v ) {
114
143
if ($ propertyAccessor ->isReadable ($ p , $ k )) {
@@ -999,6 +1028,39 @@ public function editAction(Request $request, int $probId): Response
999
1028
]);
1000
1029
}
1001
1030
1031
+ #[IsGranted('ROLE_ADMIN ' )]
1032
+ #[Route(path: '/delete-multiple ' , name: 'jury_problem_delete_multiple ' , methods: ['GET ' , 'POST ' ])]
1033
+ public function deleteMultipleAction (Request $ request ): Response
1034
+ {
1035
+ $ ids = $ request ->query ->all ('ids ' );
1036
+ if (empty ($ ids )) {
1037
+ throw new BadRequestHttpException ('No IDs specified for deletion ' );
1038
+ }
1039
+
1040
+ $ problems = $ this ->em ->getRepository (Problem::class)->findBy (['probid ' => $ ids ]);
1041
+
1042
+ $ deletableProblems = [];
1043
+ foreach ($ problems as $ problem ) {
1044
+ $ isLocked = false ;
1045
+ foreach ($ problem ->getContestProblems () as $ contestProblem ) {
1046
+ if ($ contestProblem ->getContest ()->isLocked ()) {
1047
+ $ isLocked = true ;
1048
+ break ;
1049
+ }
1050
+ }
1051
+ if (!$ isLocked ) {
1052
+ $ deletableProblems [] = $ problem ;
1053
+ }
1054
+ }
1055
+
1056
+ if (empty ($ deletableProblems )) {
1057
+ $ this ->addFlash ('warning ' , 'No problems could be deleted (they might be locked). ' );
1058
+ return $ this ->redirectToRoute ('jury_problems ' );
1059
+ }
1060
+
1061
+ return $ this ->deleteEntities ($ request , $ deletableProblems , $ this ->generateUrl ('jury_problems ' ));
1062
+ }
1063
+
1002
1064
#[IsGranted('ROLE_ADMIN ' )]
1003
1065
#[Route(path: '/{probId<\d+>}/delete ' , name: 'jury_problem_delete ' )]
1004
1066
public function deleteAction (Request $ request , int $ probId ): Response
0 commit comments