wip 12-03-2025
Some checks failed
CI / Tests (push) Failing after 11s
CI / Docker Lint (push) Successful in 3s

This commit is contained in:
2025-03-12 09:28:36 +01:00
parent f7b4b98da4
commit 448daed6ea
21 changed files with 523 additions and 103 deletions

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Quiz;
use App\Entity\Season;
use App\Repository\SeasonRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
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)
{
}
#[Route('/', name: 'index')]
public function index(): Response
{
$seasons = $this->seasonRepository->findAll();
return $this->render('backoffice/index.html.twig', [
'seasons' => $seasons,
]);
}
#[Route('/{seasonCode}', name: 'season')]
public function season(Season $season): Response
{
return $this->render('backoffice/season.html.twig', [
'season' => $season,
]);
}
#[Route('/{seasonCode}/{quiz}', name: 'quiz')]
public function quiz(Season $season, Quiz $quiz): Response
{
return $this->render('backoffice/quiz.html.twig', [
'season' => $season,
'quiz' => $quiz,
]);
}
}

View File

@@ -25,7 +25,7 @@ use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;
#[AsController]
class QuizController extends AbstractController
final class QuizController extends AbstractController
{
public const string SEASON_CODE_REGEX = '[A-Za-z\d]{5}';
private const string CANDIDATE_HASH_REGEX = '[\w\-=]+';
@@ -102,7 +102,8 @@ class QuizController extends AbstractController
$givenAnswer = (new GivenAnswer())
->setCandidate($candidate)
->setAnswer($answer);
->setAnswer($answer)
->setQuiz($answer->getQuestion()->getQuiz());
$givenAnswerRepository->save($givenAnswer);
}

View File

@@ -34,7 +34,7 @@ class GivenAnswer
#[ORM\JoinColumn(nullable: true)]
private ?Answer $answer = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: false)]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: false)]
private \DateTimeInterface $created;
public function getId(): ?Uuid
@@ -78,7 +78,7 @@ class GivenAnswer
return $this;
}
public function getCreated(): ?\DateTimeInterface
public function getCreated(): \DateTimeInterface
{
return $this->created;
}

View File

@@ -36,6 +36,9 @@ class Quiz
#[ORM\OneToMany(targetEntity: Correction::class, mappedBy: 'quiz', orphanRemoval: true)]
private Collection $corrections;
#[ORM\Column(nullable: true)]
private ?int $dropouts = null;
public function __construct()
{
$this->questions = new ArrayCollection();
@@ -102,4 +105,16 @@ class Quiz
return $this;
}
public function getDropouts(): ?int
{
return $this->dropouts;
}
public function setDropouts(?int $dropouts): static
{
$this->dropouts = $dropouts;
return $this;
}
}

View File

@@ -17,4 +17,8 @@ class QuizRepository extends ServiceEntityRepository
{
parent::__construct($registry, Quiz::class);
}
public function quizReault(Quiz $quiz): array
{
}
}