Merge branch 'training-improvements'

This commit is contained in:
Audrey Jensen 2023-07-19 20:37:20 +00:00
commit c52570c16c
17 changed files with 84 additions and 5 deletions

View File

@ -46,14 +46,59 @@ class SafetyController extends AbstractController
return $this->render('Training/Safety/SafetyQuiz.html.twig',['quiz'=>$form]);
}
#[Route('/Training/Safety/Topics/{topic?}')]
public function Topics(?string $topic) : Response
public function Topics(?string $topic, LoggerInterface $log) : Response
{
//We want to show the safety homepage if this is blank
if($topic == null)
{
return $this->redirectToRoute('safetyHome');
}
//We need to get the previous and next topics for nav buttons
//FEATURING: Regret for not having mapped this YAML file to a data model that would have saved myself a lot of trouble and spaghetti
$contentFile = Yaml::parseFile('../config/safetyLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP);
$previousTopic = $nextTopic = ""; //declare ahead of time for scoping
$arrayKeys = array_keys($contentFile['Cards']);
foreach($arrayKeys as $key)
{
$card = $contentFile['Cards'][$key];
for($i = 0; $i < count($card); $i++)
{
$entry = $card[$i];
$cardIndex = array_search($key, $arrayKeys);
if($entry['url'] == $topic)
{
//Assign Previous Topic
if($i > 0)
{
$previousTopic = $contentFile['Cards'][$arrayKeys[$cardIndex]][$i-1];
}
else if($cardIndex > 0) //there's a previous card, use the last entry in it
{
//NOTE: Should be fine to use end, at this point we shouldn't care about the array's internal pointer, we're done iterating
$previousTopic = end($contentFile['Cards'][$arrayKeys[$cardIndex-1]]);
}
//Assign Next Topic
if($i < count($card)-1) //Next topic should be within the same card
{
$nextTopic = $contentFile['Cards'][$arrayKeys[$cardIndex]][$i+1];
}
else if($cardIndex < count($contentFile['Cards'])-1) //Next topic is not in same card, or does not exist
{
$nextTopic = $contentFile['Cards'][$arrayKeys[$cardIndex+1]][0]; //Set to first entry in next card
}
break 2; //Got what we needed, break out of both for loops
}
}
}
$topic = strtolower($topic);
return $this->render('Training/Safety/Topics/'.$topic.".html.twig");
//TODO: Insert back button
$navButtonData = ['previous'=> $previousTopic, 'next' => $nextTopic];
$contents = $this->render('Training/Safety/Topics/'.$topic.".html.twig", $navButtonData);
$navButtons = $this->render('Training/Safety/navButtons.html.twig',$navButtonData);
return new Response($contents . $navButtons);
}
}

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Emergency Action Plan</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Crane / Hoist Safety </h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Electrical Safety</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Fire Extinguisher Operation</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Fire Prevention</h2>

View File

@ -2,9 +2,10 @@
<html>
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
{{ include('_navbar.html.twig')}}
<div class="container">
<h2 class="text-bold">General Rules at J.V. Manufacturing, Inc.</h2>
<ul>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Machine Guarding</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Hazard Communication</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Hearing Protection</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Hand & Power Tools</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Personal Protective Equipment (Eyes, Face, Hands, & Feet) </h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Safe Lifting</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Lockout Tagout</h2>

View File

@ -3,6 +3,7 @@
{{ include('_header.html.twig') }}
{{ include('_navbar.html.twig')}}
{{ include('Training/Safety/navButtons.html.twig') }}
<body>
<div class="container">
<h2 class="text-bold">Welding Safety</h2>

View File

@ -0,0 +1,19 @@
<body>
<div class="container">
<div class="row">
<div class="col">
{% if previous != null %}
<a href="{{previous.url}}">Previous Page: {{previous.title}}</a>
{% endif %}
</div>
<div class="col">
<a href="{{ path('safetyHome')}}">Back</a>
</div>
<div class="col">
{% if next != null %}
<a href="{{next.url}}">Next Page: {{next.title}}</a>
{% endif %}
</div>
</div>
</div>
</body>