forked from audrey/intranet
remove useless text
This commit is contained in:
parent
d5a73ed2b2
commit
fe23f9b430
@ -7,7 +7,8 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use jv\intranet\Types\NavbarItem;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class SafetyController extends AbstractController
|
class SafetyController extends AbstractController
|
||||||
{
|
{
|
||||||
@ -19,15 +20,29 @@ class SafetyController extends AbstractController
|
|||||||
return $this->render('Training/Safety/safetyHome.html.twig',['header' => $headerFile, 'content' => $contentFile]);
|
return $this->render('Training/Safety/safetyHome.html.twig',['header' => $headerFile, 'content' => $contentFile]);
|
||||||
}
|
}
|
||||||
#[Route('/training/safety/quiz')]
|
#[Route('/training/safety/quiz')]
|
||||||
public function Quiz(Request $request)
|
public function Quiz(Request $request, LoggerInterface $log)
|
||||||
{
|
{
|
||||||
$headerFile = Yaml::parseFile('../config/portalLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP);
|
$headerFile = Yaml::parseFile('../config/portalLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP);
|
||||||
|
|
||||||
$form = $this->createForm(SafetyQuizType::class);
|
$form = $this->createForm(SafetyQuizType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
if($form->isSubmitted())
|
if($form->isSubmitted() && $form->isValid())
|
||||||
{
|
{
|
||||||
//TODO: Process quiz submissions. Calculate score & return a printable results page
|
//TODO: Process quiz submissions. Calculate score & return a printable results page
|
||||||
|
$data = $form->getData();
|
||||||
|
$testerName = $data['Name'];
|
||||||
|
unset($data['Name']);
|
||||||
|
$correctAnswers = 0;
|
||||||
|
foreach($data as $question)
|
||||||
|
{
|
||||||
|
if($question)
|
||||||
|
{
|
||||||
|
$correctAnswers++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$log->Debug($testerName . ' quiz answers correct: ' . $correctAnswers);
|
||||||
|
return $this->render('Training/Safety/quizResults.html.twig', ['header'=>$headerFile, 'testerName'=>$testerName,
|
||||||
|
'correctAnswers'=>$correctAnswers, 'totalAnswers'=>count($data)]);
|
||||||
}
|
}
|
||||||
return $this->render('Training/Safety/SafetyQuiz.html.twig',['header' => $headerFile, 'quiz'=>$form]);
|
return $this->render('Training/Safety/SafetyQuiz.html.twig',['header' => $headerFile, 'quiz'=>$form]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,8 @@ class SafetyQuizType extends AbstractType
|
|||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
|
//Get the user's name
|
||||||
|
$builder->add('Name');
|
||||||
$quizFile = Yaml::parseFile("../config/SafetyQuiz.yaml", 2, 2, Yaml::PARSE_OBJECT_FOR_MAP);
|
$quizFile = Yaml::parseFile("../config/SafetyQuiz.yaml", 2, 2, Yaml::PARSE_OBJECT_FOR_MAP);
|
||||||
//Parse the quiz file & register each question as a multiple-choice form input
|
//Parse the quiz file & register each question as a multiple-choice form input
|
||||||
foreach($quizFile['Questions'] as $key => $value)
|
foreach($quizFile['Questions'] as $key => $value)
|
||||||
|
|||||||
@ -15,9 +15,8 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h4>Complete the Safety Quiz below</h4>
|
<h4>Complete the Safety Quiz below</h4>
|
||||||
<p>When you're finished, click 'Submit' at the bottom and print your results.
|
<p>When you're finished, click 'Submit' at the bottom and print your results.
|
||||||
<br>You may retake this quiz as many times as you need.
|
<br>You may retake this quiz as many times as you need.</p> {#TODO: figure out what the minimum # of correct answers is #}
|
||||||
<br>To pass this quiz you must answer NaN% of questions correctly.</p> {#TODO: figure out what the correct number is #}
|
|
||||||
{% form_theme quiz 'bootstrap_5_layout.html.twig' %}
|
{% form_theme quiz 'bootstrap_5_layout.html.twig' %}
|
||||||
{{ form(quiz )}}
|
{{ form(quiz )}}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
27
templates/Training/Safety/quizResults.html.twig
Normal file
27
templates/Training/Safety/quizResults.html.twig
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
{{ include('_header.html.twig') }}
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- Navigation -->
|
||||||
|
<div class="siteNavbar">
|
||||||
|
<ul class="list-group list-group-horizontal-md">
|
||||||
|
{% for item in header.Navbar %}
|
||||||
|
<h3 class="navitem"><a class=" list-group-item list-group-item-action text-decoration-none h-100 text-white border-0" href="{{item.url}}">{{item.title}}</a></h3>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<h4>Congratulations, you've completed the quiz!</h4>
|
||||||
|
<p>Print this page and show it to your supervisor or instructor.</p> {#TODO: figure out what the minimum # of correct answers is #}
|
||||||
|
|
||||||
|
<div class="safetyQuiz-completion card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h3>Certificate of Completion</h3>
|
||||||
|
<h4>{{ testerName }} <br> Completed the J.V. Safety Quiz on {{ 'now'|date('m/d/y')}}</h4>
|
||||||
|
<h5>With a score of {{ correctAnswers }}/{{ totalAnswers }} questions answered correctly.</h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
Loading…
x
Reference in New Issue
Block a user