Add quiz management features and improve UI

This commit is contained in:
2025-04-23 23:21:55 +02:00
parent 4e22feb256
commit 4712c01688
13 changed files with 646 additions and 262 deletions

View File

@@ -10,11 +10,13 @@ use App\Entity\User;
use App\Repository\CandidateRepository;
use App\Repository\SeasonRepository;
use App\Security\Voter\SeasonVoter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;
#[AsController]
#[IsGranted('ROLE_USER')]
@@ -59,4 +61,20 @@ final class BackofficeController extends AbstractController
'result' => $this->candidateRepository->getScores($quiz),
]);
}
#[Route('/backoffice/{seasonCode}/{quiz}/enable', name: 'app_backoffice_enable')]
#[IsGranted(SeasonVoter::EDIT, subject: 'season')]
public function enableQuiz(Season $season, Quiz $quiz, EntityManagerInterface $em): Response
{
$season->setActiveQuiz($quiz);
$em->flush();
return $this->redirectToRoute('app_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
}
#[Route('/backoffice/{seasonCode}/{quiz}/yaml')]
public function testRoute(Season $season, Quiz $quiz, SerializerInterface $serializer): Response
{
return new Response($serializer->serialize(\App\Resource\Quiz::fromEntity($quiz)->questions, 'yaml', ['yaml_inline' => 100, 'yaml_flags' => 0]), headers: ['Content-Type' => 'text/yaml']);
}
}