public function startOrContinue(Exercise $exercise, User $user = null)
    {
        $paper = null; // The paper to use for the new attempt

        // If it's not an anonymous, load the previous unfinished papers
        $unfinishedPapers = (null !== $user) ? $this->paperRepository->findUnfinishedPapers($exercise, $user) : [];
        if (!empty($unfinishedPapers)) {
            if ($exercise->isInterruptible()) {
                // Continue a previous attempt
                $paper = $unfinishedPapers[0];
            } else {
                // Close the paper
                $this->end($unfinishedPapers[0], false);
            }
        }

        // Start a new attempt is needed
        if (empty($paper)) {
            // Get the last paper for generation
            $lastPaper = $this->getLastPaper($exercise, $user);

            // Generate a new paper
            $paper = $this->paperGenerator->create($exercise, $user, $lastPaper);

            // Save the new paper
            $this->om->persist($paper);
            $this->om->flush();
        }

        return $paper;
    }