diff --git a/webapp/src/Controller/API/ClarificationController.php b/webapp/src/Controller/API/ClarificationController.php index 397e2e499b..a502b64c82 100644 --- a/webapp/src/Controller/API/ClarificationController.php +++ b/webapp/src/Controller/API/ClarificationController.php @@ -297,6 +297,14 @@ protected function getQueryBuilder(Request $request): QueryBuilder } } + // For non-API-reader users, only expose the problems after the contest has started. + // `WF Access Policy` allows for clarifications before the contest, but not to disclose the problem + // so referencing them in clarifications would violate referential integrity. + if (!$this->dj->checkrole('api_reader')) { + $queryBuilder->andWhere('c.starttime < :now OR clar.problem IS NULL') + ->setParameter('now', Utils::now()); + } + if ($request->query->has('problem')) { $queryBuilder ->andWhere('clar.problem = :problem') diff --git a/webapp/src/Controller/Team/MiscController.php b/webapp/src/Controller/Team/MiscController.php index 1ad3d4e7a1..d304264ad7 100644 --- a/webapp/src/Controller/Team/MiscController.php +++ b/webapp/src/Controller/Team/MiscController.php @@ -5,13 +5,13 @@ use App\Controller\BaseController; use App\DataTransferObject\SubmissionRestriction; use App\Entity\Clarification; -use App\Entity\Language; use App\Form\Type\PrintType; use App\Service\ConfigurationService; use App\Service\DOMJudgeService; use App\Service\EventLogService; use App\Service\ScoreboardService; use App\Service\SubmissionService; +use App\Utils\Utils; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NoResultException; @@ -92,8 +92,7 @@ public function homeAction(Request $request): Response paginated: false )[0]; - /** @var Clarification[] $clarifications */ - $clarifications = $this->em->createQueryBuilder() + $qb = $this->em->createQueryBuilder() ->from(Clarification::class, 'c') ->leftJoin('c.problem', 'p') ->leftJoin('c.sender', 's') @@ -105,9 +104,12 @@ public function homeAction(Request $request): Response ->setParameter('contest', $contest) ->setParameter('team', $team) ->addOrderBy('c.submittime', 'DESC') - ->addOrderBy('c.clarid', 'DESC') - ->getQuery() - ->getResult(); + ->addOrderBy('c.clarid', 'DESC'); + if (!$this->dj->checkrole('jury') && $contest->getStartTimeObject()->getTimestamp() > time()) { + $qb->andWhere('c.problem IS NULL'); + } + /** @var Clarification[] $clarifications */ + $clarifications = $qb->getQuery()->getResult(); /** @var Clarification[] $clarificationRequests */ $clarificationRequests = $this->em->createQueryBuilder() diff --git a/webapp/templates/team/partials/index_content.html.twig b/webapp/templates/team/partials/index_content.html.twig index 34c7ca453c..06e8061eb8 100644 --- a/webapp/templates/team/partials/index_content.html.twig +++ b/webapp/templates/team/partials/index_content.html.twig @@ -6,6 +6,10 @@

Contest {{ contest | printContestStart }}

+ {% if clarifications is not empty %} +

Clarifications

+ {% include 'team/partials/clarification_list.html.twig' with {clarifications: clarifications} %} + {% endif %} {% else %}