Merge branch 'be/Quiz' into 'backend'

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

See merge request s11-webmobile1-sub2/S11P12A701!54
This commit is contained in:
박정민 2024-08-05 17:00:51 +09:00
commit a63af73773
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; private final JWTUtil jwtUtil;
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @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 { , @RequestPart(value = "images", required = false) List<MultipartFile> images) throws IOException {
long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
@ -81,10 +81,20 @@ public class QuizController {
} }
int imageIdx = 0; int imageIdx = 0;
for (QuizUpdateRequest quizUpdateRequest : quizSetUpdateRequest.getQuizzes()) { for (QuizUpdateRequest quizUpdateRequest : quizSetUpdateRequest.getQuizzes()) {
if (quizUpdateRequest.getId() == null) {
QuizCreateRequest quizCreateRequest = QuizCreateRequest.builder()
.question(quizUpdateRequest.getQuestion())
.answer(quizUpdateRequest.getAnswer())
.choices(quizUpdateRequest.getChoices())
.build();
quizService.createQuiz(quizset, quizCreateRequest, images.get(imageIdx++));
} else {
quizService.updateQuiz(quizUpdateRequest, images.get(imageIdx++)); quizService.updateQuiz(quizUpdateRequest, images.get(imageIdx++));
quizUpdatedCheckMap.put(quizUpdateRequest.getId(), true); quizUpdatedCheckMap.put(quizUpdateRequest.getId(), true);
} }
}
for (Long quizId : quizUpdatedCheckMap.keySet()) { for (Long quizId : quizUpdatedCheckMap.keySet()) {
if (!quizUpdatedCheckMap.get(quizId)) { if (!quizUpdatedCheckMap.get(quizId)) {

View File

@ -1,11 +1,13 @@
package com.edufocus.edufocus.quiz.entity; package com.edufocus.edufocus.quiz.entity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
@Builder
@Getter @Getter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor

View File

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