|
@@ -1,5 +1,7 @@
|
|
|
package cn.seecoder.judgement.service.impl;
|
|
package cn.seecoder.judgement.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.seecoder.bok.client.SeecoderBokClient;
|
|
|
|
|
+import cn.seecoder.bok.common.vo.RecordVO;
|
|
|
import cn.seecoder.judgement.dto.StudentAnswerDTO;
|
|
import cn.seecoder.judgement.dto.StudentAnswerDTO;
|
|
|
import cn.seecoder.judgement.service.JudgementService;
|
|
import cn.seecoder.judgement.service.JudgementService;
|
|
|
import cn.seecoder.judgement.service.QuestionService;
|
|
import cn.seecoder.judgement.service.QuestionService;
|
|
@@ -26,6 +28,8 @@ public class JudgementServiceImpl implements JudgementService {
|
|
|
System.out.println(new Date());
|
|
System.out.println(new Date());
|
|
|
System.out.println("start judging, students'answers are:");
|
|
System.out.println("start judging, students'answers are:");
|
|
|
System.out.println(studentAnswerDTO);
|
|
System.out.println(studentAnswerDTO);
|
|
|
|
|
+
|
|
|
|
|
+ String userId = studentAnswerDTO.getUserId();
|
|
|
Map<String, StudentAnswerDTO.AnswerRecordDTO> records = studentAnswerDTO.getRecords();
|
|
Map<String, StudentAnswerDTO.AnswerRecordDTO> records = studentAnswerDTO.getRecords();
|
|
|
List<String> questionIds = new ArrayList<>(records.keySet());
|
|
List<String> questionIds = new ArrayList<>(records.keySet());
|
|
|
List<BaseQuestionVO> questionVOList = questionService.getQuestionsByIds(questionIds);
|
|
List<BaseQuestionVO> questionVOList = questionService.getQuestionsByIds(questionIds);
|
|
@@ -34,6 +38,8 @@ public class JudgementServiceImpl implements JudgementService {
|
|
|
|
|
|
|
|
AtomicInteger correct = new AtomicInteger();
|
|
AtomicInteger correct = new AtomicInteger();
|
|
|
|
|
|
|
|
|
|
+ List<RecordVO> judgedAnswerRecords = new ArrayList<>();
|
|
|
|
|
+
|
|
|
Map<String, JudgedAnswersVO.QuestionStudentAnswerInfo> judgedAnswers = new HashMap<>();
|
|
Map<String, JudgedAnswersVO.QuestionStudentAnswerInfo> judgedAnswers = new HashMap<>();
|
|
|
questionVOList.forEach(baseQuestionVO -> {
|
|
questionVOList.forEach(baseQuestionVO -> {
|
|
|
String questionId = baseQuestionVO.getId();
|
|
String questionId = baseQuestionVO.getId();
|
|
@@ -43,8 +49,24 @@ public class JudgementServiceImpl implements JudgementService {
|
|
|
correct.getAndIncrement();
|
|
correct.getAndIncrement();
|
|
|
}
|
|
}
|
|
|
judgedAnswers.put(questionId, JudgedAnswersVO.QuestionStudentAnswerInfo.of(questionId, answer, isTrue));
|
|
judgedAnswers.put(questionId, JudgedAnswersVO.QuestionStudentAnswerInfo.of(questionId, answer, isTrue));
|
|
|
|
|
+
|
|
|
|
|
+ //保存做题数据
|
|
|
|
|
+ StudentAnswerDTO.AnswerRecordDTO answerRecordDTO = records.get(questionId);
|
|
|
|
|
+ RecordVO record = new RecordVO();
|
|
|
|
|
+ record.setUserId(userId);
|
|
|
|
|
+ record.setQuestionId(questionId);
|
|
|
|
|
+ record.setPass(isTrue);
|
|
|
|
|
+ record.setStudentAnswer(String.valueOf(answer));
|
|
|
|
|
+ record.setStartAt(answerRecordDTO.getStartAt());
|
|
|
|
|
+ record.setFinishAt(answerRecordDTO.getEndAt());
|
|
|
|
|
+
|
|
|
|
|
+ judgedAnswerRecords.add(record);
|
|
|
});
|
|
});
|
|
|
JudgedAnswersVO res = new JudgedAnswersVO(judgedAnswers);
|
|
JudgedAnswersVO res = new JudgedAnswersVO(judgedAnswers);
|
|
|
|
|
+
|
|
|
|
|
+ SeecoderBokClient seecoderBokClient = new SeecoderBokClient("http://bok.seecoder.cn", 0);
|
|
|
|
|
+ List<RecordVO> recordVOS = seecoderBokClient.createUserRecord(judgedAnswerRecords);
|
|
|
|
|
+
|
|
|
System.out.println("results are as follows:");
|
|
System.out.println("results are as follows:");
|
|
|
System.out.println(res);
|
|
System.out.println(res);
|
|
|
return res;
|
|
return res;
|