|
@@ -10,6 +10,8 @@ import java.util.Random;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.Example;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
@@ -52,6 +54,8 @@ import com.qmth.cqb.utils.word.DocxProcessUtil;
|
|
@Service("extractConfigService")
|
|
@Service("extractConfigService")
|
|
public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(ExtractConfigServiceImpl.class);
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private ExtractConfigRepo extractConfigRepo;
|
|
private ExtractConfigRepo extractConfigRepo;
|
|
|
|
|
|
@@ -119,25 +123,34 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public PaperDto extract(Long exam_id,String course_code,String group_code){
|
|
|
|
|
|
+ public Map<String, Object> extract(Long exam_id,String course_code,String group_code){
|
|
|
|
+ Map<String, Object> returnMap = new HashMap<String,Object>();
|
|
|
|
+ logger.info("调卷开始...");
|
|
|
|
+ logger.info("根据examId和courseCode获取调卷规则");
|
|
ExtractConfig extractConfig = this.findConfig(new ExtractConfig(exam_id,course_code));
|
|
ExtractConfig extractConfig = this.findConfig(new ExtractConfig(exam_id,course_code));
|
|
if(extractConfig==null){
|
|
if(extractConfig==null){
|
|
- throw new RuntimeException("调卷规则不存在");
|
|
|
|
|
|
+ returnMap.put("errorMsg","该考试和课程下调卷规则未制定,请先制定调卷规则");
|
|
|
|
+ return returnMap;
|
|
}
|
|
}
|
|
- //获得规则中设置的试卷
|
|
|
|
|
|
+ logger.info("根据调卷规则中设置的概率获取该类型的试卷");
|
|
Map<String,Paper> paperMap = this.getExamPaperByProbability(extractConfig.getExamPaperList());
|
|
Map<String,Paper> paperMap = this.getExamPaperByProbability(extractConfig.getExamPaperList());
|
|
if(paperMap.isEmpty()){
|
|
if(paperMap.isEmpty()){
|
|
- throw new RuntimeException("抽取试卷失败");
|
|
|
|
|
|
+ returnMap.put("errorMsg","该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
|
|
|
|
+ return returnMap;
|
|
}
|
|
}
|
|
Paper paper = paperMap.get(group_code);
|
|
Paper paper = paperMap.get(group_code);
|
|
if(paper==null){
|
|
if(paper==null){
|
|
- throw new RuntimeException("抽取试卷失败");
|
|
|
|
|
|
+ returnMap.put("errorMsg","该考试和课程下调卷规则中该类型试卷不存在,请重新制定调卷规则");
|
|
|
|
+ return returnMap;
|
|
}
|
|
}
|
|
- //根据规则中设置的试卷重新组卷得到新试卷
|
|
|
|
|
|
+ logger.info("将该类型的试卷根据规则重新组卷");
|
|
Paper newPaper = this.recombinationPaper(paper,
|
|
Paper newPaper = this.recombinationPaper(paper,
|
|
extractConfig.getScrambling_the_question_order(),
|
|
extractConfig.getScrambling_the_question_order(),
|
|
extractConfig.getScrambling_the_option_order());
|
|
extractConfig.getScrambling_the_option_order());
|
|
- return getPaperDtoByPaper(newPaper);
|
|
|
|
|
|
+ logger.info("根据新试卷得到PaperDto后返回");
|
|
|
|
+ returnMap.put("paperDto", getPaperDtoByPaper(newPaper));
|
|
|
|
+ logger.info("调卷结束");
|
|
|
|
+ return returnMap;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -358,6 +371,9 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
PaperDetailUnitDto.class);
|
|
PaperDetailUnitDto.class);
|
|
for (int j = 0; j < paperDetailUnitDtos.size(); j++) {
|
|
for (int j = 0; j < paperDetailUnitDtos.size(); j++) {
|
|
PaperDetailUnitDto unitDto = paperDetailUnitDtos.get(j);
|
|
PaperDetailUnitDto unitDto = paperDetailUnitDtos.get(j);
|
|
|
|
+ if(paperDetailUnits.get(j)==null||paperDetailUnits.get(j).getQuestion()==null){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
unitDto.setQuesId(paperDetailUnits.get(j).getQuestion().getId());
|
|
unitDto.setQuesId(paperDetailUnits.get(j).getQuestion().getId());
|
|
if (StringUtils.isNotEmpty(paperDetailUnits.get(j).getQuestion().getQuesAnswer())) {
|
|
if (StringUtils.isNotEmpty(paperDetailUnits.get(j).getQuestion().getQuesAnswer())) {
|
|
String answer = DocxProcessUtil
|
|
String answer = DocxProcessUtil
|