/**
  * @param \_OurBrand_\Quiz\Domain\Model\Exercise $exercise
  * @return void
  */
 public function deleteAction($exercise)
 {
     if (!$this->accessHelper->canUserEditQuiz($this->currentUser, $exercise->getQuiz())) {
         $this->throwStatus(403);
     }
     $number = $exercise->getNumber();
     $quiz = $exercise->getQuiz();
     $prevExercise = null;
     $quiz->removeExercise($exercise);
     $quiz->touch();
     if ($quiz->getExercises()->count() > 0) {
         $prevExercise = $quiz->getExerciseByNumber($number > 0 ? $number - 1 : 0);
     }
     $this->quizRepository->update($quiz);
     $this->persistenceManager->persistAll();
     if ($prevExercise) {
         $this->redirect('edit', 'exercise', null, array('exercise' => $prevExercise));
     } else {
         $this->redirect('edit', 'quiz', null, array('quiz' => $quiz));
     }
 }