feat: Quiz 수정시 문제 추가 기능 구현

This commit is contained in:
kgc91747 2024-08-05 16:59:14 +09:00
parent d494e1f1b9
commit 3c5909926b
8 changed files with 16 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -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<MultipartFile> 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()) {

View File

@ -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

View File

@ -11,7 +11,7 @@ import java.util.List;
@AllArgsConstructor
public class QuizUpdateRequest {
private long id;
private Long id;
private String question;