Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions webapp/src/Controller/Jury/AnalysisController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
Expand All @@ -27,11 +28,24 @@ public function __construct(
private readonly EntityManagerInterface $em
) {}

/**
* @return array{error: string}|array{
* contest: mixed,
* problems: mixed,
* teams: mixed,
* submissions: mixed,
* delayed_judgings: array{data: mixed, overflow: int, delay: int},
* misc: mixed,
* filters: array<string, string>,
* view: string
* }|Response
*/
#[Template(template: 'jury/analysis/contest_overview.html.twig')]
#[Route(path: '', name: 'analysis_index')]
public function indexAction(
#[MapQueryParameter]
?string $view = null
): Response {
): array|Response {
$em = $this->em;
$contest = $this->dj->getCurrentContest();

Expand Down Expand Up @@ -66,7 +80,7 @@ public function indexAction(
->orderBy('timediff', 'DESC')
->getQuery()->getResult();

return $this->render('jury/analysis/contest_overview.html.twig', [
return [
'contest' => $contest,
'problems' => $problems,
'teams' => $teams,
Expand All @@ -79,11 +93,15 @@ public function indexAction(
'misc' => $misc,
'filters' => StatisticsService::FILTERS,
'view' => $view,
]);
];
}

/**
* @return array<string, mixed>|Response
*/
#[Template(template: 'jury/analysis/team.html.twig')]
#[Route(path: '/team/{team}', name: 'analysis_team')]
public function teamAction(Team $team): Response
public function teamAction(Team $team): array|Response
{
$contest = $this->dj->getCurrentContest();

Expand All @@ -93,18 +111,20 @@ public function teamAction(Team $team): Response
]);
}

return $this->render('jury/analysis/team.html.twig',
$this->stats->getTeamStats($contest, $team)
);
return $this->stats->getTeamStats($contest, $team);
}

/**
* @return array<string, mixed>|Response
*/
#[Template(template: 'jury/analysis/problem.html.twig')]
#[Route(path: '/problem/{probid}', name: 'analysis_problem')]
public function problemAction(
#[MapEntity(id: 'probid')]
Problem $problem,
#[MapQueryParameter]
?string $view = null
): Response {
): array|Response {
$contest = $this->dj->getCurrentContest();

if ($contest === null) {
Expand All @@ -116,16 +136,18 @@ public function problemAction(
$filterKeys = array_keys(StatisticsService::FILTERS);
$view = $view ?: reset($filterKeys);

return $this->render('jury/analysis/problem.html.twig',
$this->stats->getProblemStats($contest, $problem, $view)
);
return $this->stats->getProblemStats($contest, $problem, $view);
}

/**
* @return array<string, mixed>|Response
*/
#[Template(template: 'jury/analysis/languages.html.twig')]
#[Route(path: '/languages', name: 'analysis_languages')]
public function languagesAction(
#[MapQueryParameter]
?string $view = null
): Response {
): array|Response {
$contest = $this->dj->getCurrentContest();

if ($contest === null) {
Expand All @@ -137,8 +159,6 @@ public function languagesAction(
$filterKeys = array_keys(StatisticsService::FILTERS);
$view = $view ?: reset($filterKeys);

return $this->render('jury/analysis/languages.html.twig',
$this->stats->getLanguagesStats($contest, $view)
);
return $this->stats->getLanguagesStats($contest, $view);
}
}
21 changes: 16 additions & 5 deletions webapp/src/Controller/Jury/AuditLogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use App\Utils\Utils;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Pagination\Paginator;
use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
Expand All @@ -28,13 +28,24 @@ public function __construct(
protected readonly EventLogService $eventLogService
) {}

/**
* @return array{
* auditlog: list<array{data: array<string, mixed>, actions: list<mixed>}>,
* table_fields: array<string, array{title: string, sort: bool}>,
* table_options: array{ordering: string, searching: string, full_clickable: bool},
* maxPages: int,
* thisPage: int,
* showAll: bool
* }
*/
#[Route(path: '', name: 'jury_auditlog')]
#[Template(template: 'jury/auditlog.html.twig')]
public function indexAction(
#[MapQueryParameter]
bool $showAll = false,
#[MapQueryParameter]
int $page = 1,
): Response {
): array {
$timeFormat = (string)$this->config->get('time_format');

$limit = 1000;
Expand Down Expand Up @@ -96,17 +107,17 @@ public function indexAction(
'what' => ['title' => 'action', 'sort' => false],
];

$maxPages = ceil($paginator->count() / $limit);
$maxPages = (int)ceil($paginator->count() / $limit);
$thisPage = $page;

return $this->render('jury/auditlog.html.twig', [
return [
'auditlog' => $auditlog_table,
'table_fields' => $table_fields,
'table_options' => ['ordering' => 'false', 'searching' => 'false', 'full_clickable' => false],
'maxPages' => $maxPages,
'thisPage' => $thisPage,
'showAll' => $showAll,
]);
];
}

private function generateDatatypeUrl(string $type, int|string|null $id): ?string
Expand Down
24 changes: 19 additions & 5 deletions webapp/src/Controller/Jury/BalloonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use App\Service\EventLogService;
use App\Utils\Utils;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

Expand Down Expand Up @@ -49,12 +49,26 @@ private function areDefault(array $filters, array $defaultCategories): bool {
return false;
}

/**
* @return array{}|array{
* refresh: array{after: int, url: string, ajax: bool},
* isfrozen: bool,
* hasFilters: bool,
* filteredAffiliations: list<TeamAffiliation>,
* filteredLocations: list<Team>,
* filteredCategories: list<TeamCategory>,
* availableCategories: list<TeamCategory>,
* defaultCategories: list<int>,
* balloons: list<mixed>
* }
*/
#[Route(path: '', name: 'jury_balloons')]
public function indexAction(BalloonService $balloonService): Response
#[Template(template: 'jury/balloons.html.twig')]
public function indexAction(BalloonService $balloonService): array
{
$contest = $this->dj->getCurrentContest();
if (is_null($contest)) {
return $this->render('jury/balloons.html.twig');
return [];
}

$balloons_table = $balloonService->collectBalloonTable($contest);
Expand Down Expand Up @@ -151,7 +165,7 @@ public function indexAction(BalloonService $balloonService): Response
->getArrayResult();
$defaultCategories = array_column($defaultCategories, "categoryid");

return $this->render('jury/balloons.html.twig', [
return [
'refresh' => [
'after' => 60,
'url' => $this->generateUrl('jury_balloons'),
Expand All @@ -165,7 +179,7 @@ public function indexAction(BalloonService $balloonService): Response
'availableCategories' => $availableCategories,
'defaultCategories' => $defaultCategories,
'balloons' => $balloons_table
]);
];
}

#[Route(path: '/{balloonId}/done', name: 'jury_balloons_setdone')]
Expand Down
43 changes: 35 additions & 8 deletions webapp/src/Controller/Jury/ClarificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
use App\Utils\Utils;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Join;
use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
Expand All @@ -34,13 +37,25 @@ public function __construct(
protected readonly EventLogService $eventLogService
) {}

/**
* @return array{
* newClarifications: list<Clarification>,
* oldClarifications: list<Clarification>,
* generalClarifications: list<Clarification>,
* queues: array<string, string>,
* currentQueue: string,
* currentFilter: string|null,
* categories: array<string, string>
* }
*/
#[Route(path: '', name: 'jury_clarifications')]
#[Template(template: 'jury/clarifications.html.twig')]
public function indexAction(
#[MapQueryParameter(name: 'filter')]
?string $currentFilter = null,
#[MapQueryParameter(name: 'queue')]
string $currentQueue = 'all',
): Response {
): array {
$categories = $this->config->get('clar_categories');
if ($contest = $this->dj->getCurrentContest()) {
$contestIds = [$contest->getCid()];
Expand Down Expand Up @@ -102,19 +117,27 @@ public function indexAction(

$queues = $this->config->get('clar_queues');

return $this->render('jury/clarifications.html.twig', [
return [
'newClarifications' => $newClarifications,
'oldClarifications' => $oldClarifications,
'generalClarifications' => $generalClarifications,
'queues' => $queues,
'currentQueue' => $currentQueue,
'currentFilter' => $currentFilter,
'categories' => $categories,
]);
];
}

/**
* @return array{
* list: list<array<string, mixed>>,
* queues: array<string, string>,
* answers: list<string>, jurymember: string|null
* }|RedirectResponse
*/
#[Route(path: '/{id<\d+>}', name: 'jury_clarification')]
public function viewAction(Request $request, int $id): Response
#[Template(template: 'jury/clarification.html.twig')]
public function viewAction(Request $request, int $id): array|RedirectResponse
{
$clarification = $this->em->getRepository(Clarification::class)->find($id);
if (!$clarification) {
Expand Down Expand Up @@ -230,15 +253,19 @@ public function viewAction(Request $request, int $id): Response
->getQuery()
->getSingleResult()['jury_member'];

return $this->render('jury/clarification.html.twig', $parameters);
return $parameters;
}

/**
* @return array{form: FormView}|RedirectResponse
*/
#[Route(path: '/send', name: 'jury_clarification_new')]
#[Template(template: 'jury/clarification_new.html.twig')]
public function composeClarificationAction(
Request $request,
#[MapQueryParameter]
?string $teamto = null,
): Response {
): array|RedirectResponse {
$formData = ['recipient' => JuryClarificationType::RECIPIENT_MUST_SELECT];

if ($teamto !== null) {
Expand All @@ -253,7 +280,7 @@ public function composeClarificationAction(
return $this->processSubmittedClarification($form);
}

return $this->render('jury/clarification_new.html.twig', ['form' => $form->createView()]);
return ['form' => $form->createView()];
}

#[Route(path: '/{clarId<\d+>}/claim', name: 'jury_clarification_claim')]
Expand Down Expand Up @@ -354,7 +381,7 @@ public function changeQueueAction(Request $request, int $clarId): Response
protected function processSubmittedClarification(
FormInterface $form,
?Clarification $inReplTo = null
): Response {
): RedirectResponse {
$formData = $form->getData();
$clarification = new Clarification();
$clarification->setInReplyTo($inReplTo);
Expand Down
Loading
Loading