public function save(array $correctedAnswers = [])
    {
        $updatedPapers = [];

        foreach ($correctedAnswers as $index => $correctedAnswer) {
            /** @var Answer $answer */
            $answer = $this->om->getRepository('UJMExoBundle:Attempt\Answer')->findOneBy([
                'uuid' => $correctedAnswer['id'],
            ]);

            if (empty($answer)) {
                throw new InvalidDataException('Submitted answers are invalid', [[
                    'path' => "/{$index}",
                    'message' => 'answer does not exists',
                ]]);
            }

            $question = $answer->getPaper()->getQuestion($answer->getQuestionId());
            $decodedQuestion = $this->itemSerializer->deserialize($question, new Item());

            // Update answer and apply hint penalties
            $this->answerManager->update($decodedQuestion, $answer, $correctedAnswer, true);
            if (!empty($answer->getUsedHints())) {
                $this->applyPenalties($answer);
            }

            $updatedPapers[$answer->getPaper()->getId()] = $answer->getPaper();
        }

        // A first flush is needed because score calculation for the whole paper retrieve scores from DB
        $this->om->flush();

        // Recalculate scores for updated papers
        foreach ($updatedPapers as $paper) {
            $newScore = $this->paperManager->calculateScore($paper);
            $paper->setScore($newScore);
            $this->om->persist($paper);

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

        $this->om->flush();
    }