Exemple #1
0
 /**
  * @param Test $test
  * @param Explanation $explanation
  * @return boolean
  */
 public function checkExplanation(Test $test, Explanation $explanation)
 {
     if ($this->findExplanation($explanation->getMinRating(), $test) != null or $this->findExplanation($explanation->getMaxRating(), $test) != null) {
         return true;
     }
     return false;
 }
Exemple #2
0
 /**
  * @Security("has_role('ROLE_SUPER_ADMIN')")
  * @Route("/testid{id}/test/addExplanation", name="addExplanation")
  */
 public function addExplanationAction(Request $request, $id)
 {
     $test = $this->getDoctrine()->getRepository('AppBundle:Test')->find($id);
     $explanation = new Explanation();
     $explanation->setDescription($request->get('_description'));
     $explanation->setMinRating($request->get('_minRating'));
     $explanation->setMaxRating($request->get('_maxRating'));
     if ($this->get('calculate')->checkExplanation($test, $explanation)) {
         return $this->redirectToRoute('testpage', array('id' => $test->getId()));
     }
     $test->addExplanation($explanation);
     $explanation->setTest($test);
     $em = $this->getDoctrine()->getManager();
     $em->persist($explanation);
     $em->persist($test);
     $em->flush();
     return $this->redirectToRoute('testpage', array('id' => $test->getId()));
 }