diff --git a/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetService.java b/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetService.java index 97e75d2..8a610cc 100644 --- a/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetService.java +++ b/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetService.java @@ -22,5 +22,5 @@ public interface QuizSetService { List findMyQuizSetResponses(long userId); - void updateQuizSetTested(long quizSetId, long userId, boolean tested); + void updateQuizSetTested(long quizSetId); } diff --git a/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetServiceImpl.java index a636f0c..07b68a3 100644 --- a/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetServiceImpl.java @@ -99,15 +99,9 @@ public class QuizSetServiceImpl implements QuizSetService { } @Override - public void updateQuizSetTested(long quizSetId, long userId, boolean tested) { + public void updateQuizSetTested(long quizSetId) { QuizSet quizSet = quizSetRepository.findById(quizSetId).orElseThrow(NoSuchElementException::new); - - User user = userRepository.findById(userId).orElseThrow(NoSuchElementException::new); - - if (quizSet.getUser().getId() != user.getId()) { - throw new UnAuthorizedException(); - } - + quizSet.setTested(true); quizSetRepository.save(quizSet); } diff --git a/backend/src/main/java/com/edufocus/edufocus/ws/controller/ChatController.java b/backend/src/main/java/com/edufocus/edufocus/ws/controller/ChatController.java index 4e280b9..6f149f0 100644 --- a/backend/src/main/java/com/edufocus/edufocus/ws/controller/ChatController.java +++ b/backend/src/main/java/com/edufocus/edufocus/ws/controller/ChatController.java @@ -2,6 +2,7 @@ package com.edufocus.edufocus.ws.controller; import com.edufocus.edufocus.global.constant.RabbitMQConstant; +import com.edufocus.edufocus.quiz.service.QuizSetService; import com.edufocus.edufocus.report.service.ReportService; import com.edufocus.edufocus.ws.entity.dto.MessageDto; import com.edufocus.edufocus.ws.entity.dto.QuizDto; @@ -17,22 +18,25 @@ public class ChatController { RabbitTemplate rabbitTemplate; ReportService reportService; + QuizSetService quizSetService; - public ChatController(RabbitTemplate rabbitTemplate, ReportService reportService){ + public ChatController(RabbitTemplate rabbitTemplate, ReportService reportService, QuizSetService quizSetService) { this.rabbitTemplate = rabbitTemplate; this.reportService = reportService; + this.quizSetService = quizSetService; } @MessageMapping("chat.message.{lectureId}") - public void sendMessage(@DestinationVariable long lectureId, MessageDto messageDto){ - rabbitTemplate.convertAndSend(RabbitMQConstant.CHAT_EXCHANGE.getConstant(), + public void sendMessage(@DestinationVariable long lectureId, MessageDto messageDto) { + rabbitTemplate.convertAndSend(RabbitMQConstant.CHAT_EXCHANGE.getConstant(), RabbitMQConstant.ROUTING_KEY_PREFIX.getConstant() + lectureId, messageDto); } @MessageMapping("chat.quiz.{lectureId}") - public void quizStart(@DestinationVariable long lectureId, QuizDto quizDto){ + public void quizStart(@DestinationVariable long lectureId, QuizDto quizDto) { UUID reportSetId = reportService.initReportSet(lectureId, quizDto.getQuizSetId()); + quizSetService.updateQuizSetTested(quizDto.getQuizSetId()); quizDto.setReportSetId(reportSetId);