From 541e77765ef787c48c4b0f694b499a4fc5196d6e Mon Sep 17 00:00:00 2001 From: 龚焕茏 <2842157468@qq.com> Date: 星期三, 26 六月 2024 16:13:16 +0800 Subject: [PATCH] feat:考试监控 --- src/main/java/com/ycl/jxkg/service/impl/ExamPaperAnswerServiceImpl.java | 161 +++++++++++++++++++++++++++++------------------------ 1 files changed, 87 insertions(+), 74 deletions(-) diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperAnswerServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperAnswerServiceImpl.java index 461d096..6223325 100644 --- a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperAnswerServiceImpl.java +++ b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperAnswerServiceImpl.java @@ -1,14 +1,20 @@ package com.ycl.jxkg.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ycl.jxkg.domain.*; -import com.ycl.jxkg.domain.enums.ExamPaperAnswerStatusEnum; -import com.ycl.jxkg.domain.enums.ExamPaperTypeEnum; -import com.ycl.jxkg.domain.enums.QuestionTypeEnum; -import com.ycl.jxkg.domain.exam.ExamPaperTitleItemObject; -import com.ycl.jxkg.domain.other.KeyValue; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.ycl.jxkg.domain.ExamPaperAnswerInfo; +import com.ycl.jxkg.domain.entity.*; import com.ycl.jxkg.domain.other.ExamPaperAnswerUpdate; -import com.ycl.jxkg.domain.task.TaskItemAnswerObject; +import com.ycl.jxkg.domain.other.KeyValue; +import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperAnswerPageRequestVO; +import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitItemVO; +import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; +import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; +import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageVO; +import com.ycl.jxkg.enums.ExamPaperAnswerStatusEnum; +import com.ycl.jxkg.enums.ExamPaperTypeEnum; +import com.ycl.jxkg.enums.QuestionTypeEnum; import com.ycl.jxkg.mapper.ExamPaperAnswerMapper; import com.ycl.jxkg.mapper.ExamPaperMapper; import com.ycl.jxkg.mapper.QuestionMapper; @@ -19,14 +25,7 @@ import com.ycl.jxkg.utils.DateTimeUtil; import com.ycl.jxkg.utils.ExamUtil; import com.ycl.jxkg.utils.JsonUtil; -import com.ycl.jxkg.vo.admin.paper.ExamPaperAnswerPageRequestVO; -import com.ycl.jxkg.vo.student.exam.ExamPaperSubmitItemVO; -import com.ycl.jxkg.vo.student.exam.ExamPaperSubmitVO; -import com.ycl.jxkg.vo.student.exampaper.ExamPaperAnswerPageVO; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -37,7 +36,7 @@ @Service @RequiredArgsConstructor -public class ExamPaperAnswerServiceImpl extends ServiceImpl<ExamPaperAnswerMapper ,ExamPaperAnswer> implements ExamPaperAnswerService { +public class ExamPaperAnswerServiceImpl extends ServiceImpl<ExamPaperAnswerMapper , ExamPaperAnswer> implements ExamPaperAnswerService { private final ExamPaperAnswerMapper examPaperAnswerMapper; private final ExamPaperMapper examPaperMapper; @@ -61,32 +60,33 @@ ExamPaper examPaper = examPaperMapper.selectById(examPaperSubmitVO.getId()); ExamPaperTypeEnum paperTypeEnum = ExamPaperTypeEnum.fromCode(examPaper.getPaperType()); //浠诲姟璇曞嵎鍙兘鍋氫竴娆� - if (paperTypeEnum == ExamPaperTypeEnum.Task) { + if (paperTypeEnum == ExamPaperTypeEnum.RandomOrder) { ExamPaperAnswer examPaperAnswer = examPaperAnswerMapper.getByPidUid(examPaperSubmitVO.getId(), user.getId()); if (null != examPaperAnswer) return null; } - String frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()).getContent(); - List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent, ExamPaperTitleItemObject.class); - List<Integer> questionIds = examPaperTitleItemObjects.stream().flatMap(t -> t.getQuestionItems().stream().map(q -> q.getId())).collect(Collectors.toList()); - List<Question> questions = questionMapper.selectByIds(questionIds); - //灏嗛鐩粨鏋勭殑杞寲涓洪鐩瓟妗� - List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperTitleItemObjects.stream() - .flatMap(t -> t.getQuestionItems().stream() - .map(q -> { - Question question = questions.stream().filter(tq -> tq.getId().equals(q.getId())).findFirst().get(); - ExamPaperSubmitItemVO customerQuestionAnswer = examPaperSubmitVO.getAnswerItems().stream() - .filter(tq -> tq.getQuestionId().equals(q.getId())) - .findFirst() - .orElse(null); - return ExamPaperQuestionCustomerAnswerFromVM(question, customerQuestionAnswer, examPaper, q.getItemOrder(), user, now); - }) - ).collect(Collectors.toList()); - - ExamPaperAnswer examPaperAnswer = ExamPaperAnswerFromVM(examPaperSubmitVO, examPaper, examPaperQuestionCustomerAnswers, user, now); - examPaperAnswerInfo.setExamPaper(examPaper); - examPaperAnswerInfo.setExamPaperAnswer(examPaperAnswer); - examPaperAnswerInfo.setExamPaperQuestionCustomerAnswers(examPaperQuestionCustomerAnswers); + //TODO:寰呭畬鎴� +// String frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()).getContent(); +// List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent, ExamPaperTitleItemObject.class); +// List<Integer> questionIds = examPaperTitleItemObjects.stream().flatMap(t -> t.getQuestionItems().stream().map(q -> q.getId())).collect(Collectors.toList()); +// List<Question> questions = questionMapper.selectByIds(questionIds); +// //灏嗛鐩粨鏋勭殑杞寲涓洪鐩瓟妗� +// List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperTitleItemObjects.stream() +// .flatMap(t -> t.getQuestionItems().stream() +// .map(q -> { +// Question question = questions.stream().filter(tq -> tq.getId().equals(q.getId())).findFirst().get(); +// ExamPaperSubmitItemVO customerQuestionAnswer = examPaperSubmitVO.getAnswerItems().stream() +// .filter(tq -> tq.getQuestionId().equals(q.getId())) +// .findFirst() +// .orElse(null); +// return ExamPaperQuestionCustomerAnswerFromVM(question, customerQuestionAnswer, examPaper, q.getItemOrder(), user, now); +// }) +// ).collect(Collectors.toList()); +// +// ExamPaperAnswer examPaperAnswer = ExamPaperAnswerFromVM(examPaperSubmitVO, examPaper, examPaperQuestionCustomerAnswers, user, now); +// examPaperAnswerInfo.setExamPaper(examPaper); +// examPaperAnswerInfo.setExamPaperAnswer(examPaperAnswer); +// examPaperAnswerInfo.setExamPaperQuestionCustomerAnswers(examPaperQuestionCustomerAnswers); return examPaperAnswerInfo; } @@ -118,19 +118,20 @@ ExamPaperTypeEnum examPaperTypeEnum = ExamPaperTypeEnum.fromCode(examPaperAnswer.getPaperType()); switch (examPaperTypeEnum) { - case Task: + case RandomOrder: + //TODO:寰呭畬鎴� //浠诲姟璇曞嵎鎵规敼瀹屾垚鍚庯紝闇�瑕佹洿鏂颁换鍔$殑鐘舵�� - ExamPaper examPaper = examPaperMapper.selectById(examPaperAnswer.getExamPaperId()); - Integer taskId = examPaper.getTaskExamId(); - Integer userId = examPaperAnswer.getCreateUser(); - TaskExamCustomerAnswer taskExamCustomerAnswer = taskExamCustomerAnswerMapper.getByTUid(taskId, userId); - TextContent textContent = textContentService.getById(taskExamCustomerAnswer.getTextContentId()); - List<TaskItemAnswerObject> taskItemAnswerObjects = JsonUtil.toJsonListObject(textContent.getContent(), TaskItemAnswerObject.class); - taskItemAnswerObjects.stream() - .filter(d -> d.getExamPaperAnswerId().equals(examPaperAnswer.getId())) - .findFirst().ifPresent(taskItemAnswerObject -> taskItemAnswerObject.setStatus(examPaperAnswer.getStatus())); - textContentService.jsonConvertUpdate(textContent, taskItemAnswerObjects, null); - textContentService.updateById(textContent); +// ExamPaper examPaper = examPaperMapper.selectById(examPaperAnswer.getExamPaperId()); +// Integer taskId = examPaper.getTaskExamId(); +// Integer userId = examPaperAnswer.getCreateUser(); +// TaskExamCustomerAnswer taskExamCustomerAnswer = taskExamCustomerAnswerMapper.getByTUid(taskId, userId); +// TextContent textContent = textContentService.getById(taskExamCustomerAnswer.getTextContentId()); +// List<TaskItemAnswerObject> taskItemAnswerObjects = JsonUtil.toJsonListObject(textContent.getContent(), TaskItemAnswerObject.class); +// taskItemAnswerObjects.stream() +// .filter(d -> d.getExamPaperAnswerId().equals(examPaperAnswer.getId())) +// .findFirst().ifPresent(taskItemAnswerObject -> taskItemAnswerObject.setStatus(examPaperAnswer.getStatus())); +// textContentService.jsonConvertUpdate(textContent, taskItemAnswerObjects, null); +// textContentService.updateById(textContent); break; default: break; @@ -186,13 +187,13 @@ ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer = new ExamPaperQuestionCustomerAnswer(); examPaperQuestionCustomerAnswer.setQuestionId(question.getId()); examPaperQuestionCustomerAnswer.setExamPaperId(examPaper.getId()); - examPaperQuestionCustomerAnswer.setQuestionScore(question.getScore()); + examPaperQuestionCustomerAnswer.setQuestionScore(null); examPaperQuestionCustomerAnswer.setSubjectId(examPaper.getSubjectId()); examPaperQuestionCustomerAnswer.setItemOrder(itemOrder); examPaperQuestionCustomerAnswer.setCreateTime(now); examPaperQuestionCustomerAnswer.setCreateUser(user.getId()); examPaperQuestionCustomerAnswer.setQuestionType(question.getQuestionType()); - examPaperQuestionCustomerAnswer.setQuestionTextContentId(question.getInfoTextContentId()); + examPaperQuestionCustomerAnswer.setQuestionContent(question.getContent()); if (null == customerQuestionAnswer) { examPaperQuestionCustomerAnswer.setCustomerScore(0); } else { @@ -215,13 +216,13 @@ case TrueFalse: examPaperQuestionCustomerAnswer.setAnswer(customerQuestionAnswer.getContent()); examPaperQuestionCustomerAnswer.setDoRight(question.getCorrect().equals(customerQuestionAnswer.getContent())); - examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? question.getScore() : 0); + examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? null : 0); break; case MultipleChoice: String customerAnswer = ExamUtil.contentToString(customerQuestionAnswer.getContentArray()); examPaperQuestionCustomerAnswer.setAnswer(customerAnswer); examPaperQuestionCustomerAnswer.setDoRight(customerAnswer.equals(question.getCorrect())); - examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? question.getScore() : 0); + examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? null : 0); break; case GapFilling: String correctAnswer = JsonUtil.toJsonStr(customerQuestionAnswer.getContentArray()); @@ -239,32 +240,44 @@ Integer systemScore = examPaperQuestionCustomerAnswers.stream().mapToInt(a -> a.getCustomerScore()).sum(); long questionCorrect = examPaperQuestionCustomerAnswers.stream().filter(a -> a.getCustomerScore().equals(a.getQuestionScore())).count(); ExamPaperAnswer examPaperAnswer = new ExamPaperAnswer(); - examPaperAnswer.setPaperName(examPaper.getName()); - examPaperAnswer.setDoTime(examPaperSubmitVO.getDoTime()); - examPaperAnswer.setExamPaperId(examPaper.getId()); - examPaperAnswer.setCreateUser(user.getId()); - examPaperAnswer.setCreateTime(now); - examPaperAnswer.setSubjectId(examPaper.getSubjectId()); - examPaperAnswer.setQuestionCount(examPaper.getQuestionCount()); - examPaperAnswer.setPaperScore(examPaper.getScore()); - examPaperAnswer.setPaperType(examPaper.getPaperType()); - examPaperAnswer.setSystemScore(systemScore); - examPaperAnswer.setUserScore(systemScore); - examPaperAnswer.setTaskExamId(examPaper.getTaskExamId()); - examPaperAnswer.setQuestionCorrect((int) questionCorrect); - boolean needJudge = examPaperQuestionCustomerAnswers.stream().anyMatch(d -> QuestionTypeEnum.needSaveTextContent(d.getQuestionType())); - if (needJudge) { - examPaperAnswer.setStatus(ExamPaperAnswerStatusEnum.WaitJudge.getCode()); - } else { - examPaperAnswer.setStatus(ExamPaperAnswerStatusEnum.Complete.getCode()); - } + //TODO:寰呭畬鎴� +// examPaperAnswer.setPaperName(examPaper.getName()); +// examPaperAnswer.setDoTime(examPaperSubmitVO.getDoTime()); +// examPaperAnswer.setExamPaperId(examPaper.getId()); +// examPaperAnswer.setCreateUser(user.getId()); +// examPaperAnswer.setCreateTime(now); +// examPaperAnswer.setSubjectId(examPaper.getSubjectId()); +// examPaperAnswer.setQuestionCount(examPaper.getQuestionCount()); +// examPaperAnswer.setPaperScore(examPaper.getScore()); +// examPaperAnswer.setPaperType(examPaper.getPaperType()); +// examPaperAnswer.setSystemScore(systemScore); +// examPaperAnswer.setUserScore(systemScore); +// examPaperAnswer.setTaskExamId(examPaper.getTaskExamId()); +// examPaperAnswer.setQuestionCorrect((int) questionCorrect); +// boolean needJudge = examPaperQuestionCustomerAnswers.stream().anyMatch(d -> QuestionTypeEnum.needSaveTextContent(d.getQuestionType())); +// if (needJudge) { +// examPaperAnswer.setStatus(ExamPaperAnswerStatusEnum.WaitJudge.getCode()); +// } else { +// examPaperAnswer.setStatus(ExamPaperAnswerStatusEnum.Complete.getCode()); +// } return examPaperAnswer; } @Override - public PageInfo<ExamPaperAnswer> adminPage(ExamPaperAnswerPageRequestVO requestVM) { - return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> + public PageInfo<ExamPaperAnswerPageResponseVO> adminPage(ExamPaperAnswerPageRequestVO requestVM) { + return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize()).doSelectPageInfo(() -> examPaperAnswerMapper.adminPage(requestVM)); } + + @Override + public List<ExamPaperAnswerPageResponseVO> list(ExamPaperAnswerPageRequestVO requestVM) { + return examPaperAnswerMapper.adminPage(requestVM); + } + + @Override + public PageInfo<ExamPaperAnswerPageResponseVO> pageExamPaper(ExamPaperAnswerPageRequestVO model) { + return PageHelper.startPage(model.getPageIndex(), model.getPageSize()).doSelectPageInfo(() -> + examPaperAnswerMapper.pageExamPaper(model)); + } } -- Gitblit v1.8.0