diff --git a/backend/src/main/java/cz/scrumdojo/quizmaster/quiz/QuizQuestionController.java b/backend/src/main/java/cz/scrumdojo/quizmaster/quiz/QuizQuestionController.java index 8ec75f5..0fb2ade 100644 --- a/backend/src/main/java/cz/scrumdojo/quizmaster/quiz/QuizQuestionController.java +++ b/backend/src/main/java/cz/scrumdojo/quizmaster/quiz/QuizQuestionController.java @@ -44,14 +44,6 @@ public ResponseEntity answerQuestion(@PathVariable Integer id, @PathVar return response(findQuestion(id).map(QuizQuestion.isCorrectAnswer(index))); } - @Transactional - @PostMapping("/quiz-question/{id}/answer") - public ResponseEntity answerQuestionV2(@PathVariable Integer id, @RequestBody List answers) { - int [] answersArray = answers.stream().mapToInt(Integer::intValue).toArray(); - Optional> wrongAnswers = findQuestion(id).map(QuizQuestion.getWrongAnswers(answersArray)); - return response(Optional.of(wrongAnswers.get().isEmpty())); - } - @Transactional @PostMapping("/quiz-question/{id}/answerv3") public ResponseEntity answerQuestionV3(@PathVariable Integer id, @RequestBody List answers) { diff --git a/backend/src/test/java/cz/scrumdojo/quizmaster/quiz/QuizQuestionControllerTest.java b/backend/src/test/java/cz/scrumdojo/quizmaster/quiz/QuizQuestionControllerTest.java index bca5754..1e33977 100644 --- a/backend/src/test/java/cz/scrumdojo/quizmaster/quiz/QuizQuestionControllerTest.java +++ b/backend/src/test/java/cz/scrumdojo/quizmaster/quiz/QuizQuestionControllerTest.java @@ -57,15 +57,6 @@ public void answerQuestion(int answerIdx, boolean isCorrect) { assertEquals(isCorrect, result); } - public void answerQuestionV2(List answerIdx, boolean isCorrect) { - var questionId = quizQuestionController.saveQuestion(createQuestion()); - - Boolean result = quizQuestionController.answerQuestionV2(questionId, answerIdx).getBody(); - - assertNotNull(result); - assertEquals(isCorrect, result); - } - @Test public void answerQuestionV3_answerMultipleQuestionsCorrectly() { checkMultipleAnswers(List.of(1,3), true, List.of()); @@ -86,31 +77,16 @@ private void checkMultipleAnswers(List userAnswersIndexes, boolean isCo MultipleAnswersResult result = quizQuestionController.answerQuestionV3(questionId, userAnswersIndexes).getBody(); assertNotNull(result); -// assertEquals(isCorrect, result.getQuestionAnsweredCorrectly()); + assertEquals(isCorrect, result.getQuestionAnsweredCorrectly()); assertEquals(expectedWrongAnswers,result.getWrongAnswers()); } @Test - public void answerQuestionCorrectly() { + public void answerSingleChoiceQuestionCorrectly() { answerQuestion(1, true); } - @Test - public void answerQuestionIncorrectly() { - answerQuestionV2(List.of(0), false); - } - - @Test - public void answerMultipleQuestionsCorrectly() { - answerQuestionV2(List.of(1), true); - } - - @Test - public void answerMultipleQuestionsIncorrectly() { - answerQuestionV2(List.of(0), false); - } - @Test public void answerNonExistingQuestion() { ResponseEntity response = quizQuestionController.answerQuestion(-1, 0);