/** * To link a question with an exercise * * @access public * * @param UJM\ExoBundle\Entity\Exercise $exercise instance of Exercise * @param InteractionQCM or InteractionGraphic or ... $interX * */ public function setExerciseQuestion($exercise, $interX, $order = -1) { $eq = new ExerciseQuestion($exercise, $interX->getInteraction()->getQuestion()); if ($order == -1) { $dql = 'SELECT max(eq.ordre) FROM UJM\\ExoBundle\\Entity\\ExerciseQuestion eq ' . 'WHERE eq.exercise=' . $exercise->getId(); $query = $this->doctrine->getManager()->createQuery($dql); $maxOrdre = $query->getResult(); $eq->setOrdre((int) $maxOrdre[0][1] + 1); } else { $eq->setOrdre($order); } $this->om->persist($eq); $this->om->flush(); }
/** * Docimology * To get array of marks for an exercise. * * * @param UJM\ExoBundle\Entity\Exercise $exercise * * @return float[] */ private function getArrayMarks($exercise) { $paperSer = $this->container->get('ujm.exo_paper'); $em = $this->doctrine->getManager(); if ($exercise->getPickSteps() === 0) { $exoScoreMax = $this->container->get('ujm.exo_exercise')->getExerciseTotalScore($exercise); } $marks = $em->getRepository('UJMExoBundle:Response')->getExerciseMarks($exercise->getId(), 'noteExo'); foreach ($marks as $mark) { if ($exercise->getPickSteps() > 0) { $exoScoreMax = $this->container->get('ujm.exo_paper')->getPaperTotalScore($mark['paper']); } $scoreU = round($mark['noteExo'] / $exoScoreMax * 20, 2); $score = $paperSer->roundUpDown($scoreU); if (isset($tabMarks[(string) $score])) { $tabMarks[(string) $score] += 1; } else { $tabMarks[(string) $score] = 1; } } ksort($tabMarks); return $tabMarks; }