public int checkExam(Exam originalExam, Exam answeredExam) {
        assert (originalExam.getId().equals(answeredExam.getId()));

        int correctAnswers = 0;

        if (answeredExam.getQuestions() == null || answeredExam.getQuestions().isEmpty()) {
            return correctAnswers;
        }

        Map<String, Question> answeredQuestions = new HashMap<>();
        answeredExam.getQuestions().stream().forEach(q -> answeredQuestions.put(q.getId(), q));

        for (Question originalQuestion : originalExam.getQuestions()) {
            Question answeredQuestion = answeredQuestions.get(originalQuestion.getId());
            if (answeredQuestion != null && checkQuestion(originalQuestion, answeredQuestion)) {
                correctAnswers += 1;
            }
        }
        return correctAnswers;
    }