mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-05 20:44:19 +01:00
Refactor entities and codebase for native property usage
- Replaced getters/setters with direct property access across entities and repositories. - Added and configured `martin-georgiev/postgresql-for-doctrine` for PostgreSQL enhancements. - Updated Doctrine configuration with types, mappings, and JSONB query functions. - Removed unused `EliminationService` and related YAML configurations.
This commit is contained in:
@@ -26,12 +26,12 @@ readonly class AddSettingsCommand
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
foreach ($this->seasonRepository->findAll() as $season) {
|
||||
if (null !== $season->getSettings()) {
|
||||
if (null !== $season->settings) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$io->text('Adding settings to season : '.$season->getSeasonCode());
|
||||
$season->setSettings(new SeasonSettings());
|
||||
$io->text('Adding settings to season : '.$season->seasonCode);
|
||||
$season->settings = new SeasonSettings();
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
@@ -61,7 +61,7 @@ final class BackofficeController extends AbstractController
|
||||
$em->persist($season);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]);
|
||||
}
|
||||
|
||||
return $this->render('backoffice/season_add.html.twig', ['form' => $form]);
|
||||
|
||||
@@ -26,7 +26,7 @@ final class PrepareEliminationController extends AbstractController
|
||||
{
|
||||
$elimination = $eliminationFactory->createEliminationFromQuiz($quiz);
|
||||
|
||||
return $this->redirectToRoute('tvdt_prepare_elimination_view', ['elimination' => $elimination->getId()]);
|
||||
return $this->redirectToRoute('tvdt_prepare_elimination_view', ['elimination' => $elimination->id]);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
@@ -41,7 +41,7 @@ final class PrepareEliminationController extends AbstractController
|
||||
$em->flush();
|
||||
|
||||
if ($request->request->getBoolean('start')) {
|
||||
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->getId()]);
|
||||
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->id]);
|
||||
}
|
||||
|
||||
$this->addFlash('success', 'Elimination updated');
|
||||
|
||||
@@ -56,14 +56,14 @@ class QuizController extends AbstractController
|
||||
)]
|
||||
public function enableQuiz(Season $season, ?Quiz $quiz, EntityManagerInterface $em): RedirectResponse
|
||||
{
|
||||
$season->setActiveQuiz($quiz);
|
||||
$season->activeQuiz = $quiz;
|
||||
$em->flush();
|
||||
|
||||
if ($quiz instanceof Quiz) {
|
||||
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $season->getSeasonCode(), 'quiz' => $quiz->getId()]);
|
||||
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $season->seasonCode, 'quiz' => $quiz->id]);
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]);
|
||||
}
|
||||
|
||||
#[IsGranted(SeasonVoter::EDIT, subject: 'quiz')]
|
||||
@@ -81,7 +81,7 @@ class QuizController extends AbstractController
|
||||
$this->addFlash('error', $this->translator->trans('Error clearing quiz'));
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->getSeason()->getSeasonCode(), 'quiz' => $quiz->getId()]);
|
||||
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->season->seasonCode, 'quiz' => $quiz->id]);
|
||||
}
|
||||
|
||||
#[IsGranted(SeasonVoter::DELETE, subject: 'quiz')]
|
||||
@@ -96,7 +96,7 @@ class QuizController extends AbstractController
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('Quiz deleted'));
|
||||
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $quiz->getSeason()->getSeasonCode()]);
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $quiz->season->seasonCode]);
|
||||
}
|
||||
|
||||
#[IsGranted(SeasonVoter::EDIT, subject: 'quiz')]
|
||||
@@ -115,6 +115,6 @@ class QuizController extends AbstractController
|
||||
|
||||
$quizCandidateRepository->setCorrectionsForCandidate($quiz, $candidate, $corrections);
|
||||
|
||||
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->getSeason()->getSeasonCode(), 'quiz' => $quiz->getId()]);
|
||||
return $this->redirectToRoute('tvdt_backoffice_quiz', ['seasonCode' => $quiz->season->seasonCode, 'quiz' => $quiz->id]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class SeasonController extends AbstractController
|
||||
)]
|
||||
public function index(Season $season, Request $request): Response
|
||||
{
|
||||
$form = $this->createForm(SettingsForm::class, $season->getSettings());
|
||||
$form = $this->createForm(SettingsForm::class, $season->settings);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
@@ -74,7 +74,7 @@ class SeasonController extends AbstractController
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]);
|
||||
}
|
||||
|
||||
return $this->render('backoffice/season_add_candidates.html.twig', ['form' => $form]);
|
||||
@@ -100,13 +100,13 @@ class SeasonController extends AbstractController
|
||||
|
||||
$quizSpreadsheet->xlsxToQuiz($quiz, $sheet);
|
||||
|
||||
$quiz->setSeason($season);
|
||||
$quiz->season = $season;
|
||||
$this->em->persist($quiz);
|
||||
$this->em->flush();
|
||||
|
||||
$this->addFlash(FlashType::Success, $this->translator->trans('Quiz Added!'));
|
||||
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->getSeasonCode()]);
|
||||
return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]);
|
||||
}
|
||||
|
||||
return $this->render('/backoffice/quiz_add.html.twig', ['form' => $form, 'season' => $season]);
|
||||
|
||||
@@ -39,7 +39,7 @@ final class EliminationController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$name = $form->get('name')->getData();
|
||||
|
||||
return $this->redirectToRoute('tvdt_elimination_candidate', ['elimination' => $elimination->getId(), 'candidateHash' => Base64::base64UrlEncode($name)]);
|
||||
return $this->redirectToRoute('tvdt_elimination_candidate', ['elimination' => $elimination->id, 'candidateHash' => Base64::base64UrlEncode($name)]);
|
||||
}
|
||||
|
||||
return $this->render('quiz/elimination/index.html.twig', [
|
||||
@@ -52,21 +52,21 @@ final class EliminationController extends AbstractController
|
||||
#[Route('/elimination/{elimination}/{candidateHash}', name: 'tvdt_elimination_candidate', requirements: ['elimination' => Requirement::UUID, 'candidateHash' => self::CANDIDATE_HASH_REGEX])]
|
||||
public function candidateScreen(Elimination $elimination, string $candidateHash, CandidateRepository $candidateRepository): Response
|
||||
{
|
||||
$candidate = $candidateRepository->getCandidateByHash($elimination->getQuiz()->getSeason(), $candidateHash);
|
||||
$candidate = $candidateRepository->getCandidateByHash($elimination->quiz->season, $candidateHash);
|
||||
if (!$candidate instanceof Candidate) {
|
||||
$this->addFlash(FlashType::Warning,
|
||||
t('Cound not find candidate with name %name%', ['%name%' => Base64::base64UrlDecode($candidateHash)])->trans($this->translator),
|
||||
);
|
||||
|
||||
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->getId()]);
|
||||
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->id]);
|
||||
}
|
||||
|
||||
$screenColour = $elimination->getScreenColour($candidate->getName());
|
||||
$screenColour = $elimination->getScreenColour($candidate->name);
|
||||
|
||||
if (null === $screenColour) {
|
||||
$this->addFlash(FlashType::Warning, $this->translator->trans('Cound not find candidate with name %name% in elimination.', ['%name%' => $candidate->getName()]));
|
||||
$this->addFlash(FlashType::Warning, $this->translator->trans('Cound not find candidate with name %name% in elimination.', ['%name%' => $candidate->name]));
|
||||
|
||||
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->getId()]);
|
||||
return $this->redirectToRoute('tvdt_elimination', ['elimination' => $elimination->id]);
|
||||
}
|
||||
|
||||
return $this->render('quiz/elimination/candidate.html.twig', [
|
||||
|
||||
@@ -65,7 +65,7 @@ final class QuizController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$name = $form->get('name')->getData();
|
||||
|
||||
return $this->redirectToRoute('tvdt_quiz_quiz_page', ['seasonCode' => $season->getSeasonCode(), 'nameHash' => Base64::base64UrlEncode($name)]);
|
||||
return $this->redirectToRoute('tvdt_quiz_quiz_page', ['seasonCode' => $season->seasonCode, 'nameHash' => Base64::base64UrlEncode($name)]);
|
||||
}
|
||||
|
||||
return $this->render('quiz/enter_name.twig', ['season' => $season, 'form' => $form]);
|
||||
@@ -91,15 +91,15 @@ final class QuizController extends AbstractController
|
||||
if (!$candidate instanceof Candidate) {
|
||||
$this->addFlash(FlashType::Danger, $this->translator->trans('Candidate not found'));
|
||||
|
||||
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->getSeasonCode()]);
|
||||
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]);
|
||||
}
|
||||
|
||||
$quiz = $season->getActiveQuiz();
|
||||
$quiz = $season->activeQuiz;
|
||||
|
||||
if (!$quiz instanceof Quiz) {
|
||||
$this->addFlash(FlashType::Warning, $this->translator->trans('There is no active quiz'));
|
||||
|
||||
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->getSeasonCode()]);
|
||||
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]);
|
||||
}
|
||||
|
||||
if ('POST' === $request->getMethod()) {
|
||||
@@ -109,10 +109,10 @@ final class QuizController extends AbstractController
|
||||
throw new BadRequestHttpException('Invalid Answer ID');
|
||||
}
|
||||
|
||||
$givenAnswer = new GivenAnswer($candidate, $answer->getQuestion()->getQuiz(), $answer);
|
||||
$givenAnswer = new GivenAnswer($candidate, $answer->question->quiz, $answer);
|
||||
$givenAnswerRepository->save($givenAnswer);
|
||||
|
||||
return $this->redirectToRoute('tvdt_quiz_quiz_page', ['seasonCode' => $season->getSeasonCode(), 'nameHash' => $nameHash]);
|
||||
return $this->redirectToRoute('tvdt_quiz_quiz_page', ['seasonCode' => $season->seasonCode, 'nameHash' => $nameHash]);
|
||||
}
|
||||
|
||||
$question = $questionRepository->findNextQuestionForCandidate($candidate);
|
||||
@@ -120,7 +120,7 @@ final class QuizController extends AbstractController
|
||||
if (!$question instanceof Question) {
|
||||
$this->addFlash(FlashType::Success, $this->translator->trans('Quiz completed'));
|
||||
|
||||
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->getSeasonCode()]);
|
||||
return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]);
|
||||
}
|
||||
|
||||
$quizCandidateRepository->createIfNotExist($quiz, $candidate);
|
||||
|
||||
@@ -41,7 +41,7 @@ final class RegistrationController extends AbstractController
|
||||
/** @var string $plainPassword */
|
||||
$plainPassword = $form->get('plainPassword')->getData();
|
||||
|
||||
$user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword));
|
||||
$user->password = $userPasswordHasher->hashPassword($user, $plainPassword);
|
||||
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
@@ -50,7 +50,7 @@ final class RegistrationController extends AbstractController
|
||||
// generate a signed url and email it to the user
|
||||
$this->emailVerifier->sendEmailConfirmation('tvdt_verify_email', $user,
|
||||
new TemplatedEmail()
|
||||
->to((string) $user->getEmail())
|
||||
->to($user->email)
|
||||
->subject($this->translator->trans('Please Confirm your Email'))
|
||||
->htmlTemplate('backoffice/registration/confirmation_email.html.twig'),
|
||||
);
|
||||
|
||||
@@ -19,8 +19,9 @@ class KrtekFixtures extends Fixture
|
||||
$season = new Season();
|
||||
$manager->persist($season);
|
||||
|
||||
$season->setName('Krtek Weekend')
|
||||
->setSeasonCode('krtek')
|
||||
$season->name = 'Krtek Weekend';
|
||||
$season->seasonCode = 'krtek';
|
||||
$season
|
||||
->addCandidate(new Candidate('Claudia'))
|
||||
->addCandidate(new Candidate('Eelco'))
|
||||
->addCandidate(new Candidate('Elise'))
|
||||
@@ -35,338 +36,341 @@ class KrtekFixtures extends Fixture
|
||||
->addCandidate(new Candidate('Robbert'))
|
||||
->addCandidate(new Candidate('Tom'));
|
||||
$quiz1 = $this->createQuiz1($season);
|
||||
$season->addQuiz($quiz1)
|
||||
->setActiveQuiz($quiz1)
|
||||
->addQuiz($this->createQuiz2($season));
|
||||
$season->addQuiz($quiz1);
|
||||
$season->activeQuiz = $quiz1;
|
||||
$season->addQuiz($this->createQuiz2($season));
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
private function createQuiz1(Season $season): Quiz
|
||||
{
|
||||
return new Quiz()
|
||||
->setName('Quiz 1')
|
||||
->setSeason($season)
|
||||
$quiz = new Quiz();
|
||||
$quiz->name = 'Quiz 1';
|
||||
$quiz->season = $season;
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Is de Krtek een man of een vrouw?')
|
||||
->addAnswer(new Answer('Vrouw', true))
|
||||
->addAnswer(new Answer('Man'))
|
||||
->setOrdering(1),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Is de Krtek een man of een vrouw?';
|
||||
$q->addAnswer(new Answer('Vrouw', true))
|
||||
->addAnswer(new Answer('Man'));
|
||||
$q->ordering = 1;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Hoeveel broers heeft de Krtek?')
|
||||
->addAnswer(new Answer('Geen', true))
|
||||
->addAnswer(new Answer('1'))
|
||||
->addAnswer(new Answer('2'))
|
||||
->setOrdering(2),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Hoeveel broers heeft de Krtek?';
|
||||
$q->addAnswer(new Answer('Geen', true))
|
||||
->addAnswer(new Answer('1'))
|
||||
->addAnswer(new Answer('2'));
|
||||
$q->ordering = 2;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Wat is de lievelingsfeestdag van de Krtek?')
|
||||
->addAnswer(new Answer('Geen'))
|
||||
->addAnswer(new Answer('Diens eigen verjaardag'))
|
||||
->addAnswer(new Answer('Koningsdag'))
|
||||
->addAnswer(new Answer('Kerst', true))
|
||||
->addAnswer(new Answer('Oud en Nieuw'))
|
||||
->setOrdering(3),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Wat is de lievelingsfeestdag van de Krtek?';
|
||||
$q->addAnswer(new Answer('Geen'))
|
||||
->addAnswer(new Answer('Diens eigen verjaardag'))
|
||||
->addAnswer(new Answer('Koningsdag'))
|
||||
->addAnswer(new Answer('Kerst', true))
|
||||
->addAnswer(new Answer('Oud en Nieuw'));
|
||||
$q->ordering = 3;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Hoe kwam de Krtek naar Kersteren vandaag?')
|
||||
->addAnswer(new Answer('Met het OV', true))
|
||||
->addAnswer(new Answer('Met de auto'))
|
||||
->setOrdering(4),
|
||||
)
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Met wie keek de Krtek video bij binnenkomst?')
|
||||
->addAnswer(new Answer('Claudia'))
|
||||
->addAnswer(new Answer('Eelco'))
|
||||
->addAnswer(new Answer('Elise'))
|
||||
->addAnswer(new Answer('Gert-Jan'))
|
||||
->addAnswer(new Answer('Iris'))
|
||||
->addAnswer(new Answer('Jari'))
|
||||
->addAnswer(new Answer('Lara'))
|
||||
->addAnswer(new Answer('Lotte'))
|
||||
->addAnswer(new Answer('Myrthe'))
|
||||
->addAnswer(new Answer('Philine'))
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom', true))
|
||||
->setOrdering(5),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Hoe kwam de Krtek naar Kersteren vandaag?';
|
||||
$q->addAnswer(new Answer('Met het OV', true))
|
||||
->addAnswer(new Answer('Met de auto'));
|
||||
$q->ordering = 4;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Welk advies zou de Krtek zichzelf als kind geven?')
|
||||
->addAnswer(new Answer('Geef je vader een knuffel.'))
|
||||
->addAnswer(new Answer('Trek je wat minder aan van anderen.'))
|
||||
->addAnswer(new Answer('Luister meer naar je eigen gevoel in plaats van naar wat anderen vinden.'))
|
||||
->addAnswer(new Answer('Stel niet alles tot het laatste moment uit.'))
|
||||
->addAnswer(new Answer('Altijd doorgaan.'))
|
||||
->addAnswer(new Answer('Probeer ook eens buiten de lijntjes te kleuren', true))
|
||||
->addAnswer(new Answer('Ga als je groot bent op groepsreis! '))
|
||||
->addAnswer(new Answer('Trek minder aan van de mening van anderen, het is oké om anders te zijn.'))
|
||||
->setOrdering(6),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Met wie keek de Krtek video bij binnenkomst?';
|
||||
$q->addAnswer(new Answer('Claudia'))
|
||||
->addAnswer(new Answer('Eelco'))
|
||||
->addAnswer(new Answer('Elise'))
|
||||
->addAnswer(new Answer('Gert-Jan'))
|
||||
->addAnswer(new Answer('Iris'))
|
||||
->addAnswer(new Answer('Jari'))
|
||||
->addAnswer(new Answer('Lara'))
|
||||
->addAnswer(new Answer('Lotte'))
|
||||
->addAnswer(new Answer('Myrthe'))
|
||||
->addAnswer(new Answer('Philine'))
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom', true));
|
||||
$q->ordering = 5;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Wat voor soort schoenen droeg de Krtek bij het diner?')
|
||||
->addAnswer(new Answer('Sneakers'))
|
||||
->addAnswer(new Answer('Wandel-/bergschoenen', true))
|
||||
->addAnswer(new Answer('Lederen schoenen'))
|
||||
->addAnswer(new Answer('Pantoffels'))
|
||||
->addAnswer(new Answer('Hakken'))
|
||||
->addAnswer(new Answer('Geen schoenen, alleen sokken'))
|
||||
->setOrdering(7),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Welk advies zou de Krtek zichzelf als kind geven?';
|
||||
$q->addAnswer(new Answer('Geef je vader een knuffel.'))
|
||||
->addAnswer(new Answer('Trek je wat minder aan van anderen.'))
|
||||
->addAnswer(new Answer('Luister meer naar je eigen gevoel in plaats van naar wat anderen vinden.'))
|
||||
->addAnswer(new Answer('Stel niet alles tot het laatste moment uit.'))
|
||||
->addAnswer(new Answer('Altijd doorgaan.'))
|
||||
->addAnswer(new Answer('Probeer ook eens buiten de lijntjes te kleuren', true))
|
||||
->addAnswer(new Answer('Ga als je groot bent op groepsreis! '))
|
||||
->addAnswer(new Answer('Trek minder aan van de mening van anderen, het is oké om anders te zijn.'));
|
||||
$q->ordering = 6;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Met welk vervoersmiddel reist de Krtek het liefste?')
|
||||
->addAnswer(new Answer('Fiets', true))
|
||||
->addAnswer(new Answer('Auto'))
|
||||
->addAnswer(new Answer('Trein'))
|
||||
->setOrdering(8),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Wat voor soort schoenen droeg de Krtek bij het diner?';
|
||||
$q->addAnswer(new Answer('Sneakers'))
|
||||
->addAnswer(new Answer('Wandel-/bergschoenen', true))
|
||||
->addAnswer(new Answer('Lederen schoenen'))
|
||||
->addAnswer(new Answer('Pantoffels'))
|
||||
->addAnswer(new Answer('Hakken'))
|
||||
->addAnswer(new Answer('Geen schoenen, alleen sokken'));
|
||||
$q->ordering = 7;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Heeft de Krtek een eigen auto?')
|
||||
->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true))
|
||||
->setOrdering(9),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Met welk vervoersmiddel reist de Krtek het liefste?';
|
||||
$q->addAnswer(new Answer('Fiets', true))
|
||||
->addAnswer(new Answer('Auto'))
|
||||
->addAnswer(new Answer('Trein'));
|
||||
$q->ordering = 8;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Van wie is de quote die de Krtek gepakt heeft')
|
||||
->addAnswer(new Answer('Karen'))
|
||||
->addAnswer(new Answer('Gilles de Coster'))
|
||||
->addAnswer(new Answer('Kees Tol'))
|
||||
->addAnswer(new Answer('Harry en John'))
|
||||
->addAnswer(new Answer('Georgina Verbaan'))
|
||||
->addAnswer(new Answer('Marc-Marie Huijbregts'))
|
||||
->addAnswer(new Answer('Fresia Cousiño Arias, Rik van de Westelaken'))
|
||||
->addAnswer(new Answer('Ellie Lust'))
|
||||
->addAnswer(new Answer('Bouba'))
|
||||
->addAnswer(new Answer('Jan Versteegh'))
|
||||
->addAnswer(new Answer('Dick Jol'))
|
||||
->addAnswer(new Answer('Karin de Groot'))
|
||||
->addAnswer(new Answer('Pieter'))
|
||||
->addAnswer(new Answer('Renée Fokker'))
|
||||
->addAnswer(new Answer('Sam, Davy', true))
|
||||
->setOrdering(10),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Heeft de Krtek een eigen auto?';
|
||||
$q->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true));
|
||||
$q->ordering = 9;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Zou de Krtek molboekjes, jokers, vrijstellingen of topito’s uit iemands rugzak stelen om te kunnen winnen?')
|
||||
->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true))
|
||||
->setOrdering(11),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Van wie is de quote die de Krtek gepakt heeft';
|
||||
$q->addAnswer(new Answer('Karen'))
|
||||
->addAnswer(new Answer('Gilles de Coster'))
|
||||
->addAnswer(new Answer('Kees Tol'))
|
||||
->addAnswer(new Answer('Harry en John'))
|
||||
->addAnswer(new Answer('Georgina Verbaan'))
|
||||
->addAnswer(new Answer('Marc-Marie Huijbregts'))
|
||||
->addAnswer(new Answer('Fresia Cousiño Arias, Rik van de Westelaken'))
|
||||
->addAnswer(new Answer('Ellie Lust'))
|
||||
->addAnswer(new Answer('Bouba'))
|
||||
->addAnswer(new Answer('Jan Versteegh'))
|
||||
->addAnswer(new Answer('Dick Jol'))
|
||||
->addAnswer(new Answer('Karin de Groot'))
|
||||
->addAnswer(new Answer('Pieter'))
|
||||
->addAnswer(new Answer('Renée Fokker'))
|
||||
->addAnswer(new Answer('Sam, Davy', true));
|
||||
$q->ordering = 10;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('In wat voor bed slaapt de Krtek dit weekend?')
|
||||
->addAnswer(new Answer('Éénpersoons, losstaand bed'))
|
||||
->addAnswer(new Answer('Éénpersoonsbed, tegen een ander bed aan', true))
|
||||
->addAnswer(new Answer('Tweepersoons bed'))
|
||||
->setOrdering(12),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Zou de Krtek molboekjes, jokers, vrijstellingen of topito’s uit iemands rugzak stelen om te kunnen winnen?';
|
||||
$q->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true));
|
||||
$q->ordering = 11;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Hoeveel jaar heeft de Krtek gedaan over de middelbare school?')
|
||||
->addAnswer(new Answer('5'))
|
||||
->addAnswer(new Answer('6', true))
|
||||
->addAnswer(new Answer('7'))
|
||||
->addAnswer(new Answer('8'))
|
||||
->setOrdering(13),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'In wat voor bed slaapt de Krtek dit weekend?';
|
||||
$q->addAnswer(new Answer('Éénpersoons, losstaand bed'))
|
||||
->addAnswer(new Answer('Éénpersoonsbed, tegen een ander bed aan', true))
|
||||
->addAnswer(new Answer('Tweepersoons bed'));
|
||||
$q->ordering = 12;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Waar zat de Krtek aan tafel bij het diner?')
|
||||
->addAnswer(new Answer('Met de rug naar de accommodatie'))
|
||||
->addAnswer(new Answer('Met de rug naar de buitenmuur', true))
|
||||
->setOrdering(14),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Hoeveel jaar heeft de Krtek gedaan over de middelbare school?';
|
||||
$q->addAnswer(new Answer('5'))
|
||||
->addAnswer(new Answer('6', true))
|
||||
->addAnswer(new Answer('7'))
|
||||
->addAnswer(new Answer('8'));
|
||||
$q->ordering = 13;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Wie is de Krtek?')
|
||||
->addAnswer(new Answer('Claudia', true))
|
||||
->addAnswer(new Answer('Eelco'))
|
||||
->addAnswer(new Answer('Elise'))
|
||||
->addAnswer(new Answer('Gert-Jan'))
|
||||
->addAnswer(new Answer('Iris'))
|
||||
->addAnswer(new Answer('Jari'))
|
||||
->addAnswer(new Answer('Lara'))
|
||||
->addAnswer(new Answer('Lotte'))
|
||||
->addAnswer(new Answer('Myrthe'))
|
||||
->addAnswer(new Answer('Philine'))
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom'))
|
||||
->setOrdering(15),
|
||||
)
|
||||
;
|
||||
$q = new Question();
|
||||
$q->question = 'Waar zat de Krtek aan tafel bij het diner?';
|
||||
$q->addAnswer(new Answer('Met de rug naar de accommodatie'))
|
||||
->addAnswer(new Answer('Met de rug naar de buitenmuur', true));
|
||||
$q->ordering = 14;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
$q = new Question();
|
||||
$q->question = 'Wie is de Krtek?';
|
||||
$q->addAnswer(new Answer('Claudia', true))
|
||||
->addAnswer(new Answer('Eelco'))
|
||||
->addAnswer(new Answer('Elise'))
|
||||
->addAnswer(new Answer('Gert-Jan'))
|
||||
->addAnswer(new Answer('Iris'))
|
||||
->addAnswer(new Answer('Jari'))
|
||||
->addAnswer(new Answer('Lara'))
|
||||
->addAnswer(new Answer('Lotte'))
|
||||
->addAnswer(new Answer('Myrthe'))
|
||||
->addAnswer(new Answer('Philine'))
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom'));
|
||||
$q->ordering = 15;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
return $quiz;
|
||||
}
|
||||
|
||||
private function createQuiz2(Season $season): Quiz
|
||||
{
|
||||
return new Quiz()
|
||||
->setName('Quiz 2')
|
||||
->setSeason($season)
|
||||
$quiz = new Quiz();
|
||||
$quiz->name = 'Quiz 2';
|
||||
$quiz->season = $season;
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Is de Krtek een man of een vrouw?')
|
||||
->addAnswer(new Answer('Man'))
|
||||
->addAnswer(new Answer('Vrouw', true))
|
||||
->setOrdering(1),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Is de Krtek een man of een vrouw?';
|
||||
$q->addAnswer(new Answer('Man'))
|
||||
->addAnswer(new Answer('Vrouw', true));
|
||||
$q->ordering = 1;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Heeft de Krtek dieetwensen of allergieën?')
|
||||
->addAnswer(new Answer('nee'))
|
||||
->addAnswer(new Answer('De Krtek is vegetariër', true))
|
||||
->addAnswer(new Answer('De Krtek is flexitariër'))
|
||||
->addAnswer(new Answer('De Krtek heeft een allergie'))
|
||||
->addAnswer(new Answer('De Krtek heeft een intolerantie'))
|
||||
->addAnswer(new Answer('De Krtek eet geen rundvlees'))
|
||||
->addAnswer(new Answer('De Krtek eet geen waterdieren'))
|
||||
->setOrdering(2),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Heeft de Krtek dieetwensen of allergieën?';
|
||||
$q->addAnswer(new Answer('nee'))
|
||||
->addAnswer(new Answer('De Krtek is vegetariër', true))
|
||||
->addAnswer(new Answer('De Krtek is flexitariër'))
|
||||
->addAnswer(new Answer('De Krtek heeft een allergie'))
|
||||
->addAnswer(new Answer('De Krtek heeft een intolerantie'))
|
||||
->addAnswer(new Answer('De Krtek eet geen rundvlees'))
|
||||
->addAnswer(new Answer('De Krtek eet geen waterdieren'));
|
||||
$q->ordering = 2;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Hoe heet het huisdier/de huisdieren van de Krtek?')
|
||||
->addAnswer(new Answer('Amy, Karel en Floyd'))
|
||||
->addAnswer(new Answer('Flip en Majoor'))
|
||||
->addAnswer(new Answer('Benji'))
|
||||
->addAnswer(new Answer('Sini'))
|
||||
->addAnswer(new Answer('Tom'))
|
||||
->addAnswer(new Answer('De huisdieren van de Krtek hebben geen naam'))
|
||||
->addAnswer(new Answer('De Krtek heeft geen huisdieren', true))
|
||||
->setOrdering(3),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Hoe heet het huisdier/de huisdieren van de Krtek?';
|
||||
$q->addAnswer(new Answer('Amy, Karel en Floyd'))
|
||||
->addAnswer(new Answer('Flip en Majoor'))
|
||||
->addAnswer(new Answer('Benji'))
|
||||
->addAnswer(new Answer('Sini'))
|
||||
->addAnswer(new Answer('Tom'))
|
||||
->addAnswer(new Answer('De huisdieren van de Krtek hebben geen naam'))
|
||||
->addAnswer(new Answer('De Krtek heeft geen huisdieren', true));
|
||||
$q->ordering = 3;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Wat dronk de Krtek deze ochtend bij het ontbijt?')
|
||||
->addAnswer(new Answer('Koffie'))
|
||||
->addAnswer(new Answer('Thee'))
|
||||
->addAnswer(new Answer('Water', true))
|
||||
->addAnswer(new Answer('Melk'))
|
||||
->addAnswer(new Answer('Sap'))
|
||||
->addAnswer(new Answer('Niks'))
|
||||
->setOrdering(4),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Wat dronk de Krtek deze ochtend bij het ontbijt?';
|
||||
$q->addAnswer(new Answer('Koffie'))
|
||||
->addAnswer(new Answer('Thee'))
|
||||
->addAnswer(new Answer('Water', true))
|
||||
->addAnswer(new Answer('Melk'))
|
||||
->addAnswer(new Answer('Sap'))
|
||||
->addAnswer(new Answer('Niks'));
|
||||
$q->ordering = 4;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Waar ging de eerste vakantie die de Krtek zich nog herinnert heen?')
|
||||
->addAnswer(new Answer('Denemarken'))
|
||||
->addAnswer(new Answer('Drenthe'))
|
||||
->addAnswer(new Answer('Mallorca'))
|
||||
->addAnswer(new Answer('Marokko'))
|
||||
->addAnswer(new Answer('Oostenrijk'))
|
||||
->addAnswer(new Answer('Turkije'))
|
||||
->addAnswer(new Answer('Zweden', true))
|
||||
->setOrdering(5),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Waar ging de eerste vakantie die de Krtek zich nog herinnert heen?';
|
||||
$q->addAnswer(new Answer('Denemarken'))
|
||||
->addAnswer(new Answer('Drenthe'))
|
||||
->addAnswer(new Answer('Mallorca'))
|
||||
->addAnswer(new Answer('Marokko'))
|
||||
->addAnswer(new Answer('Oostenrijk'))
|
||||
->addAnswer(new Answer('Turkije'))
|
||||
->addAnswer(new Answer('Zweden', true));
|
||||
$q->ordering = 5;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Met welk groepje ging de Krtek als eerste het Douanespel in?')
|
||||
->addAnswer(new Answer('Het eerste groepje', true))
|
||||
->addAnswer(new Answer('Het tweede groepje'))
|
||||
->addAnswer(new Answer('Het derde groepje'))
|
||||
->addAnswer(new Answer('Het vierde groepje'))
|
||||
->addAnswer(new Answer('Het vijfde groepje'))
|
||||
->setOrdering(6),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Met welk groepje ging de Krtek als eerste het Douanespel in?';
|
||||
$q->addAnswer(new Answer('Het eerste groepje', true))
|
||||
->addAnswer(new Answer('Het tweede groepje'))
|
||||
->addAnswer(new Answer('Het derde groepje'))
|
||||
->addAnswer(new Answer('Het vierde groepje'))
|
||||
->addAnswer(new Answer('Het vijfde groepje'));
|
||||
$q->ordering = 6;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Gelooft de Krtek ergens in?')
|
||||
->addAnswer(new Answer('Nee'))
|
||||
->addAnswer(new Answer('Het universum', true))
|
||||
->addAnswer(new Answer('Toeval'))
|
||||
->addAnswer(new Answer('De Krtek is hindoeïstisch'))
|
||||
->setOrdering(7),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Gelooft de Krtek ergens in?';
|
||||
$q->addAnswer(new Answer('Nee'))
|
||||
->addAnswer(new Answer('Het universum', true))
|
||||
->addAnswer(new Answer('Toeval'))
|
||||
->addAnswer(new Answer('De Krtek is hindoeïstisch'));
|
||||
$q->ordering = 7;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('At de Krtek op vrijdagavond heksenkaas tijdens het diner?')
|
||||
->addAnswer(new Answer('Ja', true))
|
||||
->addAnswer(new Answer('Nee'))
|
||||
->setOrdering(8),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'At de Krtek op vrijdagavond heksenkaas tijdens het diner?';
|
||||
$q->addAnswer(new Answer('Ja', true))
|
||||
->addAnswer(new Answer('Nee'));
|
||||
$q->ordering = 8;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Hoe laat ging de Krtek gisteravond naar bed?')
|
||||
->addAnswer(new Answer('Tussen 0:00 en 0:59 uur'))
|
||||
->addAnswer(new Answer('Tussen 1:00 en 1:59 uur', true))
|
||||
->addAnswer(new Answer('Tussen 2:00 en 2:59 uur'))
|
||||
->addAnswer(new Answer('Na 3:00'))
|
||||
->setOrdering(9),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Hoe laat ging de Krtek gisteravond naar bed?';
|
||||
$q->addAnswer(new Answer('Tussen 0:00 en 0:59 uur'))
|
||||
->addAnswer(new Answer('Tussen 1:00 en 1:59 uur', true))
|
||||
->addAnswer(new Answer('Tussen 2:00 en 2:59 uur'))
|
||||
->addAnswer(new Answer('Na 3:00'));
|
||||
$q->ordering = 9;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Hoeveel batterijen heeft de Krtek naar het bord gebracht bij het douanespel?')
|
||||
->addAnswer(new Answer('1'))
|
||||
->addAnswer(new Answer('2'))
|
||||
->addAnswer(new Answer('3'))
|
||||
->addAnswer(new Answer('geen', true))
|
||||
->setOrdering(10),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Hoeveel batterijen heeft de Krtek naar het bord gebracht bij het douanespel?';
|
||||
$q->addAnswer(new Answer('1'))
|
||||
->addAnswer(new Answer('2'))
|
||||
->addAnswer(new Answer('3'))
|
||||
->addAnswer(new Answer('geen', true));
|
||||
$q->ordering = 10;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Wat keek de Krtek als kind graag op TV?')
|
||||
->addAnswer(new Answer('Digimon', true))
|
||||
->addAnswer(new Answer('Floris'))
|
||||
->addAnswer(new Answer('Het huis Anubis'))
|
||||
->addAnswer(new Answer('Sesamstraat'))
|
||||
->addAnswer(new Answer('Spongebob Squarepants'))
|
||||
->addAnswer(new Answer('Teletubbies'))
|
||||
->setOrdering(11),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Wat keek de Krtek als kind graag op TV?';
|
||||
$q->addAnswer(new Answer('Digimon', true))
|
||||
->addAnswer(new Answer('Floris'))
|
||||
->addAnswer(new Answer('Het huis Anubis'))
|
||||
->addAnswer(new Answer('Sesamstraat'))
|
||||
->addAnswer(new Answer('Spongebob Squarepants'))
|
||||
->addAnswer(new Answer('Teletubbies'));
|
||||
$q->ordering = 11;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Waarin zat op de heenreis de bagage van de Krtek (voornamelijk)?')
|
||||
->addAnswer(new Answer('In koffer(s)', true))
|
||||
->addAnswer(new Answer('In losse tas(sen)'))
|
||||
->addAnswer(new Answer('In een rugzak'))
|
||||
->setOrdering(12),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Waarin zat op de heenreis de bagage van de Krtek (voornamelijk)?';
|
||||
$q->addAnswer(new Answer('In koffer(s)', true))
|
||||
->addAnswer(new Answer('In losse tas(sen)'))
|
||||
->addAnswer(new Answer('In een rugzak'));
|
||||
$q->ordering = 12;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Van welk geluid gaan de haren van de Krtek overeind staan?')
|
||||
->addAnswer(new Answer('Een vork die door een metalen pan krast '))
|
||||
->addAnswer(new Answer('Smakkende mensen'))
|
||||
->addAnswer(new Answer('Een vork die over een bord schraapt'))
|
||||
->addAnswer(new Answer('Schuren met schuurpapier'))
|
||||
->addAnswer(new Answer('Nagels op een krijtbord'))
|
||||
->addAnswer(new Answer('Servies dat tegen elkaar klettert'))
|
||||
->addAnswer(new Answer('Het geroekoe van een duif', true))
|
||||
->addAnswer(new Answer('Piepschuim'))
|
||||
->setOrdering(13),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Van welk geluid gaan de haren van de Krtek overeind staan?';
|
||||
$q->addAnswer(new Answer('Een vork die door een metalen pan krast '))
|
||||
->addAnswer(new Answer('Smakkende mensen'))
|
||||
->addAnswer(new Answer('Een vork die over een bord schraapt'))
|
||||
->addAnswer(new Answer('Schuren met schuurpapier'))
|
||||
->addAnswer(new Answer('Nagels op een krijtbord'))
|
||||
->addAnswer(new Answer('Servies dat tegen elkaar klettert'))
|
||||
->addAnswer(new Answer('Het geroekoe van een duif', true))
|
||||
->addAnswer(new Answer('Piepschuim'));
|
||||
$q->ordering = 13;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Wilde de Krtek penningmeester worden?')
|
||||
->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true))
|
||||
->setOrdering(14),
|
||||
)
|
||||
$q = new Question();
|
||||
$q->question = 'Wilde de Krtek penningmeester worden?';
|
||||
$q->addAnswer(new Answer('Ja'))
|
||||
->addAnswer(new Answer('Nee', true));
|
||||
$q->ordering = 14;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
->addQuestion(new Question()
|
||||
->setQuestion('Wie is de Krtek?')
|
||||
->addAnswer(new Answer('Claudia', true))
|
||||
->addAnswer(new Answer('Eelco'))
|
||||
->addAnswer(new Answer('Elise'))
|
||||
->addAnswer(new Answer('Gert-Jan'))
|
||||
->addAnswer(new Answer('Iris'))
|
||||
->addAnswer(new Answer('Jari'))
|
||||
->addAnswer(new Answer('Lara'))
|
||||
->addAnswer(new Answer('Lotte'))
|
||||
->addAnswer(new Answer('Myrthe'))
|
||||
->addAnswer(new Answer('Philine'))
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom'))
|
||||
->setOrdering(15),
|
||||
)
|
||||
;
|
||||
$q = new Question();
|
||||
$q->question = 'Wie is de Krtek?';
|
||||
$q->addAnswer(new Answer('Claudia', true))
|
||||
->addAnswer(new Answer('Eelco'))
|
||||
->addAnswer(new Answer('Elise'))
|
||||
->addAnswer(new Answer('Gert-Jan'))
|
||||
->addAnswer(new Answer('Iris'))
|
||||
->addAnswer(new Answer('Jari'))
|
||||
->addAnswer(new Answer('Lara'))
|
||||
->addAnswer(new Answer('Lotte'))
|
||||
->addAnswer(new Answer('Myrthe'))
|
||||
->addAnswer(new Answer('Philine'))
|
||||
->addAnswer(new Answer('Remy'))
|
||||
->addAnswer(new Answer('Robbert'))
|
||||
->addAnswer(new Answer('Tom'));
|
||||
$q->ordering = 15;
|
||||
$quiz->addQuestion($q);
|
||||
|
||||
return $quiz;
|
||||
}
|
||||
}
|
||||
|
||||
19
src/Dto/Result.php
Normal file
19
src/Dto/Result.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tvdt\Dto;
|
||||
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
final readonly class Result
|
||||
{
|
||||
public function __construct(
|
||||
public Uuid $id,
|
||||
public string $name,
|
||||
public int $correct,
|
||||
public float $corrections,
|
||||
public \DateInterval $time,
|
||||
public float $score,
|
||||
) {}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Repository\AnswerRepository;
|
||||
@@ -17,114 +16,45 @@ use Tvdt\Repository\AnswerRepository;
|
||||
class Answer
|
||||
{
|
||||
#[ORM\Column(type: UuidType::NAME)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
||||
private int $ordering = 0;
|
||||
public int $ordering = 0;
|
||||
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'answers')]
|
||||
private Question $question;
|
||||
public Question $question;
|
||||
|
||||
/** @var Collection<int, Candidate> */
|
||||
#[ORM\ManyToMany(targetEntity: Candidate::class, inversedBy: 'answersOnCandidate')]
|
||||
private Collection $candidates;
|
||||
public private(set) Collection $candidates;
|
||||
|
||||
/** @var Collection<int, GivenAnswer> */
|
||||
#[ORM\OneToMany(targetEntity: GivenAnswer::class, mappedBy: 'answer', orphanRemoval: true)]
|
||||
private Collection $givenAnswers;
|
||||
public private(set) Collection $givenAnswers;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Column(length: 255)]
|
||||
private string $text,
|
||||
public string $text,
|
||||
#[ORM\Column]
|
||||
private bool $isRightAnswer = false,
|
||||
public bool $isRightAnswer = false,
|
||||
) {
|
||||
$this->candidates = new ArrayCollection();
|
||||
$this->givenAnswers = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function setText(string $text): static
|
||||
{
|
||||
$this->text = $text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuestion(): Question
|
||||
{
|
||||
return $this->question;
|
||||
}
|
||||
|
||||
public function setQuestion(Question $question): static
|
||||
{
|
||||
$this->question = $question;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isRightAnswer(): bool
|
||||
{
|
||||
return $this->isRightAnswer;
|
||||
}
|
||||
|
||||
public function setRightAnswer(bool $isRightAnswer): static
|
||||
{
|
||||
$this->isRightAnswer = $isRightAnswer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Candidate> */
|
||||
public function getCandidates(): Collection
|
||||
{
|
||||
return $this->candidates;
|
||||
}
|
||||
|
||||
public function addCandidate(Candidate $candidate): static
|
||||
public function addCandidate(Candidate $candidate): void
|
||||
{
|
||||
if (!$this->candidates->contains($candidate)) {
|
||||
$this->candidates->add($candidate);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeCandidate(Candidate $candidate): static
|
||||
public function removeCandidate(Candidate $candidate): void
|
||||
{
|
||||
$this->candidates->removeElement($candidate);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, GivenAnswer> */
|
||||
public function getGivenAnswers(): Collection
|
||||
{
|
||||
return $this->givenAnswers;
|
||||
}
|
||||
|
||||
public function getOrdering(): int
|
||||
{
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
public function setOrdering(int $ordering): self
|
||||
{
|
||||
$this->ordering = $ordering;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Tvdt\Entity;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Helpers\Base64;
|
||||
@@ -18,104 +17,52 @@ use Tvdt\Repository\CandidateRepository;
|
||||
class Candidate
|
||||
{
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'candidates')]
|
||||
private Season $season;
|
||||
public Season $season;
|
||||
|
||||
/** @var Collection<int, Answer> */
|
||||
#[ORM\ManyToMany(targetEntity: Answer::class, mappedBy: 'candidates')]
|
||||
private Collection $answersOnCandidate;
|
||||
public private(set) Collection $answersOnCandidate;
|
||||
|
||||
/** @var Collection<int, GivenAnswer> */
|
||||
#[ORM\OneToMany(targetEntity: GivenAnswer::class, mappedBy: 'candidate', orphanRemoval: true)]
|
||||
private Collection $givenAnswers;
|
||||
public private(set) Collection $givenAnswers;
|
||||
|
||||
/** @var Collection<int, QuizCandidate> */
|
||||
#[ORM\OneToMany(targetEntity: QuizCandidate::class, mappedBy: 'candidate', orphanRemoval: true)]
|
||||
private Collection $quizData;
|
||||
public private(set) Collection $quizData;
|
||||
|
||||
public string $nameHash {
|
||||
get => Base64::base64UrlEncode($this->name);
|
||||
}
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Column(length: 16)]
|
||||
private string $name,
|
||||
public string $name,
|
||||
) {
|
||||
$this->answersOnCandidate = new ArrayCollection();
|
||||
$this->givenAnswers = new ArrayCollection();
|
||||
$this->quizData = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getSeason(): Season
|
||||
{
|
||||
return $this->season;
|
||||
}
|
||||
|
||||
public function setSeason(Season $season): static
|
||||
{
|
||||
$this->season = $season;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Answer> */
|
||||
public function getAnswersOnCandidate(): Collection
|
||||
{
|
||||
return $this->answersOnCandidate;
|
||||
}
|
||||
|
||||
public function addAnswersOnCandidate(Answer $answersOnCandidate): static
|
||||
public function addAnswersOnCandidate(Answer $answersOnCandidate): void
|
||||
{
|
||||
if (!$this->answersOnCandidate->contains($answersOnCandidate)) {
|
||||
$this->answersOnCandidate->add($answersOnCandidate);
|
||||
$answersOnCandidate->addCandidate($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeAnswersOnCandidate(Answer $answersOnCandidate): static
|
||||
public function removeAnswersOnCandidate(Answer $answersOnCandidate): void
|
||||
{
|
||||
if ($this->answersOnCandidate->removeElement($answersOnCandidate)) {
|
||||
$answersOnCandidate->removeCandidate($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, GivenAnswer> */
|
||||
public function getGivenAnswers(): Collection
|
||||
{
|
||||
return $this->givenAnswers;
|
||||
}
|
||||
|
||||
/** @return Collection<int, QuizCandidate> */
|
||||
public function getQuizData(): Collection
|
||||
{
|
||||
return $this->quizData;
|
||||
}
|
||||
|
||||
public function getNameHash(): string
|
||||
{
|
||||
return Base64::base64UrlEncode($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Tvdt\Entity;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Safe\DateTimeImmutable;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\HttpFoundation\InputBag;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
@@ -22,48 +21,24 @@ class Elimination
|
||||
public const string SCREEN_RED = 'red';
|
||||
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
#[ORM\Column(type: Types::JSON)]
|
||||
private array $data = [];
|
||||
#[ORM\Column(type: Types::JSONB)]
|
||||
public array $data = [];
|
||||
|
||||
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)]
|
||||
private \DateTimeImmutable $created;
|
||||
public private(set) \DateTimeImmutable $created;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||
#[ORM\ManyToOne(inversedBy: 'eliminations')]
|
||||
private Quiz $quiz,
|
||||
public Quiz $quiz,
|
||||
) {}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $data */
|
||||
public function setData(array $data): self
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuiz(): Quiz
|
||||
{
|
||||
return $this->quiz;
|
||||
}
|
||||
|
||||
/** @param InputBag<bool|float|int|string> $inputBag */
|
||||
public function updateFromInputBag(InputBag $inputBag): self
|
||||
{
|
||||
@@ -87,9 +62,4 @@ class Elimination
|
||||
{
|
||||
$this->created = new DateTimeImmutable();
|
||||
}
|
||||
|
||||
public function getCreated(): \DateTimeInterface
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Tvdt\Entity;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Safe\DateTimeImmutable;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Repository\GivenAnswerRepository;
|
||||
@@ -17,53 +16,28 @@ use Tvdt\Repository\GivenAnswerRepository;
|
||||
class GivenAnswer
|
||||
{
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: false)]
|
||||
private \DateTimeImmutable $created;
|
||||
public private(set) \DateTimeImmutable $created;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'givenAnswers')]
|
||||
private Candidate $candidate,
|
||||
private(set) Candidate $candidate,
|
||||
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||
#[ORM\ManyToOne]
|
||||
private Quiz $quiz,
|
||||
private(set) Quiz $quiz,
|
||||
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'givenAnswers')]
|
||||
private Answer $answer,
|
||||
private(set) Answer $answer,
|
||||
) {}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCandidate(): Candidate
|
||||
{
|
||||
return $this->candidate;
|
||||
}
|
||||
|
||||
public function getQuiz(): Quiz
|
||||
{
|
||||
return $this->quiz;
|
||||
}
|
||||
|
||||
public function getAnswer(): Answer
|
||||
{
|
||||
return $this->answer;
|
||||
}
|
||||
|
||||
public function getCreated(): \DateTimeImmutable
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
#[ORM\PrePersist]
|
||||
public function setCreatedAtValue(): void
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Repository\QuestionRepository;
|
||||
@@ -17,86 +16,39 @@ use Tvdt\Repository\QuestionRepository;
|
||||
class Question
|
||||
{
|
||||
#[ORM\Column(type: UuidType::NAME)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
|
||||
private int $ordering;
|
||||
public int $ordering;
|
||||
|
||||
#[ORM\Column(type: Types::STRING, length: 255)]
|
||||
private string $question;
|
||||
public string $question;
|
||||
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'questions')]
|
||||
private Quiz $quiz;
|
||||
public Quiz $quiz;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $enabled = true;
|
||||
public bool $enabled = true;
|
||||
|
||||
/** @var Collection<int, Answer> */
|
||||
#[ORM\OneToMany(targetEntity: Answer::class, mappedBy: 'question', cascade: ['persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['ordering' => 'ASC'])]
|
||||
private Collection $answers;
|
||||
public private(set) Collection $answers;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->answers = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getQuestion(): string
|
||||
{
|
||||
return $this->question;
|
||||
}
|
||||
|
||||
public function setQuestion(string $question): static
|
||||
{
|
||||
$this->question = $question;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuiz(): Quiz
|
||||
{
|
||||
return $this->quiz;
|
||||
}
|
||||
|
||||
public function setQuiz(Quiz $quiz): static
|
||||
{
|
||||
$this->quiz = $quiz;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isEnabled(): ?bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
public function setEnabled(bool $enabled): static
|
||||
{
|
||||
$this->enabled = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Answer> */
|
||||
public function getAnswers(): Collection
|
||||
{
|
||||
return $this->answers;
|
||||
}
|
||||
|
||||
public function addAnswer(Answer $answer): static
|
||||
{
|
||||
if (!$this->answers->contains($answer)) {
|
||||
$this->answers->add($answer);
|
||||
$answer->setQuestion($this);
|
||||
$answer->question = $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -108,7 +60,7 @@ class Question
|
||||
return 'This question has no answers';
|
||||
}
|
||||
|
||||
$correctAnswers = $this->answers->filter(static fn (Answer $answer): bool => $answer->isRightAnswer())->count();
|
||||
$correctAnswers = $this->answers->filter(static fn (Answer $answer): bool => $answer->isRightAnswer)->count();
|
||||
|
||||
if (0 === $correctAnswers) {
|
||||
return 'This question has no correct answers';
|
||||
@@ -120,16 +72,4 @@ class Question
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getOrdering(): int
|
||||
{
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
public function setOrdering(int $ordering): static
|
||||
{
|
||||
$this->ordering = $ordering;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Tvdt\Entity;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Repository\QuizRepository;
|
||||
@@ -17,34 +16,34 @@ use Tvdt\Repository\QuizRepository;
|
||||
class Quiz
|
||||
{
|
||||
#[ORM\Column(type: UuidType::NAME)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\Column(length: 64)]
|
||||
private string $name;
|
||||
public string $name;
|
||||
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'quizzes')]
|
||||
private Season $season;
|
||||
public Season $season;
|
||||
|
||||
/** @var Collection<int, Question> */
|
||||
#[ORM\OneToMany(targetEntity: Question::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['ordering' => 'ASC'])]
|
||||
private Collection $questions;
|
||||
public private(set) Collection $questions;
|
||||
|
||||
/** @var Collection<int, QuizCandidate> */
|
||||
#[ORM\OneToMany(targetEntity: QuizCandidate::class, mappedBy: 'quiz', orphanRemoval: true)]
|
||||
private Collection $candidateData;
|
||||
public private(set) Collection $candidateData;
|
||||
|
||||
#[ORM\Column(nullable: false, options: ['default' => 1])]
|
||||
private int $dropouts = 1;
|
||||
public int $dropouts = 1;
|
||||
|
||||
/** @var Collection<int, Elimination> */
|
||||
#[ORM\OneToMany(targetEntity: Elimination::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['created' => 'DESC'])]
|
||||
private Collection $eliminations;
|
||||
public private(set) Collection $eliminations;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -53,75 +52,16 @@ class Quiz
|
||||
$this->eliminations = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSeason(): Season
|
||||
{
|
||||
return $this->season;
|
||||
}
|
||||
|
||||
public function setSeason(Season $season): static
|
||||
{
|
||||
$this->season = $season;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Question> */
|
||||
public function getQuestions(): Collection
|
||||
{
|
||||
return $this->questions;
|
||||
}
|
||||
|
||||
public function addQuestion(Question $question): static
|
||||
{
|
||||
if (!$this->questions->contains($question)) {
|
||||
$this->questions->add($question);
|
||||
$question->setQuiz($this);
|
||||
$question->quiz = $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, QuizCandidate> */
|
||||
public function getCandidateData(): Collection
|
||||
{
|
||||
return $this->candidateData;
|
||||
}
|
||||
|
||||
public function getDropouts(): int
|
||||
{
|
||||
return $this->dropouts;
|
||||
}
|
||||
|
||||
public function setDropouts(int $dropouts): static
|
||||
{
|
||||
$this->dropouts = $dropouts;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Elimination> */
|
||||
public function getEliminations(): Collection
|
||||
{
|
||||
return $this->eliminations;
|
||||
}
|
||||
|
||||
public function addElimination(Elimination $elimination): self
|
||||
{
|
||||
$this->eliminations->add($elimination);
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Tvdt\Entity;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Safe\DateTimeImmutable;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Repository\QuizCandidateRepository;
|
||||
@@ -18,59 +17,27 @@ use Tvdt\Repository\QuizCandidateRepository;
|
||||
class QuizCandidate
|
||||
{
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\Column]
|
||||
private float $corrections = 0;
|
||||
public float $corrections = 0;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
|
||||
private \DateTimeImmutable $created;
|
||||
public private(set) \DateTimeImmutable $created;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'candidateData')]
|
||||
private Quiz $quiz,
|
||||
public Quiz $quiz,
|
||||
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'quizData')]
|
||||
private Candidate $candidate,
|
||||
public Candidate $candidate,
|
||||
) {}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCandidate(): Candidate
|
||||
{
|
||||
return $this->candidate;
|
||||
}
|
||||
|
||||
public function getQuiz(): Quiz
|
||||
{
|
||||
return $this->quiz;
|
||||
}
|
||||
|
||||
public function getCorrections(): ?float
|
||||
{
|
||||
return $this->corrections;
|
||||
}
|
||||
|
||||
public function setCorrections(float $corrections): static
|
||||
{
|
||||
$this->corrections = $corrections;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreated(): \DateTimeImmutable
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
#[ORM\PrePersist]
|
||||
public function setCreatedAtValue(): void
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Tvdt\Entity;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Repository\SeasonRepository;
|
||||
@@ -18,37 +17,37 @@ class Season
|
||||
private const string SEASON_CODE_CHARACTERS = 'bcdfghjklmnpqrstvwxz';
|
||||
|
||||
#[ORM\Column(type: UuidType::NAME)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\Column(length: 64)]
|
||||
private string $name;
|
||||
public string $name;
|
||||
|
||||
#[ORM\Column(length: 5)]
|
||||
private string $seasonCode;
|
||||
public string $seasonCode;
|
||||
|
||||
/** @var Collection<int, Quiz> */
|
||||
#[ORM\OneToMany(targetEntity: Quiz::class, mappedBy: 'season', cascade: ['persist'], orphanRemoval: true)]
|
||||
private Collection $quizzes;
|
||||
public private(set) Collection $quizzes;
|
||||
|
||||
/** @var Collection<int, Candidate> */
|
||||
#[ORM\OneToMany(targetEntity: Candidate::class, mappedBy: 'season', cascade: ['persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['name' => 'ASC'])]
|
||||
private Collection $candidates;
|
||||
public private(set) Collection $candidates;
|
||||
|
||||
/** @var Collection<int, User> */
|
||||
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'seasons')]
|
||||
private Collection $owners;
|
||||
public private(set) Collection $owners;
|
||||
|
||||
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
|
||||
#[ORM\ManyToOne]
|
||||
private ?Quiz $ActiveQuiz = null;
|
||||
public ?Quiz $activeQuiz = null;
|
||||
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
|
||||
private ?SeasonSettings $settings = null;
|
||||
public ?SeasonSettings $settings = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -58,73 +57,26 @@ class Season
|
||||
$this->owners = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSeasonCode(): ?string
|
||||
{
|
||||
return $this->seasonCode;
|
||||
}
|
||||
|
||||
public function setSeasonCode(string $seasonCode): static
|
||||
{
|
||||
$this->seasonCode = $seasonCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Quiz> */
|
||||
public function getQuizzes(): Collection
|
||||
{
|
||||
return $this->quizzes;
|
||||
}
|
||||
|
||||
public function addQuiz(Quiz $quiz): static
|
||||
{
|
||||
if (!$this->quizzes->contains($quiz)) {
|
||||
$this->quizzes->add($quiz);
|
||||
$quiz->setSeason($this);
|
||||
$quiz->season = $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Candidate> */
|
||||
public function getCandidates(): Collection
|
||||
{
|
||||
return $this->candidates;
|
||||
}
|
||||
|
||||
public function addCandidate(Candidate $candidate): static
|
||||
{
|
||||
if (!$this->candidates->contains($candidate)) {
|
||||
$this->candidates->add($candidate);
|
||||
$candidate->setSeason($this);
|
||||
$candidate->season = $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, User> */
|
||||
public function getOwners(): Collection
|
||||
{
|
||||
return $this->owners;
|
||||
}
|
||||
|
||||
public function addOwner(User $owner): static
|
||||
{
|
||||
if (!$this->owners->contains($owner)) {
|
||||
@@ -141,18 +93,6 @@ class Season
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActiveQuiz(): ?Quiz
|
||||
{
|
||||
return $this->ActiveQuiz;
|
||||
}
|
||||
|
||||
public function setActiveQuiz(?Quiz $ActiveQuiz): static
|
||||
{
|
||||
$this->ActiveQuiz = $ActiveQuiz;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isOwner(User $user): bool
|
||||
{
|
||||
return $this->owners->contains($user);
|
||||
@@ -171,16 +111,4 @@ class Season
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSettings(): ?SeasonSettings
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
||||
public function setSettings(SeasonSettings $settings): static
|
||||
{
|
||||
$this->settings = $settings;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace Tvdt\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Repository\SeasonSettingsRepository;
|
||||
@@ -15,43 +14,14 @@ use Tvdt\Repository\SeasonSettingsRepository;
|
||||
class SeasonSettings
|
||||
{
|
||||
#[ORM\Column(type: UuidType::NAME)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
|
||||
private bool $showNumbers = false;
|
||||
public bool $showNumbers = false;
|
||||
|
||||
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
|
||||
private bool $confirmAnswers = false;
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function isShowNumbers(): bool
|
||||
{
|
||||
return $this->showNumbers;
|
||||
}
|
||||
|
||||
public function setShowNumbers(bool $showNumbers): self
|
||||
{
|
||||
$this->showNumbers = $showNumbers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isConfirmAnswers(): bool
|
||||
{
|
||||
return $this->confirmAnswers;
|
||||
}
|
||||
|
||||
public function setConfirmAnswers(bool $confirmAnswers): self
|
||||
{
|
||||
$this->confirmAnswers = $confirmAnswers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
public bool $confirmAnswers = false;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
@@ -23,51 +22,38 @@ use Tvdt\Repository\UserRepository;
|
||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
{
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Uuid $id;
|
||||
public private(set) Uuid $id;
|
||||
|
||||
#[ORM\Column(length: 180)]
|
||||
private string $email;
|
||||
public string $email;
|
||||
|
||||
/** @var list<string> The user roles */
|
||||
#[ORM\Column(type: Types::JSON)]
|
||||
private array $roles = [];
|
||||
public array $roles = [];
|
||||
|
||||
/** @var string The hashed password */
|
||||
#[ORM\Column]
|
||||
private string $password;
|
||||
public string $password;
|
||||
|
||||
/** @var Collection<int, Season> */
|
||||
#[ORM\ManyToMany(targetEntity: Season::class, mappedBy: 'owners')]
|
||||
private Collection $seasons;
|
||||
public private(set) Collection $seasons;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $isVerified = false;
|
||||
public bool $isVerified = false;
|
||||
|
||||
public bool $isAdmin {
|
||||
get => \in_array('ROLE_ADMIN', $this->getRoles(), true);
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->seasons = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): static
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A visual identifier that represents this user.
|
||||
*
|
||||
@@ -97,27 +83,12 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
return array_unique($roles);
|
||||
}
|
||||
|
||||
/** @param list<string> $roles */
|
||||
public function setRoles(array $roles): static
|
||||
{
|
||||
$this->roles = $roles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @see PasswordAuthenticatedUserInterface */
|
||||
public function getPassword(): ?string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword(string $password): static
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @see UserInterface */
|
||||
public function eraseCredentials(): void
|
||||
{
|
||||
@@ -125,12 +96,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
// $this->plainPassword = null;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Season> */
|
||||
public function getSeasons(): Collection
|
||||
{
|
||||
return $this->seasons;
|
||||
}
|
||||
|
||||
public function addSeason(Season $season): static
|
||||
{
|
||||
if (!$this->seasons->contains($season)) {
|
||||
@@ -149,21 +114,4 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isVerified(): bool
|
||||
{
|
||||
return $this->isVerified;
|
||||
}
|
||||
|
||||
public function setIsVerified(bool $isVerified): static
|
||||
{
|
||||
$this->isVerified = $isVerified;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return \in_array('ROLE_ADMIN', $this->getRoles(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ final readonly class EliminationFactory
|
||||
$simpleScores = [];
|
||||
|
||||
foreach (array_reverse($scores) as $i => $score) {
|
||||
$simpleScores[$score['name']] = $i < $quiz->getDropouts() ? Elimination::SCREEN_RED : Elimination::SCREEN_GREEN;
|
||||
$simpleScores[$score->name] = $i < $quiz->dropouts ? Elimination::SCREEN_RED : Elimination::SCREEN_GREEN;
|
||||
}
|
||||
|
||||
$elimination->setData($simpleScores);
|
||||
$elimination->data = $simpleScores;
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@ namespace Tvdt\Repository;
|
||||
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Safe\DateTimeImmutable;
|
||||
use Safe\Exceptions\DatetimeException;
|
||||
use Safe\Exceptions\UrlException;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Tvdt\Dto\Result;
|
||||
use Tvdt\Entity\Candidate;
|
||||
use Tvdt\Entity\Quiz;
|
||||
use Tvdt\Entity\Season;
|
||||
@@ -15,9 +17,6 @@ use Tvdt\Helpers\Base64;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Candidate>
|
||||
*
|
||||
* @phpstan-type Result array{id: Uuid, name: string, correct: int, time: \DateInterval, corrections: float, score: float}
|
||||
* @phpstan-type ResultList list<Result>
|
||||
*/
|
||||
class CandidateRepository extends ServiceEntityRepository
|
||||
{
|
||||
@@ -53,25 +52,39 @@ class CandidateRepository extends ServiceEntityRepository
|
||||
}
|
||||
}
|
||||
|
||||
/** @return ResultList */
|
||||
/**
|
||||
* @throws DatetimeException
|
||||
*
|
||||
* @return list<Result>
|
||||
*/
|
||||
public function getScores(Quiz $quiz): array
|
||||
{
|
||||
return $this->getEntityManager()->createQuery(<<<DQL
|
||||
$result = $this->getEntityManager()->createQuery(<<<DQL
|
||||
select
|
||||
c.id,
|
||||
c.name,
|
||||
count(case when a.isRightAnswer = true then 1 else null end) as correct,
|
||||
sum(case when a.isRightAnswer = true then 1 else 0 end) as correct,
|
||||
qc.corrections,
|
||||
max(ga.created) - qc.created as time,
|
||||
(count(case when a.isRightAnswer = true then 1 else null end) + qc.corrections) as score
|
||||
max(ga.created) as end_time,
|
||||
qc.created as start_time,
|
||||
(sum(case when a.isRightAnswer = true then 1 else 0 end) + qc.corrections) as score
|
||||
from Tvdt\Entity\Candidate c
|
||||
join c.givenAnswers ga
|
||||
join ga.answer a
|
||||
join c.quizData qc
|
||||
where qc.quiz = :quiz and ga.quiz = :quiz
|
||||
group by ga.quiz, c.id, qc.id
|
||||
order by score desc, time asc
|
||||
order by score desc, max(ga.created) - qc.created asc
|
||||
DQL
|
||||
)->setParameter('quiz', $quiz)->getResult();
|
||||
|
||||
return array_map(static fn (array $row): Result => new Result(
|
||||
id: $row['id'],
|
||||
name: $row['name'],
|
||||
correct: (int) $row['correct'],
|
||||
corrections: $row['corrections'],
|
||||
time: new DateTimeImmutable($row['end_time'])->diff($row['start_time']),
|
||||
score: $row['score'],
|
||||
), $result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class QuestionRepository extends ServiceEntityRepository
|
||||
DQL)
|
||||
->setMaxResults(1)
|
||||
->setParameter('candidate', $candidate)
|
||||
->setParameter('quiz', $candidate->getSeason()->getActiveQuiz())
|
||||
->setParameter('quiz', $candidate->season->activeQuiz)
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class QuizCandidateRepository extends ServiceEntityRepository
|
||||
throw new \InvalidArgumentException('Quiz candidate not found');
|
||||
}
|
||||
|
||||
$quizCandidate->setCorrections($corrections);
|
||||
$quizCandidate->corrections = $corrections;
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
||||
* */
|
||||
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
|
||||
{
|
||||
$user->setPassword($newHashedPassword);
|
||||
$user->password = $newHashedPassword;
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
||||
throw new \InvalidArgumentException('User not found');
|
||||
}
|
||||
|
||||
$user->setRoles(['ROLE_ADMIN']);
|
||||
$user->roles = ['ROLE_ADMIN'];
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ readonly class EmailVerifier
|
||||
{
|
||||
$signatureComponents = $this->verifyEmailHelper->generateSignature(
|
||||
$verifyEmailRouteName,
|
||||
(string) $user->getId(),
|
||||
(string) $user->getEmail(),
|
||||
['id' => $user->getId()],
|
||||
$user->id->toRfc4122(),
|
||||
$user->email,
|
||||
['id' => $user->id],
|
||||
);
|
||||
|
||||
$context = $email->getContext();
|
||||
@@ -42,9 +42,9 @@ readonly class EmailVerifier
|
||||
|
||||
public function handleEmailConfirmation(Request $request, User $user): void
|
||||
{
|
||||
$this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, (string) $user->getId(), (string) $user->getEmail());
|
||||
$this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, $user->id->toRfc4122(), $user->email);
|
||||
|
||||
$user->setIsVerified(true);
|
||||
$user->isVerified = true;
|
||||
|
||||
$this->entityManager->persist($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
@@ -15,7 +15,7 @@ use Tvdt\Entity\Quiz;
|
||||
use Tvdt\Entity\Season;
|
||||
use Tvdt\Entity\User;
|
||||
|
||||
/** @extends Voter<string, Season> */
|
||||
/** @extends Voter<string, Season|Elimination|Quiz|Candidate|Answer|Question> */
|
||||
final class SeasonVoter extends Voter
|
||||
{
|
||||
public const string EDIT = 'SEASON_EDIT';
|
||||
@@ -28,16 +28,15 @@ final class SeasonVoter extends Voter
|
||||
{
|
||||
return \in_array($attribute, [self::EDIT, self::DELETE, self::ELIMINATION], true)
|
||||
&& (
|
||||
$subject instanceof Season
|
||||
|| $subject instanceof Elimination
|
||||
|| $subject instanceof Quiz
|
||||
$subject instanceof Answer
|
||||
|| $subject instanceof Candidate
|
||||
|| $subject instanceof Answer
|
||||
|| $subject instanceof Elimination
|
||||
|| $subject instanceof Season
|
||||
|| $subject instanceof Question
|
||||
|| $subject instanceof Quiz
|
||||
);
|
||||
}
|
||||
|
||||
/** @param Season|Elimination|Quiz|Candidate|Answer|Question $subject */
|
||||
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
|
||||
{
|
||||
$user = $token->getUser();
|
||||
@@ -45,21 +44,21 @@ final class SeasonVoter extends Voter
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
if ($user->isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case $subject instanceof Answer:
|
||||
$season = $subject->getQuestion()->getQuiz()->getSeason();
|
||||
$season = $subject->question->quiz->season;
|
||||
break;
|
||||
case $subject instanceof Elimination:
|
||||
case $subject instanceof Question:
|
||||
$season = $subject->getQuiz()->getSeason();
|
||||
$season = $subject->quiz->season;
|
||||
break;
|
||||
case $subject instanceof Candidate:
|
||||
case $subject instanceof Quiz:
|
||||
$season = $subject->getSeason();
|
||||
$season = $subject->season;
|
||||
break;
|
||||
case $subject instanceof Season:
|
||||
$season = $subject;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tvdt\Service;
|
||||
|
||||
use Tvdt\Repository\CandidateRepository;
|
||||
|
||||
/**
|
||||
* @phpstan-import-type ResultList from CandidateRepository
|
||||
*/
|
||||
class EliminationService
|
||||
{
|
||||
/** @phpstan-param ResultList $result */
|
||||
public function createEliminationFromResult(array $result): void {}
|
||||
}
|
||||
@@ -84,8 +84,8 @@ class QuizSpreadsheetService
|
||||
}
|
||||
|
||||
$question = new Question();
|
||||
$question->setQuestion((string) $questionArr[0]);
|
||||
$question->setOrdering($questionCounter++);
|
||||
$question->question = (string) $questionArr[0];
|
||||
$question->ordering = $questionCounter++;
|
||||
|
||||
$answerCounter = 1;
|
||||
$arrCounter = 1;
|
||||
@@ -100,7 +100,7 @@ class QuizSpreadsheetService
|
||||
}
|
||||
|
||||
$answer = new Answer((string) $questionArr[$arrCounter++], (bool) $questionArr[$arrCounter++]);
|
||||
$answer->setOrdering($answerCounter++);
|
||||
$answer->ordering = $answerCounter++;
|
||||
$question->addAnswer($answer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user