diff --git a/backend/backend/src/main/resources/images/30d65b76-54cb-42ad-a53e-04691c6401ba_testimg3.jpg b/backend/backend/src/main/resources/images/30d65b76-54cb-42ad-a53e-04691c6401ba_testimg3.jpg new file mode 100644 index 0000000..c53ac5e Binary files /dev/null and b/backend/backend/src/main/resources/images/30d65b76-54cb-42ad-a53e-04691c6401ba_testimg3.jpg differ diff --git a/backend/backend/src/main/resources/images/427dc7fc-d22e-43a3-8fde-69bace73ee6a_lectureImage.jpg b/backend/backend/src/main/resources/images/427dc7fc-d22e-43a3-8fde-69bace73ee6a_lectureImage.jpg new file mode 100644 index 0000000..c53ac5e Binary files /dev/null and b/backend/backend/src/main/resources/images/427dc7fc-d22e-43a3-8fde-69bace73ee6a_lectureImage.jpg differ diff --git a/backend/backend/src/main/resources/images/45b6ea03-017a-4d3c-9c5c-aa0a2ada53f9_testimg1.jpg b/backend/backend/src/main/resources/images/45b6ea03-017a-4d3c-9c5c-aa0a2ada53f9_testimg1.jpg new file mode 100644 index 0000000..c53ac5e Binary files /dev/null and b/backend/backend/src/main/resources/images/45b6ea03-017a-4d3c-9c5c-aa0a2ada53f9_testimg1.jpg differ diff --git a/backend/backend/src/main/resources/images/7fd1090b-af1a-4f48-885c-30bf45d63778_lectureImage.jpg b/backend/backend/src/main/resources/images/7fd1090b-af1a-4f48-885c-30bf45d63778_lectureImage.jpg new file mode 100644 index 0000000..c53ac5e Binary files /dev/null and b/backend/backend/src/main/resources/images/7fd1090b-af1a-4f48-885c-30bf45d63778_lectureImage.jpg differ diff --git a/backend/backend/src/main/resources/images/a69e91c4-5108-41ad-96b9-9d25d5353c73_lectureImage.jpg b/backend/backend/src/main/resources/images/a69e91c4-5108-41ad-96b9-9d25d5353c73_lectureImage.jpg new file mode 100644 index 0000000..c53ac5e Binary files /dev/null and b/backend/backend/src/main/resources/images/a69e91c4-5108-41ad-96b9-9d25d5353c73_lectureImage.jpg differ diff --git a/backend/src/main/java/com/edufocus/edufocus/quiz/controller/QuizController.java b/backend/src/main/java/com/edufocus/edufocus/quiz/controller/QuizController.java index 7eda70f..49b009d 100644 --- a/backend/src/main/java/com/edufocus/edufocus/quiz/controller/QuizController.java +++ b/backend/src/main/java/com/edufocus/edufocus/quiz/controller/QuizController.java @@ -30,7 +30,7 @@ public class QuizController { private final JWTUtil jwtUtil; @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity createQuizSet(@RequestHeader("Authzation") String accessToken, @RequestPart QuizSetCreateRequest quizSetCreateRequest + public ResponseEntity createQuizSet(@RequestHeader("Authorization") String accessToken, @RequestPart QuizSetCreateRequest quizSetCreateRequest , @RequestPart(value = "images", required = false) List images) throws IOException { long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); @@ -81,9 +81,19 @@ public class QuizController { } int imageIdx = 0; for (QuizUpdateRequest quizUpdateRequest : quizSetUpdateRequest.getQuizzes()) { - quizService.updateQuiz(quizUpdateRequest, images.get(imageIdx++)); + if (quizUpdateRequest.getId() == null) { + QuizCreateRequest quizCreateRequest = QuizCreateRequest.builder() + .question(quizUpdateRequest.getQuestion()) + .answer(quizUpdateRequest.getAnswer()) + .choices(quizUpdateRequest.getChoices()) + .build(); - quizUpdatedCheckMap.put(quizUpdateRequest.getId(), true); + quizService.createQuiz(quizset, quizCreateRequest, images.get(imageIdx++)); + } else { + quizService.updateQuiz(quizUpdateRequest, images.get(imageIdx++)); + + quizUpdatedCheckMap.put(quizUpdateRequest.getId(), true); + } } for (Long quizId : quizUpdatedCheckMap.keySet()) { diff --git a/backend/src/main/java/com/edufocus/edufocus/quiz/entity/QuizCreateRequest.java b/backend/src/main/java/com/edufocus/edufocus/quiz/entity/QuizCreateRequest.java index 9ac60bd..d2a254d 100644 --- a/backend/src/main/java/com/edufocus/edufocus/quiz/entity/QuizCreateRequest.java +++ b/backend/src/main/java/com/edufocus/edufocus/quiz/entity/QuizCreateRequest.java @@ -1,11 +1,13 @@ package com.edufocus.edufocus.quiz.entity; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import java.util.List; +@Builder @Getter @NoArgsConstructor @AllArgsConstructor diff --git a/backend/src/main/java/com/edufocus/edufocus/quiz/entity/QuizUpdateRequest.java b/backend/src/main/java/com/edufocus/edufocus/quiz/entity/QuizUpdateRequest.java index f4cdc4f..7fa153d 100644 --- a/backend/src/main/java/com/edufocus/edufocus/quiz/entity/QuizUpdateRequest.java +++ b/backend/src/main/java/com/edufocus/edufocus/quiz/entity/QuizUpdateRequest.java @@ -11,7 +11,7 @@ import java.util.List; @AllArgsConstructor public class QuizUpdateRequest { - private long id; + private Long id; private String question;