|
34 | 34 | use Symfony\Component\HttpFoundation\Request;
|
35 | 35 | use Symfony\Component\HttpFoundation\Response;
|
36 | 36 | use Symfony\Component\HttpFoundation\StreamedResponse;
|
| 37 | +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
37 | 38 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
38 | 39 | use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
39 | 40 | use Symfony\Component\HttpKernel\KernelInterface;
|
40 | 41 | use Symfony\Component\PropertyAccess\PropertyAccess;
|
41 | 42 | use Symfony\Component\Routing\Attribute\Route;
|
| 43 | +use Symfony\Component\Routing\RouterInterface; |
42 | 44 | use Symfony\Component\Security\Http\Attribute\IsGranted;
|
43 | 45 | use Symfony\Component\Yaml\Yaml;
|
44 | 46 | use ZipArchive;
|
@@ -1151,6 +1153,43 @@ public function requestRemainingRunsWholeProblemAction(string $probId): Redirect
|
1151 | 1153 | return $this->redirectToRoute('jury_problem', ['probId' => $probId]);
|
1152 | 1154 | }
|
1153 | 1155 |
|
| 1156 | + #[Route(path: '/{contestId}/{probId}/toggle/{type<judge|submit>}', name: 'jury_problem_toggle')] |
| 1157 | + public function toggleSubmitAction( |
| 1158 | + RouterInterface $router, |
| 1159 | + Request $request, |
| 1160 | + string $contestId, |
| 1161 | + string $probId, |
| 1162 | + string $type |
| 1163 | + ): Response { |
| 1164 | + $contestProblem = $this->em->getRepository(ContestProblem::class)->find([ |
| 1165 | + 'contest' => $contestId, |
| 1166 | + 'problem' => $probId, |
| 1167 | + ]); |
| 1168 | + if (!$contestProblem) { |
| 1169 | + throw new NotFoundHttpException(sprintf('Problem with ID %s not found for contest %s', $probId, $contestId)); |
| 1170 | + } |
| 1171 | + |
| 1172 | + $value = $request->request->getBoolean('value'); |
| 1173 | + |
| 1174 | + switch ($type) { |
| 1175 | + case 'judge': |
| 1176 | + $contestProblem->setAllowJudge($value); |
| 1177 | + $label = 'set allow judge'; |
| 1178 | + break; |
| 1179 | + case 'submit': |
| 1180 | + $contestProblem->setAllowSubmit($value); |
| 1181 | + $label = 'set allow submit'; |
| 1182 | + break; |
| 1183 | + default: |
| 1184 | + throw new BadRequestHttpException('Unknown toggle type'); |
| 1185 | + } |
| 1186 | + $this->em->flush(); |
| 1187 | + |
| 1188 | + $id = [$contestProblem->getCid(), $contestProblem->getProbid()]; |
| 1189 | + $this->dj->auditlog('contest_problem', implode(', ', $id), $label, $value ? 'yes' : 'no'); |
| 1190 | + return $this->redirectToLocalReferrer($router, $request, $this->generateUrl('jury_problems')); |
| 1191 | + } |
| 1192 | + |
1154 | 1193 | /**
|
1155 | 1194 | * @param array<string, string[]> $allMessages
|
1156 | 1195 | */
|
|
0 commit comments