|
@@ -81,6 +81,7 @@ 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.SaveRandomPaperExtractConfigDomain;
|
|
|
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.examwork.api.ExamCloudService;
|
|
@@ -1458,4 +1459,54 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
ExtractConfig tempConfig = this.mongoTemplate.findOne(query, ExtractConfig.class);
|
|
|
return tempConfig;
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void saveExtractConfigForRandomPaper(Long rootOrgId, SaveRandomPaperExtractConfigDomain req) {
|
|
|
+ if(rootOrgId==null) {
|
|
|
+ throw new StatusException("rootOrgId不能为空");
|
|
|
+ }
|
|
|
+ GetExamReq examReq=new GetExamReq();
|
|
|
+ examReq.setRootOrgId(rootOrgId);
|
|
|
+ examReq.setName(req.getExamName());
|
|
|
+ examReq.setCode(req.getExamCode());
|
|
|
+ GetExamResp examRes=examCloudService.getExam(examReq);
|
|
|
+ if(!CallType.RANDOM_PAPER.equals(examRes.getExamBean().getCallType())) {
|
|
|
+ throw new StatusException("只能对随机抽题的考试创建调卷规则");
|
|
|
+ }
|
|
|
+ Course course = courseService.getCourse(rootOrgId, req.getCourseCode());
|
|
|
+ GetExamCourseReq settingReq = new GetExamCourseReq();
|
|
|
+ settingReq.setExamId(examRes.getExamBean().getId());
|
|
|
+ settingReq.setCourseId(Long.valueOf(course.getId()));
|
|
|
+ GetExamCourseResp settingResp = examCloudService.getExamCourseSetting(settingReq);
|
|
|
+ if(settingResp.getBean()==null) {
|
|
|
+ throw new StatusException("请先同步考生后再创建相应课程的调卷规则");
|
|
|
+ }
|
|
|
+ List<RandomPaperListVo> rps=randomPaperService.getList(rootOrgId, Long.valueOf(course.getId()));
|
|
|
+ if(CollectionUtils.isEmpty(rps)) {
|
|
|
+ throw new StatusException("没有启用的随机抽题模板");
|
|
|
+ }
|
|
|
+ if(rps.size()>1) {
|
|
|
+ throw new StatusException("存在多个启用的随机抽题模板");
|
|
|
+ }
|
|
|
+ ExtractConfig extractConfig=findConfig(examRes.getExamBean().getId(), req.getCourseCode());
|
|
|
+ if(extractConfig!=null) {
|
|
|
+ extractConfig.setRandomPaperId(rps.get(0).getId());
|
|
|
+ }else {
|
|
|
+ extractConfig=new ExtractConfig();
|
|
|
+ extractConfig.setExamId(examRes.getExamBean().getId());
|
|
|
+ extractConfig.setCallType(CallType.RANDOM_PAPER);
|
|
|
+ extractConfig.setOrgId(rootOrgId.toString());
|
|
|
+ extractConfig.setExamName(examRes.getExamBean().getName());
|
|
|
+ extractConfig.setExamType(examRes.getExamBean().getExamType());
|
|
|
+ extractConfig.setCourseCode(course.getCode());
|
|
|
+ extractConfig.setCourse(course);
|
|
|
+ extractConfig.setCourseName(course.getName());
|
|
|
+ extractConfig.setRandomPaperId(rps.get(0).getId());
|
|
|
+ extractConfig.setPlayTime(1);
|
|
|
+ }
|
|
|
+ extractConfigRepo.save(extractConfig);
|
|
|
+ // 清除缓存
|
|
|
+ extractConfigCache.remove(extractConfig.getExamId(), extractConfig.getCourseCode());
|
|
|
+ }
|
|
|
}
|