Skip to content

Commit

Permalink
Show unused executables as disabled
Browse files Browse the repository at this point in the history
This needs to be further extended as debug and default compare scripts
are now shown as unused.
  • Loading branch information
vmcj committed Sep 21, 2023
1 parent bf1bd43 commit 3ed7761
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
37 changes: 31 additions & 6 deletions webapp/src/Controller/Jury/ExecutableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Service\EventLogService;
use App\Utils\Utils;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Join;
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Form\Exception\InvalidArgumentException;
Expand Down Expand Up @@ -39,9 +40,22 @@ public function __construct(
protected readonly EventLogService $eventLogService
) {}

private function checkDisabled(Executable $e): bool
{
if (in_array($e->getExecid(), ['compare', 'run', 'full_debug'])) {
return true;
}
if (count($e->getProblemsCompare()) || count($e->getProblemsRun())) {
return true;
}
return false;
}

#[Route(path: '', name: 'jury_executables')]
public function indexAction(Request $request): Response
{
$executables_tables_enabled = [];
$executables_tables_disabled = [];
$data = [];
$form = $this->createForm(ExecutableUploadType::class, $data);
$form->handleRequest($request);
Expand Down Expand Up @@ -96,14 +110,25 @@ public function indexAction(Request $request): Response
'link' => $this->generateUrl('jury_executable_download', ['execId' => $e->getExecid()])
];

$executables_table[] = [
'data' => $execdata,
'actions' => $execactions,
'link' => $this->generateUrl('jury_executable', ['execId' => $e->getExecid()]),
];
if ($this->checkDisabled($e)) {
$executables_tables_enabled[] = [
'data' => $execdata,
'actions' => $execactions,
'link' => $this->generateUrl('jury_executable', ['execId' => $e->getExecid()]),
];
} else {
$executables_tables_disabled[] = [
'data' => $execdata,
'actions' => $execactions,
'link' => $this->generateUrl('jury_executable', ['execId' => $e->getExecid()]),
'cssclass' => 'disabled',
];
}
}

return $this->render('jury/executables.html.twig', [
'executables' => $executables_table,
'executables_enabled' => $executables_tables_enabled,
'executables_disabled' => $executables_tables_disabled,
'table_fields' => $table_fields,
'form' => $form,
]);
Expand Down
6 changes: 4 additions & 2 deletions webapp/templates/jury/executables.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

{% block content %}

<h1>Executables</h1>
<h1>Enabled executables</h1>
{{ macros.table(executables_enabled, table_fields, {'ordering': 'false'}) }}

{{ macros.table(executables, table_fields, {'ordering': 'false'}) }}
<h1>Disabled executables</h1>
{{ macros.table(executables_disabled, table_fields, {'ordering': 'false'}) }}

{% if is_granted('ROLE_ADMIN') %}
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ExecutableControllerTest extends JuryControllerTestCase
protected static string $deleteEntityIdentifier = 'description';
protected static string $getIDFunc = 'getExecid';
protected static string $className = Executable::class;
protected static array $DOM_elements = ['h1' => ['Executables']];
protected static array $DOM_elements = ['h1' => ['Enabled executables', 'Disabled executables']];
protected static string $addForm = 'executable_upload[';
protected static array $addEntitiesShown = ['type'];
protected static array $addEntities = [];
Expand Down

0 comments on commit 3ed7761

Please sign in to comment.