|
@@ -1,7 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.service.impl;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.base.Constants;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.NewQuestionType;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.Sentence;
|
|
@@ -11,12 +10,11 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordDataEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordPaperStructEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordPaperStructService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.ExamRecordQuestionsInfo;
|
|
|
-import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
-import cn.com.qmth.examcloud.support.cache.bean.BasePaperCacheBean;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -34,6 +32,8 @@ import java.util.Map;
|
|
|
@Service("examRecordPaperStructService")
|
|
|
public class ExamRecordPaperStructServiceImpl implements ExamRecordPaperStructService {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ExamRecordPaperStructServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamRecordDataRepo examRecordDataRepo;
|
|
|
|
|
@@ -43,54 +43,28 @@ public class ExamRecordPaperStructServiceImpl implements ExamRecordPaperStructSe
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MongoTemplate mongoTemplate;
|
|
|
-
|
|
|
@Override
|
|
|
public ExamRecordPaperStructEntity getExamRecordPaperStruct(Long examRecordDataId) {
|
|
|
Check.isNull(examRecordDataId, "examRecordDataId不能为空");
|
|
|
-
|
|
|
- ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
|
|
|
- if (examRecordDataEntity == null) {
|
|
|
+ ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
|
|
|
+ if (examRecordData == null) {
|
|
|
throw new StatusException("400404", "未找到考试记录数据");
|
|
|
}
|
|
|
|
|
|
- String paperStructId = examRecordDataEntity.getPaperStructId();
|
|
|
- ExamRecordPaperStructEntity examRecordPaperStruct = null;
|
|
|
+ String paperStructId = examRecordData.getPaperStructId();
|
|
|
if (StringUtils.isBlank(paperStructId)) {
|
|
|
- Map<String, Object> paperInfoMap = getPaperInfoFromOeExamQuestion(examRecordDataEntity.getId());
|
|
|
- String paperId = paperInfoMap.get("paper_id").toString();
|
|
|
- //从缓存中获取试卷结构
|
|
|
- BasePaperCacheBean getBasePaperResp = CacheHelper.getBasePaper(paperId);
|
|
|
-
|
|
|
- examRecordPaperStruct = new ExamRecordPaperStructEntity();
|
|
|
- examRecordPaperStruct.setDefaultPaper(getBasePaperResp.getDefaultPaper());
|
|
|
- //保存作答记录
|
|
|
- List<ExamRecordQuestionsInfo> examRecordQuestionList = encapsulationExamQuestion(examRecordDataEntity);
|
|
|
- if (examRecordQuestionList.size() > 0) {
|
|
|
- mongoTemplate.insert(examRecordQuestionList, Constants.EXAM_RECORD_QUESTIONS);
|
|
|
- }
|
|
|
- //保存试卷结构
|
|
|
- examRecordPaperStruct = examRecordPaperStructRepo.save(examRecordPaperStruct);
|
|
|
- //保存考试记录
|
|
|
- //经测试,从oe_exam_question中获取的paperId最准确
|
|
|
- examRecordDataEntity.setBasePaperId(paperId);
|
|
|
- examRecordDataEntity.setPaperType(paperInfoMap.get("paper_type").toString());
|
|
|
- examRecordDataEntity.setPaperStructId(examRecordPaperStruct.getId());
|
|
|
- examRecordDataRepo.save(examRecordDataEntity);
|
|
|
- return examRecordPaperStruct;
|
|
|
+ log.warn("未找到考试试卷结构!paperStructId is null, basePaperId:{} examType:{} examRecordDataId:{}",
|
|
|
+ examRecordData.getBasePaperId(), examRecordData.getExamType(), examRecordData.getId());
|
|
|
+ throw new StatusException("400404", "未找到考试试卷结构");
|
|
|
} else {
|
|
|
- examRecordPaperStruct = GlobalHelper.getEntity(examRecordPaperStructRepo, paperStructId, ExamRecordPaperStructEntity.class);
|
|
|
- return examRecordPaperStruct;
|
|
|
+ return GlobalHelper.getEntity(examRecordPaperStructRepo, paperStructId, ExamRecordPaperStructEntity.class);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 使用examRecordId查询paperId
|
|
|
- *
|
|
|
- * @param examRecordId
|
|
|
- * @return
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
private Map<String, Object> getPaperInfoFromOeExamQuestion(Long examRecordId) {
|
|
|
String sql = "select paper_id,paper_type from oe_exam_question where exam_record_id = " + examRecordId + " limit 1";
|
|
|
Map<String, Object> examQuestionMap = jdbcTemplate.queryForMap(sql);
|
|
@@ -99,9 +73,8 @@ public class ExamRecordPaperStructServiceImpl implements ExamRecordPaperStructSe
|
|
|
|
|
|
/**
|
|
|
* 封装ExamQuestion
|
|
|
- *
|
|
|
- * @param examRecordDataEntity
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
private List<ExamRecordQuestionsInfo> encapsulationExamQuestion(ExamRecordDataEntity examRecordDataEntity) {
|
|
|
List<ExamRecordQuestionsInfo> examRecordQuestionList = new ArrayList<ExamRecordQuestionsInfo>();
|
|
|
ExamRecordQuestionsInfo examRecordQuestion = new ExamRecordQuestionsInfo();
|
|
@@ -146,16 +119,18 @@ public class ExamRecordPaperStructServiceImpl implements ExamRecordPaperStructSe
|
|
|
return examRecordQuestionList;
|
|
|
}
|
|
|
|
|
|
+ @Deprecated
|
|
|
private String selectOldRecordQuestionByExamRecordIdSql(Long examRecordId) {
|
|
|
return new StringBuilder().append("SELECT ")
|
|
|
.append("id,exam_record_id,is_answered,is_multiple,is_nested_question,is_sign,orders,")
|
|
|
.append("main_number,sub_number,base_paper_id,paper_id,paper_name,paper_number,paper_type,")
|
|
|
.append("parent_question_id,question_id,question_type,score,stu_score,answer,stu_answer,create_at")
|
|
|
- .append(" FROM ").append(Constants.OE_EXAM_QUESTION)
|
|
|
+ .append(" FROM oe_exam_question")
|
|
|
.append(" WHERE exam_record_id = ").append(examRecordId)
|
|
|
.append(" ORDER BY orders ASC").toString();
|
|
|
}
|
|
|
|
|
|
+ @Deprecated
|
|
|
private Float computeStudentScore(NewQuestionType questionType, Float questionScore, String correctAnswer, String studentAnswer) {
|
|
|
//若为客观题重新计算考生试题得分
|
|
|
if (questionType == null || !questionType.isObjective()) {
|