| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package cn.seecoder.judgement.vo;
- import cn.seecoder.judgement.dto.StudentAnswerDTO;
- import cn.seecoder.judgement.vo.question.BaseQuestionVO;
- import lombok.AllArgsConstructor;
- import lombok.Data;
- import lombok.NoArgsConstructor;
- import lombok.NonNull;
- import java.math.BigDecimal;
- import java.time.LocalDateTime;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- /**
- * @author cst
- */
- @Data
- @NoArgsConstructor
- public class JudgedAnswersVO {
- /**
- * 回答情况
- */
- private Map<String, QuestionStudentAnswerInfo> answers;
- /**
- * 提交时间
- */
- private LocalDateTime submitAt;
- /**
- * 已提交次数
- */
- private Integer submitNumber;
- /**
- * 自动化判分的分数
- */
- private BigDecimal score;
- public JudgedAnswersVO(Map<String, QuestionStudentAnswerInfo> answers){
- this.answers = answers;
- }
- public JudgedAnswersVO(@NonNull Map<String, StudentAnswerDTO.AnswerRecordDTO> records, List<BaseQuestionVO> baseQuestionVOList) {
- /* this.quizId = quizStudentAnswer.getQuiz().getId();
- this.quizName = quizStudentAnswer.getQuiz().getName();
- this.studentId = quizStudentAnswer.getStudent().getId();
- this.studentName = quizStudentAnswer.getStudent().getName();*/
- this.answers = baseQuestionVOList.parallelStream()
- .map(baseQuestionVO -> {
- String questionId = baseQuestionVO.getId();
- StudentAnswerDTO.AnswerRecordDTO questionRecord = records.get(questionId);
- Object questionStudentAnswer = questionRecord.getAnswer();
- return QuestionStudentAnswerInfo.of(questionId, questionStudentAnswer, baseQuestionVO.pass(questionStudentAnswer));
- })
- .collect(Collectors.toMap(QuestionStudentAnswerInfo::getQuestionId, questionStudentAnswerInfo -> questionStudentAnswerInfo));
- /* this.submitAt = quizStudentAnswer.getSubmitAt();
- this.submitNumber = quizStudentAnswer.getSubmitNumber();
- this.score = quizStudentAnswer.getScore();*/
- }
- @Data
- @NoArgsConstructor
- @AllArgsConstructor(staticName = "of")
- public static class QuestionStudentAnswerInfo {
- private String questionId;
- private Object answer;
- private Boolean correct;
- }
- }
|