|
@@ -121,16 +121,17 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
* @return
|
|
|
*/
|
|
|
private Map<String, Paper> getExamPaperByProbability(List<ExamPaper> examPaperList) {
|
|
|
- Map<String, Paper> paperByTypeMap = new HashMap<String, Paper>();
|
|
|
+ Map<String, Paper> paperByTypeMap = new HashMap<>();
|
|
|
if (examPaperList == null || examPaperList.size() == 0) {
|
|
|
throw new StatusException("Q-020114", "可供抽取的试卷集合为空,无法抽取试卷");
|
|
|
}
|
|
|
- Map<String, List<ExamPaper>> examPaperMap = new HashMap<String, List<ExamPaper>>();
|
|
|
+
|
|
|
+ Map<String, List<ExamPaper>> examPaperMap = new HashMap<>();
|
|
|
for (int i = 0; i < examPaperList.size(); i++) {
|
|
|
ExamPaper examPaper = examPaperList.get(i);
|
|
|
if (!examPaperMap.containsKey(examPaper.getGroupCode())) {
|
|
|
if (examPaper.getPaper() != null) {
|
|
|
- List<ExamPaper> epList = new ArrayList<ExamPaper>();
|
|
|
+ List<ExamPaper> epList = new ArrayList<>();
|
|
|
epList.add(examPaper);
|
|
|
examPaperMap.put(examPaper.getGroupCode(), epList);
|
|
|
}
|
|
@@ -141,6 +142,7 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (examPaperMap != null) {
|
|
|
Set<String> keys = examPaperMap.keySet();
|
|
|
Iterator<String> it = keys.iterator();
|
|
@@ -166,6 +168,7 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
for (int i = 0; i < examPaperList.size(); i++) {
|
|
|
sum += examPaperList.get(i).getWeight();
|
|
|
}
|
|
|
+
|
|
|
// 从1开始
|
|
|
Integer rand = new Random().nextInt(sum) + 1;
|
|
|
for (int i = 0; i < examPaperList.size(); i++) {
|
|
@@ -175,6 +178,7 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
return examPaperList.get(i).getPaper();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -190,23 +194,21 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
|
|
|
//获取大题
|
|
|
List<PaperDetail> paperDetails = paperDetailRepo.findByPaper(basePaper);
|
|
|
- long pdTime = System.currentTimeMillis();
|
|
|
- log.debug("数据库取大题耗时:" + (pdTime - beginTime) + "ms");
|
|
|
+ log.debug("数据库取大题耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
|
|
|
|
|
|
+ //排序大题
|
|
|
Collections.sort(paperDetails);
|
|
|
- long pdSortEndTime = System.currentTimeMillis();
|
|
|
- log.debug("排序大题耗时:" + (pdSortEndTime - pdTime) + "ms");
|
|
|
|
|
|
//将小题全部取出来,只取一次,减少对数据库的查询
|
|
|
+ beginTime = System.currentTimeMillis();
|
|
|
List<PaperDetailUnit> allPaperDetailUnits = paperDetailUnitRepo.findByPaper(basePaper);
|
|
|
boolean fullyObjective = checkIsAllQbjectiveQuestion(allPaperDetailUnits);
|
|
|
- long pduEndTime = System.currentTimeMillis();
|
|
|
- log.debug("数据库取所有小题耗时:" + (pduEndTime - pdSortEndTime) + "ms");
|
|
|
+ log.debug("数据库取所有小题耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
|
|
|
|
|
|
//根据大题id将小题归类
|
|
|
+ beginTime = System.currentTimeMillis();
|
|
|
Map<String, List<PaperDetailUnit>> pduMap = allPaperDetailUnits.stream().collect(Collectors.groupingBy(PaperDetailUnit::getDetailId));
|
|
|
- long pduMapEndTime = System.currentTimeMillis();
|
|
|
- log.debug("获取大题与小题对应关系耗时:" + (pduMapEndTime - pduEndTime) + "ms");
|
|
|
+ log.debug("获取大题与小题对应关系耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
|
|
|
|
|
|
log.debug("循环大题,开始组装对象...");
|
|
|
//生成新的分组集合
|
|
@@ -286,16 +288,17 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
* @return
|
|
|
*/
|
|
|
private DefaultQuestionUnitWrapper buildQuesUnitWrapper(Question question, Double score) {
|
|
|
- DefaultQuestionUnitWrapper defaultQuestionUnitWrapper = new DefaultQuestionUnitWrapper();
|
|
|
Integer[] optionPermutation = null;
|
|
|
- if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION ||
|
|
|
- question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
|
|
|
+ if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
|
|
|
int length = question.getQuesOptions().size();
|
|
|
optionPermutation = new Integer[length];
|
|
|
+
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
optionPermutation[i] = i;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ DefaultQuestionUnitWrapper defaultQuestionUnitWrapper = new DefaultQuestionUnitWrapper();
|
|
|
defaultQuestionUnitWrapper.setOptionPermutation(optionPermutation);
|
|
|
defaultQuestionUnitWrapper.setQuestionScore(score);
|
|
|
defaultQuestionUnitWrapper.setQuestionType(getByOldType(question.getQuestionType()));
|
|
@@ -328,18 +331,20 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public DefaultQuestion getDefaultQuestion(Long examId, String courseCode, String groupCode, String questionId) {
|
|
|
log.debug("网考根据调卷规则中试题id:" + questionId + "获取单个试题...");
|
|
|
long beginTime = System.currentTimeMillis();
|
|
|
+
|
|
|
Question question = Model.of(quesRepo.findById(questionId));
|
|
|
if (question == null) {
|
|
|
throw new StatusException("Q-020330", "question is null");
|
|
|
}
|
|
|
quesService.formatQues(question);
|
|
|
- long oldQuesTime = System.currentTimeMillis();
|
|
|
- log.debug("查询单个试题耗时:" + (oldQuesTime - beginTime) + "ms");
|
|
|
+ log.debug("查询单个试题耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
|
|
|
+
|
|
|
+ //封装成新的题单元集合
|
|
|
+ beginTime = System.currentTimeMillis();
|
|
|
DefaultQuestionStructure defaultQuestionStructure = new DefaultQuestionStructure();
|
|
|
if (question.getHasAudio() == null || false == question.getHasAudio()) {
|
|
|
defaultQuestionStructure.setHasAudios(false);
|
|
@@ -347,13 +352,14 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
defaultQuestionStructure.setHasAudios(true);
|
|
|
}
|
|
|
defaultQuestionStructure.setVersion(CommonUtils.QUESTION_VERSION);
|
|
|
- //生成新的题单元集合
|
|
|
- List<DefaultQuestionUnit> questionUnitList = new ArrayList<DefaultQuestionUnit>();
|
|
|
+
|
|
|
+ List<DefaultQuestionUnit> questionUnitList = new ArrayList<>();
|
|
|
if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
defaultQuestionStructure.setBody(question.getQuesBody());
|
|
|
+
|
|
|
//获取套题下面所有子题
|
|
|
List<Question> subQuesList = question.getSubQuestions();
|
|
|
- if (subQuesList != null && subQuesList.size() > 0) {
|
|
|
+ if (CollectionUtils.isNotEmpty(subQuesList)) {
|
|
|
for (int i = 0; i < subQuesList.size(); i++) {
|
|
|
Question subQuestion = subQuesList.get(i);
|
|
|
DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(subQuestion);
|
|
@@ -364,19 +370,18 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(question);
|
|
|
questionUnitList.add(defaultQuestionUnit);
|
|
|
}
|
|
|
+
|
|
|
defaultQuestionStructure.setQuestionUnitList(questionUnitList);
|
|
|
DefaultQuestion defaultQuestion = new DefaultQuestion();
|
|
|
defaultQuestion.setId(questionId);
|
|
|
defaultQuestion.setMasterVersion(defaultQuestionStructure);
|
|
|
- long newQuesTime = System.currentTimeMillis();
|
|
|
- log.debug("构建一个新的试题单元耗时:" + (newQuesTime - oldQuesTime) + "ms");
|
|
|
- //替换试题单元中的音频路径
|
|
|
- log.debug("给新的试题替换音频标签...");
|
|
|
+
|
|
|
if (examId != null) {
|
|
|
+ log.debug("替换试题单元中的音频路径...");
|
|
|
appendAudioFlag(defaultQuestion, String.valueOf(examId), courseCode, groupCode, question);
|
|
|
}
|
|
|
- long finishTime = System.currentTimeMillis();
|
|
|
- log.debug("给新的试题替换音频标签耗时:" + (finishTime - newQuesTime) + "ms");
|
|
|
+
|
|
|
+ log.debug("封装成新的题单元集合耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
|
|
|
return defaultQuestion;
|
|
|
}
|
|
|
|
|
@@ -391,10 +396,13 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
defaultQuestionUnit.setAnswerType(question.getAnswerType());//作答类型
|
|
|
defaultQuestionUnit.setBody(question.getQuesBody());
|
|
|
defaultQuestionUnit.setQuestionType(getByOldType(question.getQuestionType()));
|
|
|
+
|
|
|
//如果是单选或者多选,添加选项和答案转换
|
|
|
- if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
|
|
|
- List<DefaultQuestionOption> defaultQuestionOptions = new ArrayList<DefaultQuestionOption>();
|
|
|
+ if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|
+ || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
|
|
|
+ List<DefaultQuestionOption> defaultQuestionOptions = new ArrayList<>();
|
|
|
List<QuesOption> quesOptions = question.getQuesOptions();
|
|
|
+
|
|
|
if (quesOptions != null && quesOptions.size() > 0) {
|
|
|
for (int i = 0; i < quesOptions.size(); i++) {
|
|
|
QuesOption quesOption = quesOptions.get(i);
|
|
@@ -408,18 +416,20 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
} else {
|
|
|
defaultQuestionUnit.setRightAnswer(getAnswer(question));
|
|
|
}
|
|
|
+
|
|
|
return defaultQuestionUnit;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 设置单选题和多选题 答案
|
|
|
+ * 设置单选题和多选题 答案
|
|
|
*
|
|
|
* @param quesOptions
|
|
|
* @return
|
|
|
*/
|
|
|
private String[] getSelectQuestionAnswer(List<QuesOption> quesOptions) {
|
|
|
String[] rightAnswer = null;
|
|
|
- List<String> list = new ArrayList<String>();
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+
|
|
|
if (quesOptions != null && quesOptions.size() > 0) {
|
|
|
for (int i = 0; i < quesOptions.size(); i++) {
|
|
|
QuesOption quesOption = quesOptions.get(i);
|
|
@@ -430,6 +440,7 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
rightAnswer = list.toArray(new String[list.size()]);
|
|
|
return rightAnswer;
|
|
|
}
|
|
|
+
|
|
|
return rightAnswer;
|
|
|
}
|
|
|
|
|
@@ -606,8 +617,9 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
|
|
|
log.error("该考试和课程下调卷规则中该类型试卷不存在,请检查调卷规则,调卷程序退出");
|
|
|
throw new StatusException("Q-020560", "该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
|
|
|
}
|
|
|
+
|
|
|
//构建试卷结构
|
|
|
- DefaultPaper defaultPaper = buildDefaultByBasePaper(basePaper, null, null, null);
|
|
|
+ DefaultPaper defaultPaper = this.buildDefaultByBasePaper(basePaper, null, null, null);
|
|
|
return defaultPaper;
|
|
|
}
|
|
|
|