|
@@ -1,14 +1,28 @@
|
|
package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.*;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.*;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.*;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.*;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.*;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.dao.*;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.*;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordForMarkingService;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordQuestionsService;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.others.ExamCacheTransferHelper;
|
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
|
|
import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionStructure;
|
|
import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionStructure;
|
|
import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionUnit;
|
|
import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionUnit;
|
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
|
|
|
|
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
|
|
import cn.com.qmth.examcloud.support.cache.bean.QuestionCacheBean;
|
|
import cn.com.qmth.examcloud.support.cache.bean.QuestionCacheBean;
|
|
|
|
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
|
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
|
+import com.mysql.cj.util.StringUtils;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
@@ -20,36 +34,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import com.mysql.cj.util.StringUtils;
|
|
|
|
-
|
|
|
|
-import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamRecordForSelectScore;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.bean.ToBeMarkExamRecordBean;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.bean.ToBeMarkSubjectiveAnswerBean;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.ExamCaptureRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordDataRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordQuestionsRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.ExamStudentRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamCaptureEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamQuestionEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordDataEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordForMarkingEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordQuestionsEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScoreEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamStudentEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordForMarkingService;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.others.ExamCacheTransferHelper;
|
|
|
|
-import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
|
|
|
|
-import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
|
|
|
|
-import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
|
-import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
|
|
|
|
-import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
|
-import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author chenken
|
|
* @author chenken
|
|
@@ -85,6 +72,9 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
@Autowired
|
|
@Autowired
|
|
private ExamRecordQuestionsRepo examRecordQuestionsRepo;
|
|
private ExamRecordQuestionsRepo examRecordQuestionsRepo;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamRecordQuestionsService examRecordQuestionsService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@ApiOperation(value = "查询是否已经开考")
|
|
@ApiOperation(value = "查询是否已经开考")
|
|
@PostMapping("/checkExamIsStarted")
|
|
@PostMapping("/checkExamIsStarted")
|
|
@@ -274,29 +264,173 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @ApiOperation(value = "获取待阅卷的考试记录-供bridge调用")
|
|
|
|
- @PostMapping("/getToBeMarkExamRecord")
|
|
|
|
|
|
+ @ApiOperation(value = "分页获取待阅卷的考试记录")
|
|
|
|
+ @PostMapping("/getPagedToBeMarkExamRecord")
|
|
public GetPagedToBeMarkExamRecordResp getPagedToBeMarkExamRecord(@RequestBody GetPagedToBeMarkExamRecordReq req) {
|
|
public GetPagedToBeMarkExamRecordResp getPagedToBeMarkExamRecord(@RequestBody GetPagedToBeMarkExamRecordReq req) {
|
|
- if (null == req.getExamId()) {
|
|
|
|
- throw new StatusException("101001", "考试id不允许为空");
|
|
|
|
|
|
+ Long examId = req.getExamId();
|
|
|
|
+ String courseCode = req.getSubjectCode();
|
|
|
|
+ Long startId = req.getStartId();
|
|
|
|
+ Integer size = req.getSize();
|
|
|
|
+
|
|
|
|
+ validateToBeMarkData(examId, courseCode, startId, size);
|
|
|
|
+
|
|
|
|
+ List<ExamStudentEntity> limitedExamStuList =
|
|
|
|
+ examStudentRepo.getLimitExamStudentList(examId, courseCode, startId, size);
|
|
|
|
+
|
|
|
|
+ GetPagedToBeMarkExamRecordResp resp = new GetPagedToBeMarkExamRecordResp();
|
|
|
|
+ Long nextId = startId;
|
|
|
|
+
|
|
|
|
+ if (null == limitedExamStuList || limitedExamStuList.isEmpty()) {
|
|
|
|
+ resp.setNextId(nextId);
|
|
|
|
+ resp.setToBeMarkExamRecordBeanList(null);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<PagedToBeMarkExamRecordBean> pagedToBeMarkList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ CourseCacheBean course = CacheHelper.getCourse(limitedExamStuList.get(0).getCourseId());
|
|
|
|
+ for (ExamStudentEntity examStu : limitedExamStuList) {
|
|
|
|
+ //当前考生待阅卷的考试记录
|
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList =
|
|
|
|
+ examRecordForMarkingService.queryValidExamRecordList(examStu.getExamStudentId());
|
|
|
|
+
|
|
|
|
+ for (ExamRecordForMarkingEntity record : examRecordForMarkingList) {
|
|
|
|
+ PagedToBeMarkExamRecordBean pagedBean = new PagedToBeMarkExamRecordBean();
|
|
|
|
+ pagedBean.setExamId(examId);
|
|
|
|
+ pagedBean.setStudentName(examStu.getStudentName());
|
|
|
|
+ pagedBean.setStudentCode(examStu.getStudentCode());
|
|
|
|
+ pagedBean.setCourseCode(courseCode);
|
|
|
|
+ pagedBean.setCourseName(course.getName());
|
|
|
|
+ pagedBean.setPaperType(examStu.getPaperType());
|
|
|
|
+ pagedBean.setExamStudentId(examStu.getExamStudentId());
|
|
|
|
+ pagedBean.setExamRecordDataId(record.getExamRecordDataId());
|
|
|
|
+ pagedBean.setGrade(examStu.getGrade());
|
|
|
|
+
|
|
|
|
+ pagedBean.setSubjectiveAnswerList(
|
|
|
|
+ getSubjectiveAnswerList(record.getExamRecordDataId(), examId, courseCode, examStu.getPaperType()));
|
|
|
|
+
|
|
|
|
+ pagedToBeMarkList.add(pagedBean);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- if (StringUtils.isNullOrEmpty(req.getSubjectCode())) {
|
|
|
|
|
|
+ nextId = limitedExamStuList.get(limitedExamStuList.size() - 1).getId() + 1;
|
|
|
|
+ resp.setNextId(nextId);
|
|
|
|
+ resp.setToBeMarkExamRecordBeanList(pagedToBeMarkList);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取主观题集合
|
|
|
|
+ *
|
|
|
|
+ * @param examRecordDataId
|
|
|
|
+ * @param examId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<PagedToBeMarkSubjectiveAnswerBean> getSubjectiveAnswerList(Long examRecordDataId,
|
|
|
|
+ Long examId, String courseCode, String paperType) {
|
|
|
|
+ List<ExamQuestionEntity> eqList = examRecordQuestionsService.querySubjectiveAnswerList(examRecordDataId);
|
|
|
|
+
|
|
|
|
+ List<PagedToBeMarkSubjectiveAnswerBean> resultList = new ArrayList<>();
|
|
|
|
+ for (ExamQuestionEntity eq : eqList) {
|
|
|
|
+ PagedToBeMarkSubjectiveAnswerBean bean = new PagedToBeMarkSubjectiveAnswerBean();
|
|
|
|
+ bean.setMainNumber(eq.getMainNumber());
|
|
|
|
+ bean.setOrder(eq.getOrder());
|
|
|
|
+ bean.setQuestionId(eq.getQuestionId());
|
|
|
|
+ bean.setStudentAnswer(eq.getStudentAnswer());
|
|
|
|
+ bean.setAnswerType(eq.getAnswerType());
|
|
|
|
+ bean.setAnswer(eq.getCorrectAnswer());
|
|
|
|
+ bean.setQuestionType(eq.getQuestionType());
|
|
|
|
+
|
|
|
|
+ //获取指定小题的题干相关信息
|
|
|
|
+ QuestionCacheBean cachedQues = CacheHelper.getQuestion(examId, courseCode, paperType, eq.getQuestionId());
|
|
|
|
+ bean.setParentBody(getParentBody(cachedQues));
|
|
|
|
+ bean.setBody(getBody(eq.getOrder(), eq.getQuestionId(), cachedQues, eqList));
|
|
|
|
+
|
|
|
|
+ resultList.add(bean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return resultList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取套题的主题干
|
|
|
|
+ *
|
|
|
|
+ * @param cachedQues
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String getParentBody(QuestionCacheBean cachedQues) {
|
|
|
|
+
|
|
|
|
+ DefaultQuestionStructure questionStructure = cachedQues.getDefaultQuestion().getMasterVersion();
|
|
|
|
+
|
|
|
|
+ //如果主题干不为空,则认为是套题
|
|
|
|
+ return questionStructure.getBody();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取当前小题的题干
|
|
|
|
+ *
|
|
|
|
+ * @param curSubNumber 当前小题号
|
|
|
|
+ * @param questionId 原小题id
|
|
|
|
+ * @param cachedQues 带题干的试卷结构
|
|
|
|
+ * @param subjectiveQuesList 主观题集合
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String getBody(Integer curSubNumber, String questionId,
|
|
|
|
+ QuestionCacheBean cachedQues, List<ExamQuestionEntity> subjectiveQuesList) {
|
|
|
|
+ DefaultQuestionStructure questionStructure = cachedQues.getDefaultQuestion().getMasterVersion();
|
|
|
|
+
|
|
|
|
+ //body为空,则说明当前小题为非套题(即questionUnitList集合大小为1),可直接返回小题题干
|
|
|
|
+ if (StringUtils.isNullOrEmpty(questionStructure.getBody())) {
|
|
|
|
+ return questionStructure.getQuestionUnitList().get(0).getBody();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //同一questionId的主观题集合(不带题干)
|
|
|
|
+ List<ExamQuestionEntity> noBodySubjectiveQuesList = subjectiveQuesList.stream().
|
|
|
|
+ filter(p -> p.getQuestionId().equals(questionId)).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ //同一questionId的主观题集合(带题干)
|
|
|
|
+ List<DefaultQuestionUnit> haveBodySubjectiveQuesList = questionStructure.getQuestionUnitList().stream()
|
|
|
|
+ .filter(p -> QuestionType.FILL_UP == p.getQuestionType() || QuestionType.ESSAY == p.getQuestionType())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < noBodySubjectiveQuesList.size(); i++) {
|
|
|
|
+ //如果小题号相同,则根据相同索引从带题干的集合中取出对应的小题题干
|
|
|
|
+ if (noBodySubjectiveQuesList.get(i).getOrder().intValue() == curSubNumber.intValue()) {
|
|
|
|
+ return haveBodySubjectiveQuesList.get(i).getBody();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验待阅卷数据
|
|
|
|
+ *
|
|
|
|
+ * @param examId
|
|
|
|
+ * @param courseCode
|
|
|
|
+ * @param startId
|
|
|
|
+ * @param size
|
|
|
|
+ */
|
|
|
|
+ private void validateToBeMarkData(Long examId, String courseCode, Long startId, Integer size) {
|
|
|
|
+ if (null == examId) {
|
|
|
|
+ throw new StatusException("101001", "考生id不允许为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNullOrEmpty(courseCode)) {
|
|
throw new StatusException("101002", "科目代码不允许为空");
|
|
throw new StatusException("101002", "科目代码不允许为空");
|
|
}
|
|
}
|
|
|
|
|
|
- if (null == req.getStartId()) {
|
|
|
|
|
|
+ if (null == startId) {
|
|
throw new StatusException("101003", "考试记录id不允许为空");
|
|
throw new StatusException("101003", "考试记录id不允许为空");
|
|
}
|
|
}
|
|
|
|
|
|
- if (null == req.getSize()) {
|
|
|
|
|
|
+ if (null == size) {
|
|
throw new StatusException("101004", "数据量大小不允许为空");
|
|
throw new StatusException("101004", "数据量大小不允许为空");
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- GetPagedToBeMarkExamRecordResp resp = new GetPagedToBeMarkExamRecordResp();
|
|
|
|
- return resp;
|
|
|
|
|
|
+ if (size.intValue() > 500) {
|
|
|
|
+ throw new StatusException("101005", "数据量最大不得超过500");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -479,4 +613,5 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
|
|
|
|
return studentAnswer;
|
|
return studentAnswer;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|