|
@@ -8,15 +8,16 @@
|
|
|
package cn.com.qmth.examcloud.core.print.service.impl;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
-import cn.com.qmth.examcloud.core.print.common.Constants;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.OrderBuilder;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
|
+import cn.com.qmth.examcloud.core.print.common.utils.JsonMapper;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.ExamQuestionStructure;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.ExamStructure;
|
|
|
import cn.com.qmth.examcloud.core.print.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.core.print.repository.ExamStructureRepository;
|
|
|
+import cn.com.qmth.examcloud.core.print.repository.ObjectiveQuestionStructureRepository;
|
|
|
import cn.com.qmth.examcloud.core.print.service.ExamStructureService;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.examstructure.ExamStructureConvert;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.examstructure.ExamStructureInfo;
|
|
@@ -30,6 +31,8 @@ import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
|
|
|
+
|
|
|
/**
|
|
|
* @author: fengdesheng
|
|
|
* @since: 2018/10/17
|
|
@@ -41,6 +44,8 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
|
private static final Logger log = LoggerFactory.getLogger(ExamStructureServiceImpl.class);
|
|
|
@Autowired
|
|
|
private ExamStructureRepository examStructureRepository;
|
|
|
+ @Autowired
|
|
|
+ private ObjectiveQuestionStructureRepository objectiveQuestionStructureRepository;
|
|
|
|
|
|
@Override
|
|
|
public Page<ExamStructureInfo> getExamStructureList(ExamStructureQuery query) {
|
|
@@ -66,7 +71,7 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
|
Check.isEmpty(query.getOrgId(), "学校ID不能为空!");
|
|
|
Check.isEmpty(query.getExamId(), "考试ID不能为空!");
|
|
|
- ExamStructure entity = examStructureRepository.findByExamIdAndOrgId(query.getExamId(), query.getOrgId());
|
|
|
+ ExamStructure entity = examStructureRepository.findByOrgIdAndExamId(query.getOrgId(), query.getExamId());
|
|
|
if (entity == null) {
|
|
|
return null;
|
|
|
}
|
|
@@ -91,6 +96,39 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
|
examStructureRepository.save(entity);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void checkExamStructure(Long orgId, Long examId, String paperId) {
|
|
|
+ Check.isNull(orgId, "学校ID不能为空!");
|
|
|
+ Check.isNull(examId, "考试ID不能为空!");
|
|
|
+ Check.isEmpty(paperId, "试卷ID不能为空!");
|
|
|
+
|
|
|
+ ExamStructure entity = examStructureRepository.findByOrgIdAndExamId(orgId, examId);
|
|
|
+ if (entity == null) {
|
|
|
+ throw new StatusException(PRT_CODE_500, "当前考试尚未创建考试结构!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //考试结构设置的客观题数量
|
|
|
+ ExamQuestionStructure questionStructure = new JsonMapper().fromJson(entity.getStruct(), ExamQuestionStructure.class);
|
|
|
+
|
|
|
+ //校验考试结构中的单选题数量
|
|
|
+ /*long singleChoiceSize = objectiveQuestionStructureRepository.countByExamIdAndPaperIdAndQuestionType(examId, paperId, QuesStructType.SINGLE_ANSWER_QUESTION.name());
|
|
|
+ if (singleChoiceSize > questionStructure.getSingleChoiceTotal()) {
|
|
|
+ throw new StatusException(PRT_CODE_500, String.format("考试结构中%s题数量小于试卷题目数量,需重新设置!", QuesStructType.SINGLE_ANSWER_QUESTION.getTitle()));
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //校验考试结构中的多选题数量
|
|
|
+ /*long multipleChoiceSize = objectiveQuestionStructureRepository.countByExamIdAndPaperIdAndQuestionType(examId, paperId, QuesStructType.MULTIPLE_ANSWER_QUESTION.name());
|
|
|
+ if (multipleChoiceSize > questionStructure.getMultipleChoiceTotal()) {
|
|
|
+ throw new StatusException(PRT_CODE_500, String.format("考试结构中%s题数量小于试卷题目数量,需重新设置!", QuesStructType.MULTIPLE_ANSWER_QUESTION.getTitle()));
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //校验考试结构中的判断题数量
|
|
|
+ /*long boolQuestionSize = objectiveQuestionStructureRepository.countByExamIdAndPaperIdAndQuestionType(examId, paperId, QuesStructType.BOOL_ANSWER_QUESTION.name());
|
|
|
+ if (boolQuestionSize > questionStructure.getBoolQuestionTotal()) {
|
|
|
+ throw new StatusException(PRT_CODE_500, String.format("考试结构中%s题数量小于试卷题目数量,需重新设置!", QuesStructType.BOOL_ANSWER_QUESTION.getTitle()));
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void deleteExamStructure(Long[] ids) {
|
|
|
if (ids == null || ids.length == 0) {
|
|
@@ -116,14 +154,14 @@ public class ExamStructureServiceImpl implements ExamStructureService {
|
|
|
Check.isNull(info.getExamId(), "新考试ID不能为空!");
|
|
|
Check.isBlank(info.getNewExamName(), "新考试名称不能为空!");
|
|
|
|
|
|
- ExamStructure newStructure = examStructureRepository.findByExamIdAndOrgId(info.getNewExamId(), info.getNewOrgId());
|
|
|
+ ExamStructure newStructure = examStructureRepository.findByOrgIdAndExamId(info.getNewOrgId(), info.getNewExamId());
|
|
|
if (newStructure != null) {
|
|
|
- throw new StatusException(Constants.PRT_CODE_500, "新学校考试下已有结构信息,不可复用!");
|
|
|
+ throw new StatusException(PRT_CODE_500, "新学校考试下已有结构信息,不可复用!");
|
|
|
}
|
|
|
|
|
|
- ExamStructure oldStructure = examStructureRepository.findByExamIdAndOrgId(info.getExamId(), info.getOrgId());
|
|
|
+ ExamStructure oldStructure = examStructureRepository.findByOrgIdAndExamId(info.getOrgId(), info.getExamId());
|
|
|
if (oldStructure == null) {
|
|
|
- throw new StatusException(Constants.PRT_CODE_500, "原结构信息不存在!");
|
|
|
+ throw new StatusException(PRT_CODE_500, "原结构信息不存在!");
|
|
|
}
|
|
|
|
|
|
newStructure = new ExamStructure();
|