/**
  * Implements the abstract method.
  *
  *
  * @param \UJM\ExoBundle\Entity\InteractionGraphic $interGraph
  */
 protected function onSuccessAdd($interGraph)
 {
     $interGraph->getQuestion()->setDateCreate(new \Datetime());
     // Set Creation Date to today
     $interGraph->getQuestion()->setUser($this->user);
     // add the user to the question
     if ($this->request != null) {
         $width = $this->request->get('imagewidth');
         // Get the width of the image
         $height = $this->request->get('imageheight');
         // Get the height of the image
         $interGraph->getPicture()->setHeight($height);
         $interGraph->getPicture()->setWidth($width);
         $coords = $this->request->get('coordsZone');
         // Get the answer zones
         $coord = preg_split('[##]', $coords);
         // Split all informations of one answer zones into a cell
         $lengthCoord = count($coord) - 1;
         // Number of answer zones
         $allCoords = $this->persitNewCoords($coord, $interGraph, $lengthCoord);
     } else {
         $allCoords = $interGraph->getCoords();
         $lengthCoord = count($allCoords);
     }
     $this->em->persist($interGraph);
     $this->em->persist($interGraph->getQuestion());
     $interGraph->setQuestion($interGraph->getQuestion());
     for ($i = 0; $i < $lengthCoord; ++$i) {
         $this->em->persist($allCoords[$i]);
     }
     $this->persistHints($interGraph);
     $this->em->flush();
     $this->addAnExercise($interGraph);
     $this->duplicateInter($interGraph);
 }
Ejemplo n.º 2
0
 /**
  * implement the abstract method
  * Get score max possible for a graphic question.
  *
  * @param \UJM\ExoBundle\Entity\InteractionGraphic $interGraph
  *
  * @return float
  */
 public function maxScore($interGraph = null)
 {
     $em = $this->doctrine->getManager();
     $scoreMax = 0;
     $rightCoords = $em->getRepository('UJMExoBundle:Coords')->findBy(['interactionGraphic' => $interGraph->getId()]);
     foreach ($rightCoords as $score) {
         $scoreMax += $score->getScoreCoords();
     }
     return $scoreMax;
 }