/**
  * To control the max attemps, allow to know if an user can again execute an exercise
  *
  * @access public
  *
  * @param \UJM\ExoBundle\Entity\Exercise $exercise
  * @param \UJM\ExoBundle\Entity\User $user
  * @param boolean $exoAdmin
  *
  * @return boolean
  */
 public function controlMaxAttemps($exercise, $user, $exoAdmin)
 {
     if ($exoAdmin === false && $exercise->getMaxAttempts() > 0 && $exercise->getMaxAttempts() <= $this->getNbPaper($user->getId(), $exercise->getId(), true)) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Exports an exercise in a JSON-encodable format.
  *
  * @param Exercise $exercise
  *
  * @return array
  */
 public function exportExerciseMinimal(Exercise $exercise)
 {
     return ['id' => $exercise->getId(), 'meta' => $this->exportMetadata($exercise)];
 }
 /**
  * @param Exercise $exercise
  * @param string   $grade
  */
 public function __construct(Exercise $exercise, $grade)
 {
     $details = array('exercise' => array('id' => $exercise->getId(), 'name' => $exercise->getName(), 'title' => $exercise->getTitle()), 'result' => $grade['scorePaper'], 'resultMax' => $grade['maxExoScore']);
     parent::__construct($exercise->getResourceNode(), $details);
 }