|
|
@@ -1,79 +1,79 @@
|
|
|
-package nju.seec.helper.aspect.record;
|
|
|
-
|
|
|
-import nju.seec.helper.sys.bok.api.RecordApi;
|
|
|
-import nju.seec.helper.sys.dataanalysis.api.ExerciseApi;
|
|
|
-import nju.seec.helper.aspect.auth.LoginUser;
|
|
|
-import nju.seec.helper.dto.quiz.QuizStudentAnswerDTO;
|
|
|
-import nju.seec.helper.vo.quiz.QuizStudentAnswerVO;
|
|
|
-import org.aspectj.lang.annotation.AfterReturning;
|
|
|
-import org.aspectj.lang.annotation.Aspect;
|
|
|
-import org.aspectj.lang.annotation.Pointcut;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author cst
|
|
|
- */
|
|
|
-@Aspect
|
|
|
-@Component
|
|
|
-public class ExerciseRecordAspect {
|
|
|
- private final ExerciseApi exerciseApi;
|
|
|
- private final RecordApi recordApi;
|
|
|
-
|
|
|
- public ExerciseRecordAspect(ExerciseApi exerciseApi, RecordApi recordApi) {
|
|
|
- this.exerciseApi = exerciseApi;
|
|
|
- this.recordApi = recordApi;
|
|
|
- }
|
|
|
-
|
|
|
- @Pointcut(value = "@annotation(exerciseRecord) && args(user,..,quizStudentAnswerDTO)", argNames = "exerciseRecord,user,quizStudentAnswerDTO")
|
|
|
- public void pointCut(ExerciseRecord exerciseRecord, LoginUser user, QuizStudentAnswerDTO quizStudentAnswerDTO) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @AfterReturning(value = "pointCut(exerciseRecord,user,quizStudentAnswerDTO)", returning = "quizStudentAnswerVO", argNames = "exerciseRecord,user,quizStudentAnswerDTO,quizStudentAnswerVO")
|
|
|
- public void reportRecordToData(ExerciseRecord exerciseRecord, LoginUser user, QuizStudentAnswerDTO quizStudentAnswerDTO, QuizStudentAnswerVO quizStudentAnswerVO) {
|
|
|
- String userId = String.valueOf(user.getPid());
|
|
|
- Map<String, QuizStudentAnswerVO.QuestionStudentAnswerInfo> questionStudentAnswerInfoMap = quizStudentAnswerVO.getAnswers();
|
|
|
- exerciseApi.reportExercise(
|
|
|
- quizStudentAnswerDTO
|
|
|
- .getRecords()
|
|
|
- .entrySet()
|
|
|
- .stream()
|
|
|
- .map(answerRecordDTOEntry -> {
|
|
|
- String questionId = answerRecordDTOEntry.getKey();
|
|
|
- QuizStudentAnswerDTO.AnswerRecordDTO answerRecordDTO = answerRecordDTOEntry.getValue();
|
|
|
- QuizStudentAnswerVO.QuestionStudentAnswerInfo studentAnswerInfo = questionStudentAnswerInfoMap.get(questionId);
|
|
|
- return studentAnswerInfo != null
|
|
|
- ? exerciseApi.createExerciseRecordDTO(userId, questionId, answerRecordDTO.getStartAt(), answerRecordDTO.getEndAt(), studentAnswerInfo.getCorrect())
|
|
|
- : null;
|
|
|
- })
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toList())
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- @AfterReturning(value = "pointCut(exerciseRecord,user,quizStudentAnswerDTO)", returning = "quizStudentAnswerVO", argNames = "exerciseRecord,user,quizStudentAnswerDTO,quizStudentAnswerVO")
|
|
|
- public void reportRecordToBok(ExerciseRecord exerciseRecord, LoginUser user, QuizStudentAnswerDTO quizStudentAnswerDTO, QuizStudentAnswerVO quizStudentAnswerVO) {
|
|
|
- String userId = String.valueOf(user.getPid());
|
|
|
- Map<String, QuizStudentAnswerVO.QuestionStudentAnswerInfo> questionStudentAnswerInfoMap = quizStudentAnswerVO.getAnswers();
|
|
|
- recordApi.reportUserRecord(
|
|
|
- quizStudentAnswerDTO
|
|
|
- .getRecords()
|
|
|
- .entrySet()
|
|
|
- .stream()
|
|
|
- .map(answerRecordDTOEntry -> {
|
|
|
- String questionId = answerRecordDTOEntry.getKey();
|
|
|
- QuizStudentAnswerDTO.AnswerRecordDTO answerRecordDTO = answerRecordDTOEntry.getValue();
|
|
|
- QuizStudentAnswerVO.QuestionStudentAnswerInfo studentAnswerInfo = questionStudentAnswerInfoMap.get(questionId);
|
|
|
- return studentAnswerInfo != null
|
|
|
- ? recordApi.createRecordDTO(userId, questionId, studentAnswerInfo.getAnswer(), studentAnswerInfo.getCorrect(), answerRecordDTO.getStartAt(), answerRecordDTO.getEndAt())
|
|
|
- : null;
|
|
|
- })
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toList())
|
|
|
- );
|
|
|
- }
|
|
|
-}
|
|
|
+//package nju.seec.helper.aspect.record;
|
|
|
+//
|
|
|
+//import nju.seec.helper.sys.bok.api.RecordApi;
|
|
|
+//import nju.seec.helper.sys.dataanalysis.api.ExerciseApi;
|
|
|
+//import nju.seec.helper.aspect.auth.LoginUser;
|
|
|
+//import nju.seec.helper.dto.quiz.StudentAnswerDTO;
|
|
|
+//import nju.seec.helper.vo.quiz.QuizStudentAnswerVO;
|
|
|
+//import org.aspectj.lang.annotation.AfterReturning;
|
|
|
+//import org.aspectj.lang.annotation.Aspect;
|
|
|
+//import org.aspectj.lang.annotation.Pointcut;
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//
|
|
|
+//import java.util.Map;
|
|
|
+//import java.util.Objects;
|
|
|
+//import java.util.stream.Collectors;
|
|
|
+//
|
|
|
+///**
|
|
|
+// * @author cst
|
|
|
+// */
|
|
|
+//@Aspect
|
|
|
+//@Component
|
|
|
+//public class ExerciseRecordAspect {
|
|
|
+// private final ExerciseApi exerciseApi;
|
|
|
+// private final RecordApi recordApi;
|
|
|
+//
|
|
|
+// public ExerciseRecordAspect(ExerciseApi exerciseApi, RecordApi recordApi) {
|
|
|
+// this.exerciseApi = exerciseApi;
|
|
|
+// this.recordApi = recordApi;
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Pointcut(value = "@annotation(exerciseRecord) && args(user,..,studentAnswerDTO)", argNames = "exerciseRecord,user,quizStudentAnswerDTO")
|
|
|
+// public void pointCut(ExerciseRecord exerciseRecord, LoginUser user, StudentAnswerDTO studentAnswerDTO) {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @AfterReturning(value = "pointCut(exerciseRecord,user,studentAnswerDTO)", returning = "quizStudentAnswerVO", argNames = "exerciseRecord,user,quizStudentAnswerDTO,quizStudentAnswerVO")
|
|
|
+// public void reportRecordToData(ExerciseRecord exerciseRecord, LoginUser user, StudentAnswerDTO studentAnswerDTO, QuizStudentAnswerVO quizStudentAnswerVO) {
|
|
|
+// String userId = String.valueOf(user.getPid());
|
|
|
+// Map<String, QuizStudentAnswerVO.QuestionStudentAnswerInfo> questionStudentAnswerInfoMap = quizStudentAnswerVO.getAnswers();
|
|
|
+// exerciseApi.reportExercise(
|
|
|
+// studentAnswerDTO
|
|
|
+// .getRecords()
|
|
|
+// .entrySet()
|
|
|
+// .stream()
|
|
|
+// .map(answerRecordDTOEntry -> {
|
|
|
+// String questionId = answerRecordDTOEntry.getKey();
|
|
|
+// StudentAnswerDTO.AnswerRecordDTO answerRecordDTO = answerRecordDTOEntry.getValue();
|
|
|
+// QuizStudentAnswerVO.QuestionStudentAnswerInfo studentAnswerInfo = questionStudentAnswerInfoMap.get(questionId);
|
|
|
+// return studentAnswerInfo != null
|
|
|
+// ? exerciseApi.createExerciseRecordDTO(userId, questionId, answerRecordDTO.getStartAt(), answerRecordDTO.getEndAt(), studentAnswerInfo.getCorrect())
|
|
|
+// : null;
|
|
|
+// })
|
|
|
+// .filter(Objects::nonNull)
|
|
|
+// .collect(Collectors.toList())
|
|
|
+// );
|
|
|
+// }
|
|
|
+//
|
|
|
+// @AfterReturning(value = "pointCut(exerciseRecord,user,studentAnswerDTO)", returning = "quizStudentAnswerVO", argNames = "exerciseRecord,user,quizStudentAnswerDTO,quizStudentAnswerVO")
|
|
|
+// public void reportRecordToBok(ExerciseRecord exerciseRecord, LoginUser user, StudentAnswerDTO studentAnswerDTO, QuizStudentAnswerVO quizStudentAnswerVO) {
|
|
|
+// String userId = String.valueOf(user.getPid());
|
|
|
+// Map<String, QuizStudentAnswerVO.QuestionStudentAnswerInfo> questionStudentAnswerInfoMap = quizStudentAnswerVO.getAnswers();
|
|
|
+// recordApi.reportUserRecord(
|
|
|
+// studentAnswerDTO
|
|
|
+// .getRecords()
|
|
|
+// .entrySet()
|
|
|
+// .stream()
|
|
|
+// .map(answerRecordDTOEntry -> {
|
|
|
+// String questionId = answerRecordDTOEntry.getKey();
|
|
|
+// StudentAnswerDTO.AnswerRecordDTO answerRecordDTO = answerRecordDTOEntry.getValue();
|
|
|
+// QuizStudentAnswerVO.QuestionStudentAnswerInfo studentAnswerInfo = questionStudentAnswerInfoMap.get(questionId);
|
|
|
+// return studentAnswerInfo != null
|
|
|
+// ? recordApi.createRecordDTO(userId, questionId, studentAnswerInfo.getAnswer(), studentAnswerInfo.getCorrect(), answerRecordDTO.getStartAt(), answerRecordDTO.getEndAt())
|
|
|
+// : null;
|
|
|
+// })
|
|
|
+// .filter(Objects::nonNull)
|
|
|
+// .collect(Collectors.toList())
|
|
|
+// );
|
|
|
+// }
|
|
|
+//}
|