Refactor code for improved readability and consistency; add flash message handling and enhance quiz functionality
Some checks failed
CI / Tests (push) Failing after 9s
CI / Docker Lint (push) Successful in 4s

This commit is contained in:
2025-03-12 23:18:13 +01:00
parent 448daed6ea
commit acf5c06fcc
21 changed files with 309 additions and 80 deletions

View File

@@ -6,6 +6,7 @@ namespace App\Controller;
use App\Entity\Quiz;
use App\Entity\Season;
use App\Repository\CandidateRepository;
use App\Repository\SeasonRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
@@ -13,14 +14,14 @@ use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;
#[AsController]
#[Route('/backoffice', name: 'backoffice_')]
final class BackofficeController extends AbstractController
{
public function __construct(private readonly SeasonRepository $seasonRepository)
{
}
public function __construct(
private readonly SeasonRepository $seasonRepository,
private readonly CandidateRepository $candidateRepository,
) {}
#[Route('/', name: 'index')]
#[Route('/backoffice/', name: 'index')]
public function index(): Response
{
$seasons = $this->seasonRepository->findAll();
@@ -30,7 +31,7 @@ final class BackofficeController extends AbstractController
]);
}
#[Route('/{seasonCode}', name: 'season')]
#[Route('/backoffice/{seasonCode}', name: 'season')]
public function season(Season $season): Response
{
return $this->render('backoffice/season.html.twig', [
@@ -38,12 +39,13 @@ final class BackofficeController extends AbstractController
]);
}
#[Route('/{seasonCode}/{quiz}', name: 'quiz')]
#[Route('/backoffice/{seasonCode}/{quiz}', name: 'quiz')]
public function quiz(Season $season, Quiz $quiz): Response
{
return $this->render('backoffice/quiz.html.twig', [
'season' => $season,
'quiz' => $quiz,
'result' => $this->candidateRepository->getScores($quiz),
]);
}
}