plugin/exo/Controller/Api/AttemptController.php
public function finishAction(Paper $paper, User $user = null)
    {
        $this->assertHasPermission('OPEN', $paper->getExercise());
        $this->assertHasPaperAccess($paper, $user);

        $this->attemptManager->end($paper, true, !empty($user));
        $userEvaluation = !empty($user) ?
            $this->resourceEvalManager->getResourceUserEvaluation($paper->getExercise()->getResourceNode(), $user) :
            null;

        return new JsonResponse(
            [
                'paper' => $this->paperManager->serialize($paper),
                'userEvaluation' => !empty($userEvaluation) ? $this->userEvalSerializer->serialize($userEvaluation) : null,
            ],
            200
        );
    }
public function finishAction(Paper $paper, User $user = null)
    {
        $this->assertHasPermission('OPEN', $paper->getExercise());
        $this->assertHasPaperAccess($paper, $user);

        $this->attemptManager->end($paper, true, !empty($user));
        $userEvaluation = !empty($user) ?
            $this->resourceEvalManager->getResourceUserEvaluation($paper->getExercise()->getResourceNode(), $user) :
            null;

        return new JsonResponse(
            [
                'paper' => $this->paperManager->serialize($paper),
                'userEvaluation' => !empty($userEvaluation) ? $this->userEvalSerializer->serialize($userEvaluation) : null,
            ],
            200
        );
    }
public function finishAction ( Paper $ paper , User $ user = null ) { $ this -> assertHasPermission ( 'OPEN' , $ paper -> getExercise ( ) ) ; $ this -> assertHasPaperAccess ( $ paper , $ user ) ; $ this -> attemptManager -> end ( $ paper , true , ! empty ( $ user ) ) ; $ userEvaluation = ! empty ( $ user ) ? $ this -> resourceEvalManager -> getResourceUserEvaluation ( $ paper -> getExercise ( ) -> getResourceNode ( ) , $ user ) : null ; return new JsonResponse ( [ 'paper' => $ this -> paperManager -> serialize ( $ paper ) , 'userEvaluation' => ! empty ( $ userEvaluation ) ? $ this -> userEvalSerializer -> serialize ( $ userEvaluation ) : null , ] , 200 ) ; }
Flags a paper as finished.

@EXT\Route("/{id}/end", name="exercise_attempt_finish")
@EXT\Method("PUT")
@EXT\ParamConverter("paper", class="UJMExoBundle:Attempt\Paper", options={"mapping": {"id": "uuid"}})
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=true})

@param Paper $paper
@param User  $user

@return JsonResponse
Flags a paper as finished .