Merge branch 'be/Quiz' into 'backend'
feat: Quiz 수정시 문제 추가 기능 구현 See merge request s11-webmobile1-sub2/S11P12A701!54
This commit is contained in:
commit
a63af73773
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 |
@ -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()) {
|
||||
|
@ -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
|
||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class QuizUpdateRequest {
|
||||
|
||||
private long id;
|
||||
private Long id;
|
||||
|
||||
private String question;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user