/** * Implements the abstract method * * @access protected * * @param \UJM\ExoBundle\Entity\InteractionGraphic $interGraph */ protected function onSuccessAdd($interGraph) { $interGraph->getInteraction()->getQuestion()->setDateCreate(new \Datetime()); // Set Creation Date to today $interGraph->getInteraction()->getQuestion()->setUser($this->user); // add the user to the question $interGraph->getInteraction()->setType('InteractionGraphic'); // set the type of 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->setHeight($height); $interGraph->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->getInteraction()->getQuestion()); $this->em->persist($interGraph->getInteraction()); for ($i = 0; $i < $lengthCoord; $i++) { $this->em->persist($allCoords[$i]); } $this->persistHints($interGraph); $this->em->flush(); $this->addAnExercise($interGraph); $this->duplicateInter($interGraph); }