|
|
@@ -29,6 +29,7 @@ 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.slf4j.Logger;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
@@ -39,6 +40,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
public class JudgeServiceImpl implements JudgeService {
|
|
|
+
|
|
|
private final JudgeManager judgeManager;
|
|
|
private final QuestionManager questionManager;
|
|
|
private final ScoreDao scoreDao;
|
|
|
@@ -59,7 +61,12 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
public ObjectiveJudgeResVO judgeObjectiveQuestionAnswers(Integer userId, Integer examId, ObjectiveJudgeVO objectiveJudgeVO) {
|
|
|
try {
|
|
|
// 提交给判题系统
|
|
|
- JudgedAnswersVO judgedAnswersVO = judgeManager.judgeObjectiveQuestionAnswers(userId, objectiveJudgeVO);
|
|
|
+ JudgedAnswersVO judgedAnswersVO = null;
|
|
|
+ try {
|
|
|
+ judgedAnswersVO = judgeManager.judgeObjectiveQuestionAnswers(userId, objectiveJudgeVO);
|
|
|
+ }catch (ThirdPartyServiceException e){
|
|
|
+ LogTracingUtil.logSimple("no error");
|
|
|
+ }
|
|
|
|
|
|
User user = userDao.findById(userId).orElse(null);
|
|
|
Exam exam = examDao.findById(examId).orElse(null);
|
|
|
@@ -85,8 +92,16 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
// 看该题是否正确
|
|
|
boolean isTrue = judgedAnswersVO.getAnswers().get(questionId).getCorrect();
|
|
|
// 填入错题集
|
|
|
- if (!isTrue)
|
|
|
- err.add(new AnswerDTO(questionId, scoreOfQuestion));
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (!isTrue)
|
|
|
+ err.add(new AnswerDTO(questionId, scoreOfQuestion));
|
|
|
+ }catch (Exception e) {
|
|
|
+ LogTracingUtil.logSimple("smart error");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
double actualScore = isTrue ? scoreOfQuestion : 0;
|
|
|
curScore += actualScore;
|
|
|
QuestionRecord questionRecord = new QuestionRecord(user, exam, entry.getKey(), score, (String) entry.getValue().getAnswer(), actualScore, currentTime);
|
|
|
@@ -100,7 +115,11 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
scoreDao.save(score);;
|
|
|
|
|
|
// 提交记录日志
|
|
|
- LogTracingUtil.logRecord(new ExamRecordLog(examId, userId, currentTime, curScore, err));
|
|
|
+ try {
|
|
|
+ LogTracingUtil.logRecord(new ExamRecordLog(examId, userId, currentTime, curScore, err));
|
|
|
+ }catch (Exception e) {
|
|
|
+ LogTracingUtil.logSimple("smart error");
|
|
|
+ }
|
|
|
|
|
|
return new ObjectiveJudgeResVO(judgedAnswersVO.getSubmitAt(), judgedAnswersVO.getSubmitNumber());
|
|
|
|