From 3ebae947eae3b6da60bc925d623cfaeda44bac76 Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+mvr320@users.noreply.github.com> Date: Fri, 13 Aug 2021 21:02:19 +0200 Subject: [PATCH 1/5] Remove JudgehostRestriction feature --- ChangeLog | 1 + .../Controller/API/JudgehostController.php | 22 -- .../Controller/Jury/AuditLogController.php | 2 - .../src/Controller/Jury/ContestController.php | 13 - .../Controller/Jury/JudgehostController.php | 13 +- .../Jury/JudgehostRestrictionController.php | 259 ------------------ .../Controller/Jury/SubmissionController.php | 26 +- .../Test/AddJudgehostRestrictionFixture.php | 21 -- webapp/src/Entity/Judgehost.php | 19 -- webapp/src/Entity/JudgehostRestriction.php | 142 ---------- .../Form/Type/JudgehostRestrictionType.php | 82 ------ webapp/src/Form/Type/JudgehostType.php | 8 - webapp/src/Service/CheckConfigService.php | 52 ---- webapp/templates/jury/index.html.twig | 1 - webapp/templates/jury/judgehost.html.twig | 12 - .../jury/judgehost_restriction.html.twig | 120 -------- .../jury/judgehost_restriction_add.html.twig | 18 -- .../jury/judgehost_restriction_edit.html.twig | 18 -- .../jury/judgehost_restrictions.html.twig | 23 -- .../jury/partials/judgehosts_form.html.twig | 5 - .../JudgehostRestrictionsControllerTest.php | 36 --- 21 files changed, 5 insertions(+), 888 deletions(-) delete mode 100644 webapp/src/Controller/Jury/JudgehostRestrictionController.php delete mode 100644 webapp/src/DataFixtures/Test/AddJudgehostRestrictionFixture.php delete mode 100644 webapp/src/Entity/JudgehostRestriction.php delete mode 100644 webapp/src/Form/Type/JudgehostRestrictionType.php delete mode 100644 webapp/templates/jury/judgehost_restriction.html.twig delete mode 100644 webapp/templates/jury/judgehost_restriction_add.html.twig delete mode 100644 webapp/templates/jury/judgehost_restriction_edit.html.twig delete mode 100644 webapp/templates/jury/judgehost_restrictions.html.twig delete mode 100644 webapp/tests/Unit/Controller/Jury/JudgehostRestrictionsControllerTest.php diff --git a/ChangeLog b/ChangeLog index 5460a95a98..b33b02d59e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,7 @@ Version 8.0.0 - DEV - Improve API action to add submission to adhere to the CCS spec. - Add API action to create clarification following CCS spec. - Add support for showing (pending) awards on the scoreboard. Thanks @shuibinlong! + - Remove JudgehostRestriction feature due to new Judgehost API Version 7.3.2 - 23 November 2020 diff --git a/webapp/src/Controller/API/JudgehostController.php b/webapp/src/Controller/API/JudgehostController.php index 14a2d2b312..5ed3ea3540 100644 --- a/webapp/src/Controller/API/JudgehostController.php +++ b/webapp/src/Controller/API/JudgehostController.php @@ -1137,28 +1137,6 @@ private function getSubmissionsToJudge(Judgehost $judgehost, $restrictJudgingOnS ->addOrderBy('s.submittime', 'ASC') ->addOrderBy('s.submitid', 'ASC'); - // Apply restrictions - if ($judgehost->getRestriction()) { - $restrictions = $judgehost->getRestriction()->getRestrictions(); - - if (isset($restrictions['contest'])) { - $queryBuilder - ->andWhere('s.contest IN (:restrictionContestIds)') - ->setParameter(':restrictionContestIds', $restrictions['contest']); - } - - if (isset($restrictions['problem'])) { - $queryBuilder - ->andWhere('s.problem IN (:restrictionProblemIds)') - ->setParameter(':restrictionProblemIds', $restrictions['problem']); - } - - if (isset($restrictions['language'])) { - $queryBuilder - ->andWhere('s.language IN (:restrictionLanguageIds)') - ->setParameter(':restrictionLanguageIds', $restrictions['language']); - } - } if ($restrictJudgingOnSameJudgehost) { $queryBuilder ->leftJoin('s.judgings', 'j', Join::WITH, 'j.judgehost = :judgehost') diff --git a/webapp/src/Controller/Jury/AuditLogController.php b/webapp/src/Controller/Jury/AuditLogController.php index c13d2b8f33..f32f3bbae9 100644 --- a/webapp/src/Controller/Jury/AuditLogController.php +++ b/webapp/src/Controller/Jury/AuditLogController.php @@ -161,8 +161,6 @@ private function generateDatatypeUrl(string $type, $id): ?string return $this->generateUrl('jury_judgehosts'); case 'judgehosts': return $this->generateUrl('jury_judgehosts'); - case 'judgehost_restriction': - return $this->generateUrl('jury_judgehost_restriction', ['restrictionId' => $id]); case 'judging': return $this->generateUrl('jury_submission_by_judging', ['jid' => $id]); case 'external_judgement': diff --git a/webapp/src/Controller/Jury/ContestController.php b/webapp/src/Controller/Jury/ContestController.php index 35bc1590cc..11d767d147 100644 --- a/webapp/src/Controller/Jury/ContestController.php +++ b/webapp/src/Controller/Jury/ContestController.php @@ -675,7 +675,6 @@ public function prefetchAction(Request $request, int $contestId) $cnt = 0; foreach ($judgehosts as $judgehost) { /** @var Judgehost $judgehost */ - $judgehostRestriction = $judgehost->getRestriction(); foreach ($contest->getProblems() as $contestProblem) { /** @var ContestProblem $contestProblem */ if (!$contestProblem->getAllowJudge() || !$contestProblem->getAllowSubmit()) { @@ -683,12 +682,6 @@ public function prefetchAction(Request $request, int $contestId) } /** @var Problem $problem */ $problem = $contestProblem->getProblem(); - if ($judgehostRestriction !== null) { - $restrictedProblems = $judgehostRestriction->getProblems(); - if (!empty($restrictedProblems) && !in_array($problem->getProbid(), $restrictedProblems)) { - continue; - } - } foreach ($problem->getTestcases() as $testcase) { /** @var Testcase $testcase */ $judgeTask = new JudgeTask(); @@ -723,12 +716,6 @@ public function prefetchAction(Request $request, int $contestId) ); foreach ($languages as $language) { /** @var Language $language */ - if ($judgehostRestriction !== null) { - $restrictedLangs = $judgehostRestriction->getLanguages(); - if (!empty($restrictedLangs) && !in_array($language->getLangid(), $restrictedLangs)) { - continue; - } - } $compileExec = $language->getCompileExecutable()->getImmutableExecutable(); $judgeTask = new JudgeTask(); $judgeTask diff --git a/webapp/src/Controller/Jury/JudgehostController.php b/webapp/src/Controller/Jury/JudgehostController.php index 475bf06bab..86e8b083ad 100644 --- a/webapp/src/Controller/Jury/JudgehostController.php +++ b/webapp/src/Controller/Jury/JudgehostController.php @@ -81,8 +81,7 @@ public function indexAction(Request $request): Response /** @var Judgehost[] $judgehosts */ $judgehosts = $this->em->createQueryBuilder() ->from(Judgehost::class, 'j') - ->leftJoin('j.restriction', 'r') - ->select('j', 'r') + ->select('j') ->andWhere('j.hidden = 0') ->orderBy('j.hostname') ->getQuery()->getResult(); @@ -92,7 +91,6 @@ public function indexAction(Request $request): Response 'hostname' => ['title' => 'hostname'], 'active' => ['title' => 'active'], 'status' => ['title' => 'status'], - 'restriction' => ['title' => 'restriction'], 'load' => ['title' => 'load'], 'last_judgingid' => ['title' => 'last judging'], ]; @@ -207,9 +205,6 @@ public function indexAction(Request $request): Response 'active' => [ 'value' => $judgehost->getActive() ? 'yes' : 'no', ], - 'restriction' => [ - 'value' => $judgehost->getRestriction() ? $judgehost->getRestriction()->getName() : 'none', - ], ]); // Create action links @@ -275,8 +270,7 @@ public function viewAction(Request $request, int $judgehostid): Response /** @var Judgehost $judgehost */ $judgehost = $this->em->createQueryBuilder() ->from(Judgehost::class, 'j') - ->leftJoin('j.restriction', 'r') - ->select('j', 'r') + ->select('j') ->andWhere('j.judgehostid = :judgehostid') ->setParameter(':judgehostid', $judgehostid) ->getQuery() @@ -341,8 +335,7 @@ public function deleteAction(Request $request, int $judgehostid): Response /** @var Judgehost $judgehost */ $judgehost = $this->em->createQueryBuilder() ->from(Judgehost::class, 'j') - ->leftJoin('j.restriction', 'r') - ->select('j', 'r') + ->select('j') ->andWhere('j.judgehostid = :judgehostid') ->setParameter(':judgehostid', $judgehostid) ->getQuery() diff --git a/webapp/src/Controller/Jury/JudgehostRestrictionController.php b/webapp/src/Controller/Jury/JudgehostRestrictionController.php deleted file mode 100644 index e9b4b34796..0000000000 --- a/webapp/src/Controller/Jury/JudgehostRestrictionController.php +++ /dev/null @@ -1,259 +0,0 @@ -em = $entityManager; - $this->dj = $dj; - $this->eventLog = $eventLog; - $this->kernel = $kernel; - } - - /** - * @Route("", name="jury_judgehost_restrictions") - */ - public function indexAction(Request $request): Response - { - /** @var JudgehostRestriction[] $judgehostRestrictions */ - $judgehostRestrictions = $this->em->createQueryBuilder() - ->from(JudgehostRestriction::class, 'jr') - ->select('jr') - ->orderBy('jr.restrictionid') - ->getQuery()->getResult(); - - $table_fields = [ - 'restrictionid' => ['title' => 'ID', 'sort' => true, 'default_sort' => true], - 'name' => ['title' => 'name', 'sort' => true], - 'numcontests' => ['title' => '# contests', 'sort' => true], - 'numproblems' => ['title' => '# problems', 'sort' => true], - 'numlanguages' => ['title' => '# languages', 'sort' => true], - 'numlinkedjudgehosts' => ['title' => '# linked judgehosts', 'sort' => true], - ]; - - $propertyAccessor = PropertyAccess::createPropertyAccessor(); - $judgehost_restrictions_table = []; - foreach ($judgehostRestrictions as $judgehostRestriction) { - $judgehostrestrictiondata = []; - $judgehostrestrictionactions = []; - // Get whatever fields we can from the problem object itself - foreach ($table_fields as $k => $v) { - if ($propertyAccessor->isReadable($judgehostRestriction, $k)) { - $judgehostrestrictiondata[$k] = ['value' => $propertyAccessor->getValue($judgehostRestriction, $k)]; - } - } - - $judgehostrestrictiondata = array_merge($judgehostrestrictiondata, [ - 'numcontests' => ['value' => count($judgehostRestriction->getContests())], - 'numproblems' => ['value' => count($judgehostRestriction->getProblems())], - 'numlanguages' => ['value' => count($judgehostRestriction->getLanguages())], - 'numlinkedjudgehosts' => ['value' => $judgehostRestriction->getJudgehosts()->count()], - ]); - - // Create action links - if ($this->isGranted('ROLE_ADMIN')) { - $judgehostrestrictionactions[] = [ - 'icon' => 'edit', - 'title' => 'edit this judgehost restriction', - 'link' => $this->generateUrl('jury_judgehost_restriction_edit', [ - 'restrictionId' => $judgehostRestriction->getRestrictionid(), - ]) - ]; - $judgehostrestrictionactions[] = [ - 'icon' => 'trash-alt', - 'title' => 'delete this judgehost restriction', - 'link' => $this->generateUrl('jury_judgehost_restriction_delete', [ - 'restrictionId' => $judgehostRestriction->getRestrictionid(), - ]), - 'ajaxModal' => true, - ]; - } - - // Save this to our list of rows - $judgehost_restrictions_table[] = [ - 'data' => $judgehostrestrictiondata, - 'actions' => $judgehostrestrictionactions, - 'link' => $this->generateUrl('jury_judgehost_restriction', - ['restrictionId' => $judgehostRestriction->getRestrictionid()]), - ]; - } - - - return $this->render('jury/judgehost_restrictions.html.twig', [ - 'judgehost_restrictions' => $judgehost_restrictions_table, - 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0, - ]); - } - - /** - * @Route("/{restrictionId<\d+>}", name="jury_judgehost_restriction") - * @throws NonUniqueResultException - */ - public function viewAction(int $restrictionId): Response - { - /** @var JudgehostRestriction $judgehostRestriction */ - $judgehostRestriction = $this->em->createQueryBuilder() - ->from(JudgehostRestriction::class, 'jr') - ->leftJoin('jr.judgehosts', 'j') - ->select('jr', 'j') - ->andWhere('jr.restrictionid = :restrictionId') - ->setParameter(':restrictionId', $restrictionId) - ->getQuery() - ->getOneOrNullResult(); - if (!$judgehostRestriction) { - throw new NotFoundHttpException(sprintf('Judgehost restriction with ID %s not found', $restrictionId)); - } - - /** @var Contest[] $contests */ - $contests = $this->em->createQueryBuilder() - ->from(Contest::class, 'c', 'c.cid') - ->select('c') - ->getQuery() - ->getResult(); - - /** @var Problem[] $problems */ - $problems = $this->em->createQueryBuilder() - ->from(Problem::class, 'p', 'p.probid') - ->select('p') - ->getQuery() - ->getResult(); - - /** @var Language[] $languages */ - $languages = $this->em->createQueryBuilder() - ->from(Language::class, 'l', 'l.langid') - ->select('l') - ->getQuery() - ->getResult(); - - return $this->render('jury/judgehost_restriction.html.twig', [ - 'judgehostRestriction' => $judgehostRestriction, - 'contests' => $contests, - 'problems' => $problems, - 'languages' => $languages, - ]); - } - - /** - * @Route("/{restrictionId<\d+>}/edit", name="jury_judgehost_restriction_edit") - * @IsGranted("ROLE_ADMIN") - */ - public function editAction(Request $request, int $restrictionId): Response - { - /** @var JudgehostRestriction $judgehostRestriction */ - $judgehostRestriction = $this->em->getRepository(JudgehostRestriction::class)->find($restrictionId); - - $form = $this->createForm(JudgehostRestrictionType::class, $judgehostRestriction); - - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $this->em->flush(); - $this->dj->auditlog('judgehost_restriction', $judgehostRestriction->getRestrictionid(), - 'updated'); - return $this->redirect($this->generateUrl( - 'jury_judgehost_restriction', - ['restrictionId' => $judgehostRestriction->getRestrictionid()] - )); - } - - return $this->render('jury/judgehost_restriction_edit.html.twig', [ - 'judgehostRestriction' => $judgehostRestriction, - 'form' => $form->createView(), - ]); - } - - /** - * @Route("/{restrictionId<\d+>}/delete", name="jury_judgehost_restriction_delete") - * @IsGranted("ROLE_ADMIN") - * @throws DBALException - * @throws NoResultException - * @throws NonUniqueResultException - */ - public function deleteAction(Request $request, int $restrictionId): Response - { - /** @var JudgehostRestriction $judgehostRestriction */ - $judgehostRestriction = $this->em->getRepository(JudgehostRestriction::class)->find($restrictionId); - - return $this->deleteEntities($request, $this->em, $this->dj, $this->eventLog, $this->kernel, - [$judgehostRestriction], $this->generateUrl('jury_judgehost_restrictions')); - } - - /** - * @Route("/add", name="jury_judgehost_restriction_add") - * @IsGranted("ROLE_ADMIN") - */ - public function addAction(Request $request): Response - { - $judgehostRestriction = new JudgehostRestriction(); - - $form = $this->createForm(JudgehostRestrictionType::class, $judgehostRestriction); - - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $this->em->persist($judgehostRestriction); - $this->em->flush(); - $this->dj->auditlog('judgehost_restriction', $judgehostRestriction->getRestrictionid(), - 'added'); - return $this->redirect($this->generateUrl( - 'jury_judgehost_restriction', - ['restrictionId' => $judgehostRestriction->getRestrictionid()] - )); - } - - return $this->render('jury/judgehost_restriction_add.html.twig', [ - 'form' => $form->createView(), - ]); - } -} diff --git a/webapp/src/Controller/Jury/SubmissionController.php b/webapp/src/Controller/Jury/SubmissionController.php index 76982ef097..7052c1478e 100644 --- a/webapp/src/Controller/Jury/SubmissionController.php +++ b/webapp/src/Controller/Jury/SubmissionController.php @@ -324,18 +324,12 @@ public function viewAction(Request $request, int $submitId) /** @var Judgehost[] $judgehosts */ $judgehosts = $this->em->createQueryBuilder() ->from(Judgehost::class, 'j') - ->leftJoin('j.restriction', 'r') - ->select('j', 'r') + ->select('j') ->andWhere('j.active = 1') ->getQuery() ->getResult(); $canBeJudged = false; foreach ($judgehosts as $judgehost) { - if (!$judgehost->getRestriction()) { - $canBeJudged = true; - break; - } - $queryBuilder = $this->em->createQueryBuilder() ->from(Submission::class, 's') ->select('s') @@ -349,24 +343,6 @@ public function viewAction(Request $request, int $submitId) ->setParameter(':submitid', $submission->getSubmitid()) ->setMaxResults(1); - $restrictions = $judgehost->getRestriction()->getRestrictions(); - if (isset($restrictions['contest'])) { - $queryBuilder - ->andWhere('s.contest IN (:contests)') - ->setParameter(':contests', $restrictions['contest']); - } - if (isset($restrictions['problem'])) { - $queryBuilder - ->leftJoin('s.problem', 'p') - ->andWhere('p.probid IN (:problems)') - ->setParameter(':problems', $restrictions['problem']); - } - if (isset($restrictions['language'])) { - $queryBuilder - ->andWhere('s.language IN (:languages)') - ->setParameter(':languages', $restrictions['language']); - } - if ($queryBuilder->getQuery()->getOneOrNullResult()) { $canBeJudged = true; } diff --git a/webapp/src/DataFixtures/Test/AddJudgehostRestrictionFixture.php b/webapp/src/DataFixtures/Test/AddJudgehostRestrictionFixture.php deleted file mode 100644 index d1eae5ef27..0000000000 --- a/webapp/src/DataFixtures/Test/AddJudgehostRestrictionFixture.php +++ /dev/null @@ -1,21 +0,0 @@ -getRepository(Problem::class)->findOneBy(['externalid' => 'boolfind']); - $restriction = (new JudgehostRestriction()) - ->setName('TestRestriction') - ->setProblems([$problem]) - ->setRejudgeOwn(True); - $manager->persist($restriction); - $manager->flush(); - } -} diff --git a/webapp/src/Entity/Judgehost.php b/webapp/src/Entity/Judgehost.php index 955aee8b93..2a6f599f35 100644 --- a/webapp/src/Entity/Judgehost.php +++ b/webapp/src/Entity/Judgehost.php @@ -14,7 +14,6 @@ * @ORM\Table( * name="judgehost", * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4", "comment"="Hostnames of the autojudgers"}, - * indexes={@ORM\Index(name="restrictionid", columns={"restrictionid"})}, * uniqueConstraints={ * @ORM\UniqueConstraint(name="hostname", columns={"hostname"}) * }) @@ -58,13 +57,6 @@ class Judgehost */ private $polltime; - /** - * @ORM\ManyToOne(targetEntity="JudgehostRestriction", inversedBy="judgehosts") - * @ORM\JoinColumn(name="restrictionid", referencedColumnName="restrictionid", onDelete="SET NULL") - * @Serializer\Exclude() - */ - private $restriction; - /** * @ORM\OneToMany(targetEntity="Judging", mappedBy="judgehost") * @Serializer\Exclude() @@ -137,17 +129,6 @@ public function getPolltime() return $this->polltime; } - public function setRestriction(?JudgehostRestriction $restriction = null): Judgehost - { - $this->restriction = $restriction; - return $this; - } - - public function getRestriction(): ?JudgehostRestriction - { - return $this->restriction; - } - public function addJudging(Judging $judging): Judgehost { $this->judgings[] = $judging; diff --git a/webapp/src/Entity/JudgehostRestriction.php b/webapp/src/Entity/JudgehostRestriction.php deleted file mode 100644 index 99bf0b1020..0000000000 --- a/webapp/src/Entity/JudgehostRestriction.php +++ /dev/null @@ -1,142 +0,0 @@ -judgehosts = new ArrayCollection(); - } - - public function getRestrictionid(): int - { - return $this->restrictionid; - } - - public function setName(string $name): JudgehostRestriction - { - $this->name = $name; - return $this; - } - - public function getName(): ?string - { - return $this->name; - } - - public function getShortDescription(): string - { - return $this->getName(); - } - - public function setRestrictions(array $restrictions): JudgehostRestriction - { - $this->restrictions = $restrictions; - return $this; - } - - public function getRestrictions(): array - { - return $this->restrictions; - } - - public function setContests(array $contests): JudgehostRestriction - { - $this->restrictions['contest'] = $contests; - return $this; - } - - public function getContests(): array - { - return $this->restrictions['contest'] ?? []; - } - - public function setProblems(array $problems): JudgehostRestriction - { - $this->restrictions['problem'] = $problems; - return $this; - } - - public function getProblems(): array - { - return $this->restrictions['problem'] ?? []; - } - - public function setLanguages(array $languages): JudgehostRestriction - { - $this->restrictions['language'] = $languages; - return $this; - } - - public function getLanguages(): array - { - return $this->restrictions['language'] ?? []; - } - - public function setRejudgeOwn(bool $rejudgeOwn): JudgehostRestriction - { - $this->restrictions['rejudge_own'] = $rejudgeOwn; - return $this; - } - - public function getRejudgeOwn(): bool - { - return $this->restrictions['rejudge_own'] ?? true; - } - - public function addJudgehost(Judgehost $judgehost): JudgehostRestriction - { - $this->judgehosts[] = $judgehost; - return $this; - } - - public function removeJudgehost(Judgehost $judgehost) - { - $this->judgehosts->removeElement($judgehost); - } - - public function getJudgehosts(): Collection - { - return $this->judgehosts; - } -} diff --git a/webapp/src/Form/Type/JudgehostRestrictionType.php b/webapp/src/Form/Type/JudgehostRestrictionType.php deleted file mode 100644 index 1620ce592e..0000000000 --- a/webapp/src/Form/Type/JudgehostRestrictionType.php +++ /dev/null @@ -1,82 +0,0 @@ -em = $em; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('name', TextType::class, [ - 'constraints' => [new NotBlank()], - ]); - - // Note that we can not use the normal EntityType form type, because these are not Doctrine associations - - $contests = $this->em->getRepository(Contest::class)->findAll(); - $contestChoices = []; - foreach ($contests as $contest) { - $contestChoices[$contest->getName()] = $contest->getCid(); - } - $builder->add('contests', ChoiceType::class, [ - 'multiple' => true, - 'required' => false, - 'choices' => $contestChoices, - ]); - - $problems = $this->em->getRepository(Problem::class)->findAll(); - $problemChoices = []; - foreach ($problems as $problem) { - $problemChoices[$problem->getName()] = $problem->getProbid(); - } - $builder->add('problems', ChoiceType::class, [ - 'multiple' => true, - 'required' => false, - 'choices' => $problemChoices, - ]); - - $languages = $this->em->getRepository(Language::class)->findAll(); - $languageChoices = []; - foreach ($languages as $language) { - $languageChoices[$language->getName()] = $language->getLangid(); - } - $builder->add('languages', ChoiceType::class, [ - 'multiple' => true, - 'required' => false, - 'choices' => $languageChoices, - ]); - $builder->add('rejudge_own', ChoiceType::class, [ - 'expanded' => true, - 'choices' => ['Yes' => true, 'Prefer a different judgehost (if possible)' => false], - 'label' => 'Allow rejudging on any judgehost', - ]); - $builder->add('save', SubmitType::class); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(['data_class' => JudgehostRestriction::class]); - } -} diff --git a/webapp/src/Form/Type/JudgehostType.php b/webapp/src/Form/Type/JudgehostType.php index 3af9b01c2b..c2a0e808a9 100644 --- a/webapp/src/Form/Type/JudgehostType.php +++ b/webapp/src/Form/Type/JudgehostType.php @@ -3,7 +3,6 @@ namespace App\Form\Type; use App\Entity\Judgehost; -use App\Entity\JudgehostRestriction; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -30,13 +29,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'no' => false, ], ]); - $builder->add('restriction', EntityType::class, [ - 'class' => JudgehostRestriction::class, - 'choice_label' => 'name', - 'required' => false, - 'placeholder' => '-- no restrictions --', - 'label' => 'Restrictions', - ]); } public function configureOptions(OptionsResolver $resolver) diff --git a/webapp/src/Service/CheckConfigService.php b/webapp/src/Service/CheckConfigService.php index a35f6db238..86980f34f2 100644 --- a/webapp/src/Service/CheckConfigService.php +++ b/webapp/src/Service/CheckConfigService.php @@ -129,7 +129,6 @@ public function runAll() : array $pl = [ 'problems' => $this->checkProblemsValidate(), 'languages' => $this->checkLanguagesValidate(), - 'judgability' => $this->checkProblemLanguageJudgability(), ]; $results['Problems and languages'] = $pl; @@ -597,57 +596,6 @@ public function checkLanguagesValidate() : array ($desc ?: 'No languages with problems found.')]; } - public function checkProblemLanguageJudgability() : array - { - $judgehosts = $this->em->getRepository(Judgehost::class)->findBy(['active' => 1]); - - foreach ($judgehosts as $judgehost) { - if ($judgehost->getRestriction() === null) { - return ['caption' => 'Problem, language and contest judgability', - 'result' => 'O', - 'desc' => sprintf("At least one judgehost (%s) is active and unrestricted.", $judgehost->getHostname())]; - } - } - - $languages = $this->em->getRepository(Language::class)->findAll(); - $contests = $this->dj->getCurrentContests(null, true); - - $desc = ''; - $result = 'O'; - foreach ($contests as $contest) { - foreach ($contest->getProblems() as $cp ) { - foreach ($languages as $lang) { - if (!$lang->getAllowSubmit()) { - continue; - } - $found1 = false; - foreach ($judgehosts as $judgehost) { - $rest = $judgehost->getRestriction(); - $rest_c = $rest->getContests(); - $rest_p = $rest->getProblems(); - $rest_l = $rest->getLanguages(); - if ((empty($rest_c) || in_array($contest->getCid(), $rest_c)) && - (empty($rest_p) || in_array($cp->getProbid(), $rest_p)) && - (empty($rest_l) || in_array($lang->getLangid(), $rest_l))) { - $found1 = true; - continue; - } - } - if (!$found1) { - $result = 'E'; - $desc .= sprintf("No active judgehost that allows combination c%s-p%s-%s\n", - $contest->getCid(), $cp->getProbid(), $lang->getLangid()); - } - } - } - } - $desc = $desc ?: 'Found at least one judgehost for each combination of current/future contest, associated problem, enabled language'; - - return ['caption' => 'Problem, language and contest judgability', - 'result' => $result, - 'desc' => $desc]; - } - public function checkAffiliations() : array { $show_logos = $this->config->get('show_affiliation_logos'); diff --git a/webapp/templates/jury/index.html.twig b/webapp/templates/jury/index.html.twig index 81147cc9d9..aef7f3008a 100644 --- a/webapp/templates/jury/index.html.twig +++ b/webapp/templates/jury/index.html.twig @@ -29,7 +29,6 @@
ID | -{{ judgehostRestriction.restrictionid }} | -|
---|---|---|
Name | -{{ judgehostRestriction.name }} | -|
Restrict to contests | - {% if judgehostRestriction.contests is empty %} -none | - {% else %} -
- {% for contest in judgehostRestriction.contests %}
-
- {{ contests[contest].name }} ({{ contests[contest].shortname }} - c{{ contest }})
-
- - {% endfor %} - |
- {% endif %}
-
Restrict to problems | - {% if judgehostRestriction.problems is empty %} -none | - {% else %} -
- {% for problem in judgehostRestriction.problems %}
-
- {{ problems[problem].name }} (p{{ problem }})
-
- - {% endfor %} - |
- {% endif %}
-
Restrict to languages | - {% if judgehostRestriction.languages is empty %} -none | - {% else %} -
- {% for language in judgehostRestriction.languages %}
-
- {{ languages[language].name }} ({{ language }})
-
- - {% endfor %} - |
- {% endif %}
-
Rejudge by same judgehost | -{{ judgehostRestriction.rejudgeOwn | printYesNo }} | -
no judgehosts
- {% else %} -hostname | -active | -
---|---|
- - {{ judgehost.hostname }} - - | -- - {{ judgehost.active | printYesNo }} - - | -
- {{ button(path('jury_judgehost_restriction_add'), 'Add new judgehost restriction', 'primary', 'plus') }} -
- {%- endif %} - -{% endblock %} diff --git a/webapp/templates/jury/partials/judgehosts_form.html.twig b/webapp/templates/jury/partials/judgehosts_form.html.twig index 6b53aaf11e..ed69c5400c 100644 --- a/webapp/templates/jury/partials/judgehosts_form.html.twig +++ b/webapp/templates/jury/partials/judgehosts_form.html.twig @@ -6,7 +6,6 @@