move question count calculation

This commit is contained in:
Audrey Jensen 2023-09-27 21:30:52 +00:00
parent c5999fb6e7
commit 4676ec9b55

View File

@ -49,7 +49,7 @@ class SafetyController extends AbstractController
} }
} }
$log->Debug($testerName . ' quiz answers correct: ' . $correctAnswers); $log->Debug($testerName . ' quiz answers correct: ' . $correctAnswers);
$this->sendQuizResults($correctAnswers, count($data), $form, $mailer, $log); $this->sendQuizResults($correctAnswers, $form, $mailer, $log);
return $this->render('Training/Safety/quizResults.html.twig', ['testerName'=>$testerName, return $this->render('Training/Safety/quizResults.html.twig', ['testerName'=>$testerName,
'correctAnswers'=>$correctAnswers, 'totalAnswers'=>count($data)]); 'correctAnswers'=>$correctAnswers, 'totalAnswers'=>count($data)]);
} }
@ -115,7 +115,7 @@ class SafetyController extends AbstractController
return new Response($header . $navButtons . $contents); return new Response($header . $navButtons . $contents);
} }
//Send an email with the quiz results //Send an email with the quiz results
public function sendQuizResults(int $answersCorrect, int $totalQuestions, FormInterface $submittedQuiz, MailerInterface $mailer, LoggerInterface $log) public function sendQuizResults(int $answersCorrect, FormInterface $submittedQuiz, MailerInterface $mailer, LoggerInterface $log)
{ {
//Fetch array of mail inboxes to send messages to. //Fetch array of mail inboxes to send messages to.
//If env var doesn't exist then fail gracefully //If env var doesn't exist then fail gracefully
@ -170,7 +170,7 @@ class SafetyController extends AbstractController
->context([ ->context([
'submission' => $quiz, 'submission' => $quiz,
'answersCorrect' => $answersCorrect, 'answersCorrect' => $answersCorrect,
'totalQuestions' => $totalQuestions, 'totalQuestions' => count($questionKeys),
'submitterName' => $submittedData['Name']]) 'submitterName' => $submittedData['Name']])
; ;
try try