From 4918f494451c84846434c95194447ab91d8640b4 Mon Sep 17 00:00:00 2001 From: Marijn Doeve Date: Mon, 9 Mar 2026 19:56:25 +0100 Subject: [PATCH] WIP --- .idea/db-forest-config.xml | 6 + config/packages/maker.yaml | 6 + src/Controller/Backoffice/QuizController.php | 4 +- .../Backoffice/SeasonController.php | 2 +- src/Controller/QuizController.php | 2 +- src/DataFixtures/KrtekFixtures.php | 4 +- src/Form/UploadQuizFormType.php | 4 +- src/Repository/QuizCandidateRepository.php | 4 +- templates/backoffice/index.html.twig | 2 +- templates/backoffice/quiz.html.twig | 201 +++--------------- .../backoffice/quiz/tab_candidates.html.twig | 5 + .../backoffice/quiz/tab_overview.html.twig | 100 +++++++++ .../backoffice/quiz/tab_result.html.twig | 78 +++++++ templates/quiz/select_season.html.twig | 2 +- tests/Repository/QuizRepositoryTest.php | 2 +- tests/Security/Voter/SeasonVoterTest.php | 2 +- translations/messages+intl-icu.nl.xliff | 90 ++++---- 17 files changed, 290 insertions(+), 224 deletions(-) create mode 100644 .idea/db-forest-config.xml create mode 100644 config/packages/maker.yaml create mode 100644 templates/backoffice/quiz/tab_candidates.html.twig create mode 100644 templates/backoffice/quiz/tab_overview.html.twig create mode 100644 templates/backoffice/quiz/tab_result.html.twig diff --git a/.idea/db-forest-config.xml b/.idea/db-forest-config.xml new file mode 100644 index 0000000..97ceafb --- /dev/null +++ b/.idea/db-forest-config.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/config/packages/maker.yaml b/config/packages/maker.yaml new file mode 100644 index 0000000..aebcc27 --- /dev/null +++ b/config/packages/maker.yaml @@ -0,0 +1,6 @@ +# yaml-language-server: $schema=../../vendor/symfony/dependency-injection/Loader/schema/services.schema.json +when@dev: + maker: + root_namespace: 'Tvdt' + generate_final_classes: true + generate_final_entities: false diff --git a/src/Controller/Backoffice/QuizController.php b/src/Controller/Backoffice/QuizController.php index c54c872..bc0dd7a 100644 --- a/src/Controller/Backoffice/QuizController.php +++ b/src/Controller/Backoffice/QuizController.php @@ -76,7 +76,7 @@ class QuizController extends AbstractController { try { $this->quizRepository->clearQuiz($quiz); - $this->addFlash('success', $this->translator->trans('Quiz cleared')); + $this->addFlash('success', $this->translator->trans('quiz cleared')); } catch (ErrorClearingQuizException) { $this->addFlash('error', $this->translator->trans('Error clearing quiz')); } @@ -94,7 +94,7 @@ class QuizController extends AbstractController { $this->quizRepository->deleteQuiz($quiz); - $this->addFlash('success', $this->translator->trans('Quiz deleted')); + $this->addFlash('success', $this->translator->trans('quiz deleted')); return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $quiz->season->seasonCode]); } diff --git a/src/Controller/Backoffice/SeasonController.php b/src/Controller/Backoffice/SeasonController.php index 198ca9a..0e76b52 100644 --- a/src/Controller/Backoffice/SeasonController.php +++ b/src/Controller/Backoffice/SeasonController.php @@ -105,7 +105,7 @@ class SeasonController extends AbstractController $this->em->persist($quiz); $this->em->flush(); - $this->addFlash(FlashType::Success, $this->translator->trans('Quiz Added!')); + $this->addFlash(FlashType::Success, $this->translator->trans('quiz Added!')); return $this->redirectToRoute('tvdt_backoffice_season', ['seasonCode' => $season->seasonCode]); } diff --git a/src/Controller/QuizController.php b/src/Controller/QuizController.php index 07412bf..d23d903 100644 --- a/src/Controller/QuizController.php +++ b/src/Controller/QuizController.php @@ -118,7 +118,7 @@ final class QuizController extends AbstractController // Keep creating flash here based on the return type of service call if (!$question instanceof Question) { - $this->addFlash(FlashType::Success, $this->translator->trans('Quiz completed')); + $this->addFlash(FlashType::Success, $this->translator->trans('quiz completed')); return $this->redirectToRoute('tvdt_quiz_enter_name', ['seasonCode' => $season->seasonCode]); } diff --git a/src/DataFixtures/KrtekFixtures.php b/src/DataFixtures/KrtekFixtures.php index 29cfb9c..7442e5f 100644 --- a/src/DataFixtures/KrtekFixtures.php +++ b/src/DataFixtures/KrtekFixtures.php @@ -56,7 +56,7 @@ final class KrtekFixtures extends Fixture implements FixtureGroupInterface private function createQuiz1(Season $season): Quiz { $quiz = new Quiz(); - $quiz->name = 'Quiz 1'; + $quiz->name = 'quiz 1'; $quiz->season = $season; $q = new Question(); @@ -223,7 +223,7 @@ final class KrtekFixtures extends Fixture implements FixtureGroupInterface private function createQuiz2(Season $season): Quiz { $quiz = new Quiz(); - $quiz->name = 'Quiz 2'; + $quiz->name = 'quiz 2'; $quiz->season = $season; $q = new Question(); diff --git a/src/Form/UploadQuizFormType.php b/src/Form/UploadQuizFormType.php index 71a163f..6408ab5 100644 --- a/src/Form/UploadQuizFormType.php +++ b/src/Form/UploadQuizFormType.php @@ -22,11 +22,11 @@ class UploadQuizFormType extends AbstractType { $builder ->add('name', TextType::class, [ - 'label' => $this->translator->trans('Quiz name'), + 'label' => $this->translator->trans('quiz name'), 'translation_domain' => false, ]) ->add('sheet', FileType::class, [ - 'label' => $this->translator->trans('Quiz (xlsx)'), + 'label' => $this->translator->trans('quiz (xlsx)'), 'mapped' => false, 'required' => true, 'translation_domain' => false, diff --git a/src/Repository/QuizCandidateRepository.php b/src/Repository/QuizCandidateRepository.php index da50c62..9cb335f 100644 --- a/src/Repository/QuizCandidateRepository.php +++ b/src/Repository/QuizCandidateRepository.php @@ -38,7 +38,7 @@ class QuizCandidateRepository extends ServiceEntityRepository { $quizCandidate = $this->findOneBy(['candidate' => $candidate, 'quiz' => $quiz]); if (!$quizCandidate instanceof QuizCandidate) { - throw new \InvalidArgumentException('Quiz candidate not found'); + throw new \InvalidArgumentException('quiz candidate not found'); } $quizCandidate->corrections = $corrections; @@ -49,7 +49,7 @@ class QuizCandidateRepository extends ServiceEntityRepository { $quizCandidate = $this->findOneBy(['candidate' => $candidate, 'quiz' => $quiz]); if (!$quizCandidate instanceof QuizCandidate) { - throw new \InvalidArgumentException('Quiz candidate not found'); + throw new \InvalidArgumentException('quiz candidate not found'); } $quizCandidate->penaltySeconds = $penalty; diff --git a/templates/backoffice/index.html.twig b/templates/backoffice/index.html.twig index 43afa5b..2ef1bfe 100644 --- a/templates/backoffice/index.html.twig +++ b/templates/backoffice/index.html.twig @@ -19,7 +19,7 @@ {{ 'Owner(s)'|trans }} {% endif %} {{ 'Name'|trans }} - {{ 'Active Quiz'|trans }} + {{ 'Active quiz'|trans }} {{ 'Season Code'|trans }} {{ 'Manage'|trans }} diff --git a/templates/backoffice/quiz.html.twig b/templates/backoffice/quiz.html.twig index 4e7cc2e..f3cbc99 100644 --- a/templates/backoffice/quiz.html.twig +++ b/templates/backoffice/quiz.html.twig @@ -4,179 +4,38 @@ {% block body %}

{{ 'Quiz'|trans }}: {{ quiz.season.name }} - {{ quiz.name }}

-
- {{ 'Make active'|trans }} - {% if quiz is same as (season.activeQuiz) %} - {{ 'Deactivate Quiz'|trans }} - {% endif %} - - -
- -
-

{{ 'Questions'|trans }}

-
- {%~ for question in quiz.questions ~%} -
-

- -

-
-
-
    - {%~ for answer in question.answers %} - {{ answer.text -}} - {%~ else %} - {{ 'There are no answers for this question'|trans -}} - {%~ endfor %} -
-
-
-
- {% else %} - {{ 'EMPTY'|trans }} - {% endfor %} + +
+
+ {% include 'backoffice/quiz/tab_overview.html.twig' %}
-
-
-

{{ 'Score'|trans }}

- - - {# Modal Clear #} - - - {# Modal Delete #} -