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 8109765..7eda70f 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("Authorization") String accessToken, @RequestPart QuizSetCreateRequest quizSetCreateRequest + public ResponseEntity createQuizSet(@RequestHeader("Authzation") String accessToken, @RequestPart QuizSetCreateRequest quizSetCreateRequest , @RequestPart(value = "images", required = false) List images) throws IOException { long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); diff --git a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java index 104e626..a9e119e 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java @@ -41,34 +41,33 @@ public class ReportServiceImpl implements ReportService { QuizSet quizSet = quizSetService.findQuizSet(reportRequset.getQuizsetId()); - + System.out.println(quizSet.toString()); List quizList = quizSet.getQuizzes(); List answerInputList = reportRequset.getAnswerInputList(); Report report = new Report(); Long reportNum = report.getId(); - int allCount= quizList.size(); - int correctCount =0 ; + int allCount = quizList.size(); + int correctCount = 0; - User testuser= userRepository.findById(reportRequset.getUserId()).orElse(null); + User testuser = userRepository.findById(reportRequset.getUserId()).orElse(null); for (Quiz quiz : quizList) { for (AnswerInput answerInput : answerInputList) { if (quiz.getId() == answerInput.getAnswerinputID()) { - if(quiz.getAnswer().equals(answerInput.getAnswer())) { + if (quiz.getAnswer().equals(answerInput.getAnswer())) { correctCount++; Answer answer = Answer.builder() - .userAnswer(answerInput.getAnswer()) + .userAnswer(answerInput.getAnswer()) .isCorrect(true) .report(report) .quiz(quiz) .build(); - } - else{ + } else { Answer answer = Answer.builder() .userAnswer(answerInput.getAnswer()) .isCorrect(false) @@ -77,7 +76,6 @@ public class ReportServiceImpl implements ReportService { .build(); - } } @@ -86,11 +84,11 @@ public class ReportServiceImpl implements ReportService { } report = Report.builder() - .user(testuser) - .quizSet(quizSet) - .allCount(allCount) - .correctCount(correctCount) - .testAt(new Date()).build(); + .user(testuser) + .quizSet(quizSet) + .allCount(allCount) + .correctCount(correctCount) + .testAt(new Date()).build(); ReportResponse reportResponse = ReportResponse.builder() .quizesetId(quizSet.getId()) .userId(testuser.getId()) diff --git a/backend/src/main/java/com/edufocus/edufocus/user/config/WebConfiguration.java b/backend/src/main/java/com/edufocus/edufocus/user/config/WebConfiguration.java index 0d8851c..0972d21 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/config/WebConfiguration.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/config/WebConfiguration.java @@ -21,13 +21,14 @@ public class WebConfiguration implements WebMvcConfigurer { this.jwtInterceptor = jwtInterceptor; } -// + + // @Override public void addCorsMappings(CorsRegistry registry) { registry .addMapping("/**") - .allowedOriginPatterns("https://i11a701.p.ssafy.io/","https://localhost:5173", "http://localhost:5173", "http://localhost:4173","http://localhost:5080","http://192.168.*.*:5173") - .allowedMethods("GET","POST",HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), + .allowedOriginPatterns("https://i11a701.p.ssafy.io/", "https://localhost:5173", "http://localhost:5173", "http://localhost:4173", "http://localhost:5080", "http://192.168.*.*:5173") + .allowedMethods("GET", "POST", HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), HttpMethod.DELETE.name(), HttpMethod.HEAD.name(), HttpMethod.OPTIONS.name(), HttpMethod.PATCH.name()) .allowCredentials(true) @@ -41,10 +42,11 @@ public class WebConfiguration implements WebMvcConfigurer { registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/assets/img/"); registry.addResourceHandler("/*.html**").addResourceLocations("classpath:/static/"); } + @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(jwtInterceptor) .addPathPatterns("/**") // 모든 경로에 대해 인터셉터 적용 - .excludePathPatterns("/v3/api-docs/**","/swagger-resources/**","/webjars/**","/swagger-ui/**","/auth/**", "/board/**", "/user/**","/lecture/**","/qna/**", "/quiz/**","/video/**","/registration/**"); // 인증 없이 접근 가능한 경로 설정 + .excludePathPatterns("/v3/api-docs/**", "/swagger-resources/**", "/webjars/**", "/swagger-ui/**", "/auth/**", "/board/**", "/user/**", "/lecture/**", "/qna/**", "/quiz/**", "/video/**", "/registration/**", "/report/**"); // 인증 없이 접근 가능한 경로 설정 } } \ No newline at end of file diff --git a/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java b/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java index 6bfa21a..6dbba66 100644 --- a/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java +++ b/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java @@ -93,36 +93,9 @@ public class Controller { } - } + } else if (findUser.getRole() == UserRole.ADMIN) {//&& lecture.isOnline() ) { - return ResponseEntity.ok(Map.of("token", null)); - - } - - - @PostMapping(value = "/makeroom/{lecture_id}") - public ResponseEntity> makeRoom(@PathVariable("lecture_id") Long id, HttpServletRequest request) throws Exception { - String userToken = request.getHeader("Authorization"); - - - Long userId = Long.parseLong(jwtUtil.getUserId(userToken)); - User findUser = userRepository.findById(userId).orElse(null); - Lecture lecture = lectureRepository.findById(id).orElse(null); - - - String roomName = lecture.getTitle(); - String participantName = userService.getUserName(userId); - System.out.println(participantName); - - AccessToken token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET); - - - if (findUser.getRole() == UserRole.ADMIN) {//&& lecture.isOnline() ) { - - - videoSertvice.startOnline(userId, id); - IdentityData identityData = new IdentityData(participantName, "강사"); String jsonIdentity = serializeIdentityData(identityData); @@ -137,11 +110,26 @@ public class Controller { } - return ResponseEntity.ok(Map.of("token", null)); } + + @PostMapping(value = "/makeroom/{lecture_id}") + public ResponseEntity> makeRoom(@PathVariable("lecture_id") Long id, HttpServletRequest request) throws Exception { + String userToken = request.getHeader("Authorization"); + + + Long userId = Long.parseLong(jwtUtil.getUserId(userToken)); + + + videoSertvice.startOnline(userId, id); + + + return ResponseEntity.ok(Map.of("token", " ")); + + } + @PostMapping(value = "/livekit/webhook", consumes = "application/webhook+json") public ResponseEntity receiveWebhook(@RequestHeader("Authorization") String authHeader, @RequestBody String body) { WebhookReceiver webhookReceiver = new WebhookReceiver(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);