plugin/exo/Controller/Api/AttemptController.php
public function startAction(Exercise $exercise, User $user = null)
    {
        $this->assertHasPermission('OPEN', $exercise);

        if (!$this->isAdmin($exercise) && !$this->attemptManager->canPass($exercise, $user)) {
            return new JsonResponse([
                'message' => $exercise->getAttemptsReachedMessage(),
                'accessErrors' => $this->attemptManager->getErrors($exercise, $user),
                'lastAttempt' => $this->paperManager->serialize(
                    $this->attemptManager->getLastPaper($exercise, $user)
                ),
            ], 403);
        }

        return new JsonResponse($this->paperManager->serialize(
            $this->attemptManager->startOrContinue($exercise, $user)
        ));
    }
public function startAction(Exercise $exercise, User $user = null)
    {
        $this->assertHasPermission('OPEN', $exercise);

        if (!$this->isAdmin($exercise) && !$this->attemptManager->canPass($exercise, $user)) {
            return new JsonResponse([
                'message' => $exercise->getAttemptsReachedMessage(),
                'accessErrors' => $this->attemptManager->getErrors($exercise, $user),
                'lastAttempt' => $this->paperManager->serialize(
                    $this->attemptManager->getLastPaper($exercise, $user)
                ),
            ], 403);
        }

        return new JsonResponse($this->paperManager->serialize(
            $this->attemptManager->startOrContinue($exercise, $user)
        ));
    }
public function startAction ( Exercise $ exercise , User $ user = null ) { $ this -> assertHasPermission ( 'OPEN' , $ exercise ) ; if ( ! $ this -> isAdmin ( $ exercise ) && ! $ this -> attemptManager -> canPass ( $ exercise , $ user ) ) { return new JsonResponse ( [ 'message' => $ exercise -> getAttemptsReachedMessage ( ) , 'accessErrors' => $ this -> attemptManager -> getErrors ( $ exercise , $ user ) , 'lastAttempt' => $ this -> paperManager -> serialize ( $ this -> attemptManager -> getLastPaper ( $ exercise , $ user ) ) , ] , 403 ) ; } return new JsonResponse ( $ this -> paperManager -> serialize ( $ this -> attemptManager -> startOrContinue ( $ exercise , $ user ) ) ) ; }
Opens an exercise, creating a new paper or re-using an unfinished one.
Also check that max attempts are not reached if needed.

@EXT\Route("", name="exercise_attempt_start")
@EXT\Method("POST")
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=true})

@param Exercise $exercise
@param User     $user

@return JsonResponse
Opens an exercise creating a new paper or re - using an unfinished one . Also check that max attempts are not reached if needed .