|
@@ -1,5 +1,39 @@
|
|
package cn.com.qmth.examcloud.core.questions.service.impl;
|
|
package cn.com.qmth.examcloud.core.questions.service.impl;
|
|
|
|
|
|
|
|
+import static cn.com.qmth.examcloud.core.questions.service.cache.Constants.DEFAULT_TIME_OUT;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Random;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.bson.types.ObjectId;
|
|
|
|
+import org.nlpcn.commons.lang.util.StringUtil;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Example;
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
|
+import org.springframework.data.mongodb.core.query.Update;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.Assert;
|
|
|
|
+
|
|
import cn.com.qmth.examcloud.api.commons.enums.CallType;
|
|
import cn.com.qmth.examcloud.api.commons.enums.CallType;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
|
|
@@ -8,21 +42,47 @@ import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.CheckPaperInExamReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.CheckPaperInExamReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.CheckPaperInExamResp;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.CheckPaperInExamResp;
|
|
import cn.com.qmth.examcloud.core.oe.student.api.ExamRecordDataCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.student.api.ExamRecordDataCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.api.bean.ExtractConfigBean;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.api.bean.ExtractConfigDetailBean;
|
|
import cn.com.qmth.examcloud.core.questions.api.request.SaveRandomPaperExtractConfigReq;
|
|
import cn.com.qmth.examcloud.core.questions.api.request.SaveRandomPaperExtractConfigReq;
|
|
import cn.com.qmth.examcloud.core.questions.base.BeanCopierUtil;
|
|
import cn.com.qmth.examcloud.core.questions.base.BeanCopierUtil;
|
|
import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
import cn.com.qmth.examcloud.core.questions.base.em.enums.ExamType;
|
|
import cn.com.qmth.examcloud.core.questions.base.em.enums.ExamType;
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
|
|
-import cn.com.qmth.examcloud.core.questions.base.question.*;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.question.PaperDetailDto;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.question.PaperDetailUnitDto;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.question.PaperDto;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.question.QuesOptionDto;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.question.QuestionDto;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.question.SubQuestionDto;
|
|
import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
|
|
import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
|
|
-import cn.com.qmth.examcloud.core.questions.dao.*;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.*;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.AudioTimeConfigRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.ExtractConfigRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.PaperRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.RandomPaperRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.AudioTimeConfig;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.ExamPaper;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.ExtractConfig;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetail;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuesOption;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionAudio;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.RandomPaper;
|
|
import cn.com.qmth.examcloud.core.questions.service.ExtractConfigService;
|
|
import cn.com.qmth.examcloud.core.questions.service.ExtractConfigService;
|
|
import cn.com.qmth.examcloud.core.questions.service.QuesService;
|
|
import cn.com.qmth.examcloud.core.questions.service.QuesService;
|
|
import cn.com.qmth.examcloud.core.questions.service.QuestionAudioService;
|
|
import cn.com.qmth.examcloud.core.questions.service.QuestionAudioService;
|
|
import cn.com.qmth.examcloud.core.questions.service.RandomPaperService;
|
|
import cn.com.qmth.examcloud.core.questions.service.RandomPaperService;
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.*;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.CouresInfo;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.PaperDetailDtoAssembler;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.PaperDetailUnitDtoAssembler;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.PaperDtoAssembler;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.SubQuestionDtoAssembler;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.extract.SaveRandomPaperExtractConfigForToolDomain;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.extract.SaveRandomPaperExtractConfigForToolDomain;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.RandomPaperListVo;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.RandomPaperListVo;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.ExtractConfigCache;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.ExtractConfigCache;
|
|
@@ -38,32 +98,6 @@ import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
|
|
import cn.com.qmth.examcloud.support.CacheConstants;
|
|
import cn.com.qmth.examcloud.support.CacheConstants;
|
|
import cn.com.qmth.examcloud.support.fss.FssHelper;
|
|
import cn.com.qmth.examcloud.support.fss.FssHelper;
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
-import org.bson.types.ObjectId;
|
|
|
|
-import org.nlpcn.commons.lang.util.StringUtil;
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.data.domain.Example;
|
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
|
-import org.springframework.data.domain.PageImpl;
|
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
|
-import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
-import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
|
-import org.springframework.data.mongodb.core.query.Query;
|
|
|
|
-import org.springframework.data.mongodb.core.query.Update;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-import org.springframework.util.Assert;
|
|
|
|
-
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.regex.Matcher;
|
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
-import static cn.com.qmth.examcloud.core.questions.service.cache.Constants.DEFAULT_TIME_OUT;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author chenken
|
|
* @author chenken
|
|
@@ -226,7 +260,8 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
Example<RandomPaper> queryExample = Example.of(query);
|
|
Example<RandomPaper> queryExample = Example.of(query);
|
|
boolean exists = randomPaperRepo.exists(queryExample);
|
|
boolean exists = randomPaperRepo.exists(queryExample);
|
|
if (!exists) {
|
|
if (!exists) {
|
|
- LOG.warn("随机抽题模板选择错误,与当前课程不匹配! courseId:{} randomPaperId:{}", course.getId(), extractConfig.getRandomPaperId());
|
|
|
|
|
|
+ LOG.warn("随机抽题模板选择错误,与当前课程不匹配! courseId:{} randomPaperId:{}", course.getId(),
|
|
|
|
+ extractConfig.getRandomPaperId());
|
|
throw new StatusException("500", "随机抽题模板选择错误,与当前课程不匹配!");
|
|
throw new StatusException("500", "随机抽题模板选择错误,与当前课程不匹配!");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -269,10 +304,10 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
for (ExamPaper paper : ec.getExamPaperList()) {
|
|
for (ExamPaper paper : ec.getExamPaperList()) {
|
|
- if (inExam(paper.getPaper().getId())) {//如果有考试记录
|
|
|
|
|
|
+ if (inExam(paper.getPaper().getId())) {// 如果有考试记录
|
|
updatePaperInUse(paper.getPaper().getId(), 1);
|
|
updatePaperInUse(paper.getPaper().getId(), 1);
|
|
} else {
|
|
} else {
|
|
- if (!inOtherExtractConfig(extractConfigId, paper.getPaper().getId())) {//没有考试记录且不被其他调卷规则引用
|
|
|
|
|
|
+ if (!inOtherExtractConfig(extractConfigId, paper.getPaper().getId())) {// 没有考试记录且不被其他调卷规则引用
|
|
updatePaperInUse(paper.getPaper().getId(), 0);
|
|
updatePaperInUse(paper.getPaper().getId(), 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -428,7 +463,8 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
@Override
|
|
@Override
|
|
public boolean checkIsAllQbjectiveQuestion(String paperId) {
|
|
public boolean checkIsAllQbjectiveQuestion(String paperId) {
|
|
// 优先从redis中获取缓存dto
|
|
// 优先从redis中获取缓存dto
|
|
- PaperDto cachePaperDto = redisClient.get(CacheConstants.CACHE_Q_TEMP_PAPER + paperId, PaperDto.class, DEFAULT_TIME_OUT);
|
|
|
|
|
|
+ PaperDto cachePaperDto = redisClient.get(CacheConstants.CACHE_Q_TEMP_PAPER + paperId, PaperDto.class,
|
|
|
|
+ DEFAULT_TIME_OUT);
|
|
if (cachePaperDto != null) {
|
|
if (cachePaperDto != null) {
|
|
return cachePaperDto.isAllQbjectiveQuestion();
|
|
return cachePaperDto.isAllQbjectiveQuestion();
|
|
}
|
|
}
|
|
@@ -491,7 +527,8 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
String key = entry.getKey();
|
|
String key = entry.getKey();
|
|
// 根据原有试卷重新组卷得到新试卷
|
|
// 根据原有试卷重新组卷得到新试卷
|
|
/*
|
|
/*
|
|
- * Paper newPaper = this.recombinationPaper(entry.getValue(), PaperType.PREVIEW,
|
|
|
|
|
|
+ * Paper newPaper = this.recombinationPaper(entry.getValue(),
|
|
|
|
+ * PaperType.PREVIEW,
|
|
* extractConfig.getScrambling_the_question_order(),
|
|
* extractConfig.getScrambling_the_question_order(),
|
|
* extractConfig.getScrambling_the_option_order());
|
|
* extractConfig.getScrambling_the_option_order());
|
|
*/
|
|
*/
|
|
@@ -503,9 +540,12 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
/**
|
|
/**
|
|
* 重组试卷,生成新的试卷
|
|
* 重组试卷,生成新的试卷
|
|
*
|
|
*
|
|
- * @param paper 选中的试卷
|
|
|
|
- * @param upSetQuestionOrder 客观题小题乱序 1:乱序 0:不乱序
|
|
|
|
- * @param upSetOptionOrder 客观题选项乱序 1:乱序 0:不乱序
|
|
|
|
|
|
+ * @param paper
|
|
|
|
+ * 选中的试卷
|
|
|
|
+ * @param upSetQuestionOrder
|
|
|
|
+ * 客观题小题乱序 1:乱序 0:不乱序
|
|
|
|
+ * @param upSetOptionOrder
|
|
|
|
+ * 客观题选项乱序 1:乱序 0:不乱序
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public Paper recombinationPaper(Paper paper, PaperType paperType, int upSetQuestionOrder, int upSetOptionOrder) {
|
|
public Paper recombinationPaper(Paper paper, PaperType paperType, int upSetQuestionOrder, int upSetOptionOrder) {
|
|
@@ -945,7 +985,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public QuestionDto extractExamQuestion(String examId, String courseCode, String groupCode,
|
|
public QuestionDto extractExamQuestion(String examId, String courseCode, String groupCode,
|
|
- String paperDetailUnitId) {
|
|
|
|
|
|
+ String paperDetailUnitId) {
|
|
PaperDetailUnit paperDetailUnit = Model.of(paperDetailUnitRepo.findById(paperDetailUnitId));
|
|
PaperDetailUnit paperDetailUnit = Model.of(paperDetailUnitRepo.findById(paperDetailUnitId));
|
|
List<PaperDetailUnit> paperDetailUnits = new ArrayList<>();
|
|
List<PaperDetailUnit> paperDetailUnits = new ArrayList<>();
|
|
paperDetailUnits.add(paperDetailUnit);
|
|
paperDetailUnits.add(paperDetailUnit);
|
|
@@ -1116,7 +1156,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Page<ExtractConfig> findPageExtractConfig(int currentPage, int pageSize, Long examId, String courseCode,
|
|
public Page<ExtractConfig> findPageExtractConfig(int currentPage, int pageSize, Long examId, String courseCode,
|
|
- String orgId, UserDataRule ud) {
|
|
|
|
|
|
+ String orgId, UserDataRule ud) {
|
|
if (ud.assertEmptyQueryResult()) {
|
|
if (ud.assertEmptyQueryResult()) {
|
|
return Page.empty();
|
|
return Page.empty();
|
|
}
|
|
}
|
|
@@ -1402,7 +1442,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
GetExamCourseListReq req = new GetExamCourseListReq();
|
|
GetExamCourseListReq req = new GetExamCourseListReq();
|
|
req.setExamId(examRes.getExamBean().getId());
|
|
req.setExamId(examRes.getExamBean().getId());
|
|
Long start = 1L;
|
|
Long start = 1L;
|
|
- for (; ; ) {
|
|
|
|
|
|
+ for (;;) {
|
|
req.setStart(start);
|
|
req.setStart(start);
|
|
GetExamCourseListResp resp = examCloudService.getExamCourseList(req);
|
|
GetExamCourseListResp resp = examCloudService.getExamCourseList(req);
|
|
courseInfoList.addAll(resp.getRelationList());
|
|
courseInfoList.addAll(resp.getRelationList());
|
|
@@ -1425,11 +1465,13 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
private void createByCourse(Long rootOrgId, ExamBean examBean, ExamCourseRelationBean course) {
|
|
private void createByCourse(Long rootOrgId, ExamBean examBean, ExamCourseRelationBean course) {
|
|
List<RandomPaperListVo> rps = randomPaperService.getList(rootOrgId, course.getCourseId());
|
|
List<RandomPaperListVo> rps = randomPaperService.getList(rootOrgId, course.getCourseId());
|
|
if (CollectionUtils.isEmpty(rps)) {
|
|
if (CollectionUtils.isEmpty(rps)) {
|
|
- LOG.warn("==>没有启用的随机抽题模板!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, examBean.getId(), course.getCourseCode());
|
|
|
|
|
|
+ LOG.warn("==>没有启用的随机抽题模板!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, examBean.getId(),
|
|
|
|
+ course.getCourseCode());
|
|
throw new StatusException(course.getCourseName() + ",没有启用的随机抽题模板");
|
|
throw new StatusException(course.getCourseName() + ",没有启用的随机抽题模板");
|
|
}
|
|
}
|
|
if (rps.size() > 1) {
|
|
if (rps.size() > 1) {
|
|
- LOG.warn("==>存在多个启用的随机抽题模板!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, examBean.getId(), course.getCourseCode());
|
|
|
|
|
|
+ LOG.warn("==>存在多个启用的随机抽题模板!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, examBean.getId(),
|
|
|
|
+ course.getCourseCode());
|
|
throw new StatusException("存在多个启用的随机抽题模板");
|
|
throw new StatusException("存在多个启用的随机抽题模板");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1448,7 +1490,8 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
extractConfig.setCallType(CallType.RANDOM_PAPER);
|
|
extractConfig.setCallType(CallType.RANDOM_PAPER);
|
|
extractConfig.setPlayTime(1);
|
|
extractConfig.setPlayTime(1);
|
|
extractConfigRepo.save(extractConfig);
|
|
extractConfigRepo.save(extractConfig);
|
|
- LOG.warn("==>创建随机抽卷调卷规则成功!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, examBean.getId(), course.getCourseCode());
|
|
|
|
|
|
+ LOG.warn("==>创建随机抽卷调卷规则成功!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, examBean.getId(),
|
|
|
|
+ course.getCourseCode());
|
|
|
|
|
|
// 清除缓存
|
|
// 清除缓存
|
|
extractConfigCache.remove(extractConfig.getExamId(), extractConfig.getCourseCode());
|
|
extractConfigCache.remove(extractConfig.getExamId(), extractConfig.getCourseCode());
|
|
@@ -1499,16 +1542,19 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
GetExamCourseResp settingResp = examCloudService.getExamCourseSetting(settingReq);
|
|
GetExamCourseResp settingResp = examCloudService.getExamCourseSetting(settingReq);
|
|
|
|
|
|
if (settingResp.getBean() == null) {
|
|
if (settingResp.getBean() == null) {
|
|
- LOG.warn("-->当前考试课程不存在!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, req.getExamId(), req.getCourseCode());
|
|
|
|
|
|
+ LOG.warn("-->当前考试课程不存在!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, req.getExamId(),
|
|
|
|
+ req.getCourseCode());
|
|
throw new StatusException("请先同步考生后再创建相应课程的调卷规则");
|
|
throw new StatusException("请先同步考生后再创建相应课程的调卷规则");
|
|
}
|
|
}
|
|
List<RandomPaperListVo> rps = randomPaperService.getList(rootOrgId, Long.valueOf(course.getId()));
|
|
List<RandomPaperListVo> rps = randomPaperService.getList(rootOrgId, Long.valueOf(course.getId()));
|
|
if (CollectionUtils.isEmpty(rps)) {
|
|
if (CollectionUtils.isEmpty(rps)) {
|
|
- LOG.warn("-->没有启用的随机抽题模板!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, req.getExamId(), req.getCourseCode());
|
|
|
|
|
|
+ LOG.warn("-->没有启用的随机抽题模板!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, req.getExamId(),
|
|
|
|
+ req.getCourseCode());
|
|
throw new StatusException("没有启用的随机抽题模板");
|
|
throw new StatusException("没有启用的随机抽题模板");
|
|
}
|
|
}
|
|
if (rps.size() > 1) {
|
|
if (rps.size() > 1) {
|
|
- LOG.warn("-->存在多个启用的随机抽题模板!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, req.getExamId(), req.getCourseCode());
|
|
|
|
|
|
+ LOG.warn("-->存在多个启用的随机抽题模板!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, req.getExamId(),
|
|
|
|
+ req.getCourseCode());
|
|
throw new StatusException("存在多个启用的随机抽题模板");
|
|
throw new StatusException("存在多个启用的随机抽题模板");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1527,10 +1573,78 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
extractConfig.setRandomPaperId(rps.get(0).getId());
|
|
extractConfig.setRandomPaperId(rps.get(0).getId());
|
|
extractConfig.setPlayTime(1);
|
|
extractConfig.setPlayTime(1);
|
|
extractConfigRepo.save(extractConfig);
|
|
extractConfigRepo.save(extractConfig);
|
|
- LOG.warn("-->创建随机抽卷调卷规则成功!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, req.getExamId(), req.getCourseCode());
|
|
|
|
|
|
+ LOG.warn("-->创建随机抽卷调卷规则成功!rootOrgId:{} examId:{} courseCode:{}", rootOrgId, req.getExamId(),
|
|
|
|
+ req.getCourseCode());
|
|
|
|
|
|
// 清除缓存
|
|
// 清除缓存
|
|
extractConfigCache.remove(extractConfig.getExamId(), extractConfig.getCourseCode());
|
|
extractConfigCache.remove(extractConfig.getExamId(), extractConfig.getCourseCode());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<ExtractConfigBean> getExtractConfigList(Long examId) {
|
|
|
|
+ if (examId == null) {
|
|
|
|
+ throw new StatusException("考试id不能为空");
|
|
|
|
+ }
|
|
|
|
+ List<ExtractConfig> ecs = findConfigListByExam(examId);
|
|
|
|
+ if (CollectionUtils.isEmpty(ecs)) {
|
|
|
|
+ throw new StatusException("该考试调卷规则未制定");
|
|
|
|
+ }
|
|
|
|
+ List<ExtractConfigBean> ret = new ArrayList<>();
|
|
|
|
+ for (ExtractConfig extractConfig : ecs) {
|
|
|
|
+ if (CallType.WHOLE_SET.equals(extractConfig.getCallType())) {
|
|
|
|
+ if (CollectionUtils.isEmpty(extractConfig.getExamPaperList())) {
|
|
|
|
+ throw new StatusException("可供抽取的试卷集合为空!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExtractConfigBean cacheBean = new ExtractConfigBean();
|
|
|
|
+ ret.add(cacheBean);
|
|
|
|
+ cacheBean.setId(extractConfig.getId());
|
|
|
|
+ cacheBean.setExamId(examId);
|
|
|
|
+ cacheBean.setCallType(extractConfig.getCallType());
|
|
|
|
+ cacheBean.setCourseCode(extractConfig.getCourseCode());
|
|
|
|
+ cacheBean.setRandomPaperId(extractConfig.getRandomPaperId());
|
|
|
|
+ cacheBean.setPlayTime(extractConfig.getPlayTime());
|
|
|
|
+ cacheBean.setSortQuestionOrder(getByShort(extractConfig.getScrambling_the_question_order()));
|
|
|
|
+ cacheBean.setSortOptionOrder(getByShort(extractConfig.getScrambling_the_option_order()));
|
|
|
|
+
|
|
|
|
+ if (CallType.WHOLE_SET.equals(extractConfig.getCallType())) {
|
|
|
|
+ List<ExtractConfigDetailBean> details = new ArrayList<>();
|
|
|
|
+ for (ExamPaper examPaper : extractConfig.getExamPaperList()) {
|
|
|
|
+ details.add(new ExtractConfigDetailBean(examPaper.getGroupCode(), examPaper.getPaper().getId(),
|
|
|
|
+ examPaper.getWeight()));
|
|
|
|
+ }
|
|
|
|
+ cacheBean.setDetails(details);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean getByShort(Short s) {
|
|
|
|
+ if (s == null) {
|
|
|
|
+ return false;
|
|
|
|
+ } else {
|
|
|
|
+ return s != 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<ExtractConfig> findConfigListByExam(Long examId) {
|
|
|
|
+ if (examId == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Query query = new Query();
|
|
|
|
+ query.addCriteria(Criteria.where("examId").is(examId));
|
|
|
|
+
|
|
|
|
+ List<ExtractConfig> list = this.mongoTemplate.find(query, ExtractConfig.class);
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
+ for (ExtractConfig ec : list) {
|
|
|
|
+ if (ec != null && ec.getCallType() == null) {
|
|
|
|
+ ec.setCallType(CallType.WHOLE_SET);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
}
|
|
}
|