コード例 #1
0
 /**
  * Returns one paper.
  * Also includes the complete definition and solution of each question
  * associated with the exercise.
  *
  * @EXT\Route("/papers/{id}", name="exercise_export_paper")
  * @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=true})
  *
  * @param Paper $paper
  * @param User  $user
  *
  * @return JsonResponse
  */
 public function exportPaperAction(Paper $paper, User $user = null)
 {
     // ATTENTION : As is, anonymous have access to all the other anonymous Papers !!!
     if (!$this->isAdmin($paper->getExercise()) && $paper->getUser() !== $user) {
         // Only administrator or the User attached can see a Paper
         throw new AccessDeniedHttpException();
     }
     return new JsonResponse(['questions' => $this->paperManager->exportPaperQuestions($paper, $this->isAdmin($paper->getExercise()), true), 'paper' => $this->paperManager->exportPaper($paper, $this->isAdmin($paper->getExercise()))]);
 }