|
|
@@ -21,15 +21,17 @@ import com.nju.edu.eval.model.vo.judge.CodeJudgeVO;
|
|
|
import com.nju.edu.eval.model.vo.judge.ObjectiveJudgeResOfExerciseVO;
|
|
|
import com.nju.edu.eval.model.vo.judge.ObjectiveJudgeResVO;
|
|
|
import com.nju.edu.eval.model.vo.judge.ObjectiveJudgeVO;
|
|
|
+import com.nju.edu.eval.model.vo.logdata.AnswerDTO;
|
|
|
+import com.nju.edu.eval.model.vo.logdata.ExamRecordLog;
|
|
|
import com.nju.edu.eval.model.vo.question.CompleteQuestionVO;
|
|
|
import com.nju.edu.eval.publicdatas.enums.CodeJudgeResultType;
|
|
|
import com.nju.edu.eval.service.JudgeService;
|
|
|
+import com.nju.edu.eval.util.LogTracingUtil;
|
|
|
+import com.nju.edu.logTracking.enums.SeecSystem;
|
|
|
+import org.apache.logging.log4j.LogBuilder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -70,6 +72,9 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
scoreDao.save(score);
|
|
|
List<QuestionRecord> records = score.getRecords();
|
|
|
|
|
|
+ // 存储用以打日志的错题集
|
|
|
+ List<AnswerDTO> err = new ArrayList<>();
|
|
|
+
|
|
|
double curScore = 0.0;
|
|
|
// 存储用户提交的记录
|
|
|
for (Map.Entry<String, StudentAnswerDTO.AnswerRecordDTO> entry : objectiveJudgeVO.getRecords().entrySet()) {
|
|
|
@@ -79,15 +84,24 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
double scoreOfQuestion = exam.getQuestionAndScore().get(questionId);
|
|
|
// 看该题是否正确
|
|
|
boolean isTrue = judgedAnswersVO.getAnswers().get(questionId).getCorrect();
|
|
|
+ // 填入错题集
|
|
|
+ if (!isTrue)
|
|
|
+ err.add(new AnswerDTO(questionId, scoreOfQuestion));
|
|
|
double actualScore = isTrue ? scoreOfQuestion : 0;
|
|
|
curScore += actualScore;
|
|
|
QuestionRecord questionRecord = new QuestionRecord(user, exam, entry.getKey(), score, (String) entry.getValue().getAnswer(), actualScore, currentTime);
|
|
|
records.add(questionRecord);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
double maxScore = Math.max(score.getScore() - score.getObjectiveScore() + curScore, score.getScore());
|
|
|
score.setObjectiveScore(Math.max(curScore, score.getObjectiveScore()));
|
|
|
score.setScore(maxScore);
|
|
|
- scoreDao.save(score);
|
|
|
+ scoreDao.save(score);;
|
|
|
+
|
|
|
+ // 提交记录日志
|
|
|
+ LogTracingUtil.logRecord(new ExamRecordLog(examId, userId, currentTime, curScore, err));
|
|
|
+
|
|
|
return new ObjectiveJudgeResVO(judgedAnswersVO.getSubmitAt(), judgedAnswersVO.getSubmitNumber());
|
|
|
|
|
|
} catch (ThirdPartyServiceException exception) {
|
|
|
@@ -158,6 +172,13 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
double maxScore = Math.max(score.getScore() - preScore + curScore, score.getScore());
|
|
|
score.setScore(maxScore);
|
|
|
scoreDao.save(score);
|
|
|
+
|
|
|
+ // 提交记录日志
|
|
|
+ List<AnswerDTO> err = new ArrayList<>();
|
|
|
+ if (curScore != scoreOfQuestion)
|
|
|
+ err.add(new AnswerDTO(questionId, scoreOfQuestion));
|
|
|
+ LogTracingUtil.logRecord(new ExamRecordLog(examId, userId, currentTime, curScore, err));
|
|
|
+
|
|
|
return judgeResult;
|
|
|
} catch (ThirdPartyServiceException exception) {
|
|
|
throw new MyServiceException(exception.getCode(), exception.getMessage());
|