|
@@ -4,8 +4,12 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.SubjectiveAnswerBean;
|
|
|
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.question.commons.core.question.DefaultQuestionStructure;
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionUnit;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.QuestionCacheBean;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
@@ -195,7 +199,7 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
|
//待阅卷的考试记录集合
|
|
|
List<ToBeMarkExamRecordBean> toBeMarkExamRecordBeanList = new ArrayList<>();
|
|
|
for (Long examStudentId : req.getExamStudentIdList()) {
|
|
|
- ExamStudentEntity examStudent =examStudentRepo.findByExamStudentId(examStudentId);
|
|
|
+ ExamStudentEntity examStudent = examStudentRepo.findByExamStudentId(examStudentId);
|
|
|
|
|
|
if (null == examStudent.getStudentId()) {
|
|
|
throw new StatusException("100101", "考生id:" + examStudentId + "不正确");
|
|
@@ -230,7 +234,8 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
|
toBeMarkExamRecordBean.setExamRecordDataId(markingRecord.getExamRecordDataId());
|
|
|
//待评阅的主观题集合
|
|
|
toBeMarkExamRecordBean.setSubjectiveAnswerList(
|
|
|
- getToBeMarkSubjectiveAnswerList(examRecordData.getExamRecordQuestionsId(), examRecordDataId, examId));
|
|
|
+ getToBeMarkSubjectiveAnswerList(examRecordData.getExamRecordQuestionsId(),
|
|
|
+ examRecordDataId, examId, course.getCode(), examRecordData.getPaperType()));
|
|
|
|
|
|
toBeMarkExamRecordBeanList.add(toBeMarkExamRecordBean);
|
|
|
}
|
|
@@ -269,10 +274,12 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
|
* @param recordQuestionsId
|
|
|
* @param examRecordDataId
|
|
|
* @param examId
|
|
|
+ * @param courseCode
|
|
|
+ * @param paperType
|
|
|
* @return
|
|
|
*/
|
|
|
private List<ToBeMarkSubjectiveAnswerBean> getToBeMarkSubjectiveAnswerList(String recordQuestionsId,
|
|
|
- Long examRecordDataId, Long examId) {
|
|
|
+ Long examRecordDataId, Long examId, String courseCode, String paperType) {
|
|
|
ExamRecordQuestionsEntity questionsEntity;
|
|
|
if (null != recordQuestionsId) {
|
|
|
questionsEntity = GlobalHelper.getEntity(examRecordQuestionsRepo, recordQuestionsId, ExamRecordQuestionsEntity.class);
|
|
@@ -286,16 +293,81 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
|
|
|
p.getQuestionType() == QuestionType.FILL_UP).collect(Collectors.toList());
|
|
|
|
|
|
List<ToBeMarkSubjectiveAnswerBean> subjectiveAnswerBeanList = new ArrayList<>();
|
|
|
- for (ExamQuestionEntity sq : subjectiveQuestionList) {
|
|
|
- ToBeMarkSubjectiveAnswerBean subjectiveAnswerBean = new ToBeMarkSubjectiveAnswerBean();
|
|
|
- subjectiveAnswerBean.setMainNumber(sq.getMainNumber());
|
|
|
- subjectiveAnswerBean.setOrder(sq.getOrder());
|
|
|
- subjectiveAnswerBean.setQuestionId(sq.getQuestionId());
|
|
|
- subjectiveAnswerBean.setStudentAnswer(transformedStudentAnswer(sq.getStudentAnswer()));//格式化过的答案
|
|
|
- subjectiveAnswerBean.setAnswerType(sq.getAnswerType());
|
|
|
- subjectiveAnswerBean.setRealAnswerType(transformedAnswerType(sq.getAnswerType(), sq.getQuestionType(), examId));//实际的作答类型
|
|
|
-
|
|
|
- subjectiveAnswerBeanList.add(subjectiveAnswerBean);
|
|
|
+
|
|
|
+ for (int i = 0; i < subjectiveQuestionList.size(); i++) {
|
|
|
+ ExamQuestionEntity sq = subjectiveQuestionList.get(i);
|
|
|
+
|
|
|
+ ToBeMarkSubjectiveAnswerBean subjectiveAnswerBean;
|
|
|
+
|
|
|
+ //集合中是否已存在当前作答结果(因为套题会提前插入部分数据)
|
|
|
+ String questionId = sq.getQuestionId();
|
|
|
+ Integer order = sq.getOrder();
|
|
|
+ List<ToBeMarkSubjectiveAnswerBean> existSubjectiveAnswerBeanList = subjectiveAnswerBeanList.stream().filter(p -> questionId.equals(p.getQuestionId())
|
|
|
+ && order.equals(p.getOrder())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //如果已经存在,则直接修改,因为套题一次性设置多个小题的题干,所以如果已经设置过就不再设置题干部分
|
|
|
+ if (null != existSubjectiveAnswerBeanList && !existSubjectiveAnswerBeanList.isEmpty()) {
|
|
|
+ subjectiveAnswerBean = existSubjectiveAnswerBeanList.get(0);
|
|
|
+
|
|
|
+ subjectiveAnswerBean.setMainNumber(sq.getMainNumber());
|
|
|
+ subjectiveAnswerBean.setOrder(sq.getOrder());
|
|
|
+ subjectiveAnswerBean.setQuestionId(sq.getQuestionId());
|
|
|
+ subjectiveAnswerBean.setStudentAnswer(transformedStudentAnswer(sq.getStudentAnswer()));//格式化过的答案
|
|
|
+ subjectiveAnswerBean.setAnswerType(sq.getAnswerType());
|
|
|
+ subjectiveAnswerBean.setRealAnswerType(transformedAnswerType(sq.getAnswerType(), sq.getQuestionType(), examId));//实际的作答类型
|
|
|
+
|
|
|
+ subjectiveAnswerBean.setAnswer(sq.getCorrectAnswer());
|
|
|
+ }
|
|
|
+
|
|
|
+ //不存在则重新实例化,并添加
|
|
|
+ else {
|
|
|
+ subjectiveAnswerBean = new ToBeMarkSubjectiveAnswerBean();
|
|
|
+
|
|
|
+ subjectiveAnswerBean.setMainNumber(sq.getMainNumber());
|
|
|
+ subjectiveAnswerBean.setOrder(sq.getOrder());
|
|
|
+ subjectiveAnswerBean.setQuestionId(sq.getQuestionId());
|
|
|
+ subjectiveAnswerBean.setStudentAnswer(transformedStudentAnswer(sq.getStudentAnswer()));//格式化过的答案
|
|
|
+ subjectiveAnswerBean.setAnswerType(sq.getAnswerType());
|
|
|
+ subjectiveAnswerBean.setRealAnswerType(transformedAnswerType(sq.getAnswerType(), sq.getQuestionType(), examId));//实际的作答类型
|
|
|
+
|
|
|
+ subjectiveAnswerBean.setAnswer(sq.getCorrectAnswer());
|
|
|
+
|
|
|
+ /**题干部分相关处理逻辑--start**/
|
|
|
+ //TODO 这是由于历史原因(套题下的小题共享同一个questionId),导致这个恶心的变通实现方式,如果以后优化了套题的结构,可修改
|
|
|
+ QuestionCacheBean getQuestionResp = CacheHelper.getQuestion(examId,
|
|
|
+ courseCode, paperType, questionId);//获取题干相关信息
|
|
|
+ DefaultQuestionStructure questionStructure = getQuestionResp.getDefaultQuestion().getMasterVersion();
|
|
|
+
|
|
|
+ //所有的小题单元
|
|
|
+ List<DefaultQuestionUnit> questionUnits = questionStructure.getQuestionUnitList();
|
|
|
+
|
|
|
+ //如果主题干不为空,则认为是套题(套题需要将大题题干和小题题干拼在一起)
|
|
|
+ String mainBody = questionStructure.getBody();//主题干
|
|
|
+ if (!StringUtils.isNullOrEmpty(mainBody)) {
|
|
|
+ //第1小题的子题干
|
|
|
+ String subBody0 = questionUnits.get(0).getBody();
|
|
|
+
|
|
|
+ //首先将本条数据添加(本条数据是完整的)
|
|
|
+ subjectiveAnswerBean.setBody(mainBody + subBody0);//构建题干
|
|
|
+ subjectiveAnswerBeanList.add(subjectiveAnswerBean);
|
|
|
+
|
|
|
+ //其次,拼装套题的其它几个小题的题干(只初始化题干和唯一标识),并提前添加到结果集中
|
|
|
+ for (int j = 1; j < questionUnits.size(); j++) {
|
|
|
+ ToBeMarkSubjectiveAnswerBean nextSubjectiveAnswerBean = new ToBeMarkSubjectiveAnswerBean();
|
|
|
+ nextSubjectiveAnswerBean.setQuestionId(questionId);
|
|
|
+ nextSubjectiveAnswerBean.setOrder(order + j);
|
|
|
+ nextSubjectiveAnswerBean.setBody(mainBody + questionUnits.get(j).getBody());//构建题干
|
|
|
+ subjectiveAnswerBeanList.add(nextSubjectiveAnswerBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //不是套题,则默认取第一条记录的题干
|
|
|
+ else {
|
|
|
+ subjectiveAnswerBean.setBody(questionUnits.get(0).getBody());//构建题干
|
|
|
+ subjectiveAnswerBeanList.add(subjectiveAnswerBean);
|
|
|
+ }
|
|
|
+ /**题干部分相关处理逻辑--end**/
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return subjectiveAnswerBeanList;
|