diff --git a/src/Controller/SafetyController.php b/src/Controller/SafetyController.php index 8cd6cfe..9818f40 100644 --- a/src/Controller/SafetyController.php +++ b/src/Controller/SafetyController.php @@ -1,10 +1,14 @@ render('Training/Safety/safetyHome.html.twig',['header' => $headerFile, 'content' => $contentFile]); } #[Route('/training/safety/quiz')] - public function Quiz() + public function Quiz(Request $request) { + $headerFile = Yaml::parseFile('../config/portalLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP); + $form = $this->createForm(SafetyQuizType::class); + $form->handleRequest($request); + if($form->isSubmitted()) + { + //TODO: Process quiz submissions. Calculate score & return a printable results page + } + return $this->render('Training/Safety/SafetyQuiz.html.twig',['header' => $headerFile, 'quiz'=>$form]); } } \ No newline at end of file diff --git a/src/Form/SafetyQuizType.php b/src/Form/SafetyQuizType.php index 2e4b3e2..af66223 100644 --- a/src/Form/SafetyQuizType.php +++ b/src/Form/SafetyQuizType.php @@ -6,18 +6,28 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\RadioType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; class SafetyQuizType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('q1', ChoiceType::class, [ + ->add('Question_1', ChoiceType::class, [ 'choices' => [ 'Correct' => true, 'False' => false, 'False again' => false - ] + ], + 'expanded' => true + ]) + ->add('Question_2', ChoiceType::class, [ + 'choices' => [ + 'Correct' => true, + 'False' => false, + 'False again' => false + ], + 'expanded' => true ]) ; } diff --git a/templates/Training/Safety/SafetyQuiz.html.twig b/templates/Training/Safety/SafetyQuiz.html.twig new file mode 100644 index 0000000..9d55434 --- /dev/null +++ b/templates/Training/Safety/SafetyQuiz.html.twig @@ -0,0 +1,23 @@ + + + +{{ include('_header.html.twig') }} + +
+ + +When you're finished, click 'Submit' at the bottom and print your results.
+
You may retake this quiz as many times as you need.
+
To pass this quiz you must answer NaN% of questions correctly.