public function end(Paper $paper, $finished = true, $generateEvaluation = true)
    {
        $this->om->startFlushSuite();

        if (!$paper->getEnd()) {
            $paper->setEnd(new \DateTime());
        }

        $paper->setInterrupted(!$finished);
        $totalScoreOn = $paper->getExercise()->getTotalScoreOn();
        $score = $this->paperManager->calculateScore($paper, $totalScoreOn);
        $paper->setScore($score);

        if ($generateEvaluation) {
            $this->paperManager->generateResourceEvaluation($paper, $finished);
        }
        $this->om->persist($paper);
        $this->om->endFlushSuite();

        $this->paperManager->checkPaperEvaluated($paper);
    }