|
@@ -837,11 +837,9 @@ public abstract class ExportPaperAbstractService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 在题干上设置分数
|
|
|
|
- *
|
|
|
|
- * @throws Exception
|
|
|
|
|
|
+ * 在Word题干上设置分数
|
|
*/
|
|
*/
|
|
- public String appendScoreToQuestionBody(String quesBodyWordMl, double score) throws Exception {
|
|
|
|
|
|
+ public String appendScoreToWordQuestionBody(String quesBodyWordMl, double score) throws Exception {
|
|
String totalScore = BigDecimal.valueOf(score).stripTrailingZeros().toPlainString();
|
|
String totalScore = BigDecimal.valueOf(score).stripTrailingZeros().toPlainString();
|
|
String scores = deletePoint(totalScore);
|
|
String scores = deletePoint(totalScore);
|
|
String tmpStr = DocxProcessUtil.BODY_HEADER + quesBodyWordMl + DocxProcessUtil.BODY_TAIL;
|
|
String tmpStr = DocxProcessUtil.BODY_HEADER + quesBodyWordMl + DocxProcessUtil.BODY_TAIL;
|
|
@@ -870,14 +868,9 @@ public abstract class ExportPaperAbstractService {
|
|
return pWordMl.toString();
|
|
return pWordMl.toString();
|
|
}
|
|
}
|
|
|
|
|
|
- public String appendScoreToQuestionBodyHtml(String quesBodyHtml, double score) {
|
|
|
|
- String html = quesBodyHtml.replaceAll("<p>", "").replaceAll("</p>", "");
|
|
|
|
- html = "<P>" + html + "(" + score + "分)</p>";
|
|
|
|
- return html;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //去掉分数后面的小数点
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 去掉分数后面的小数点
|
|
|
|
+ */
|
|
protected String deletePoint(String str) {
|
|
protected String deletePoint(String str) {
|
|
if (str.indexOf(".0") > -1) {
|
|
if (str.indexOf(".0") > -1) {
|
|
return str.replace(".0", "");
|
|
return str.replace(".0", "");
|
|
@@ -885,62 +878,8 @@ public abstract class ExportPaperAbstractService {
|
|
return str;
|
|
return str;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 当大题下小题分数不是全部一样时,在小题题干后面加上小题的分数
|
|
|
|
- *
|
|
|
|
- * @param details
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- public void appendScoreToQuestionBody(List<PaperDetailExp> details) throws Exception {
|
|
|
|
- for (PaperDetailExp paperDetailExp : details) {
|
|
|
|
- if (checkPaperDetailUnitScore(paperDetailExp) == null) {
|
|
|
|
- for (PaperDetailUnitExp paperDetailUnit : paperDetailExp.getPaperDetailUnits()) {
|
|
|
|
- //判断小题是否为套题
|
|
|
|
- if (paperDetailUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
|
- List<Question> subQuestions = paperDetailUnit.getQuestion().getSubQuestions();
|
|
|
|
- for (int i = 0; i < subQuestions.size(); i++) {
|
|
|
|
- Question subQuestion = subQuestions.get(i);
|
|
|
|
- double subScore = paperDetailUnit.getSubScoreList().get(i);
|
|
|
|
- String questionBodyWord = appendScoreToQuestionBody(subQuestion.getQuesBodyWord(), subScore);
|
|
|
|
- subQuestion.setQuesBodyWord(questionBodyWord);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- Question question = paperDetailUnit.getQuestion();
|
|
|
|
- String questionBodyWord = appendScoreToQuestionBody(question.getQuesBodyWord(), paperDetailUnit.getScore());
|
|
|
|
- question.setQuesBodyWord(questionBodyWord);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void appendScoreToQuestionBodyHtml(List<PaperDetailExp> details) {
|
|
|
|
- for (PaperDetailExp paperDetailExp : details) {
|
|
|
|
- if (checkPaperDetailUnitScore(paperDetailExp) == null) {
|
|
|
|
- for (PaperDetailUnitExp paperDetailUnit : paperDetailExp.getPaperDetailUnits()) {
|
|
|
|
- //判断小题是否为套题
|
|
|
|
- if (paperDetailUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
|
- List<Question> subQuestions = paperDetailUnit.getQuestion().getSubQuestions();
|
|
|
|
- for (int i = 0; i < subQuestions.size(); i++) {
|
|
|
|
- Question subQuestion = subQuestions.get(i);
|
|
|
|
- double subScore = paperDetailUnit.getSubScoreList().get(i);
|
|
|
|
- String questionBodyHtml = appendScoreToQuestionBodyHtml(subQuestion.getQuesBody(), subScore);
|
|
|
|
- subQuestion.setQuesBody(questionBodyHtml);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- Question question = paperDetailUnit.getQuestion();
|
|
|
|
- String questionBodyHtml = appendScoreToQuestionBodyHtml(question.getQuesBody(), paperDetailUnit.getScore());
|
|
|
|
- question.setQuesBody(questionBodyHtml);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 设置大题标题
|
|
* 设置大题标题
|
|
- *
|
|
|
|
- * @param paperDetailExps
|
|
|
|
*/
|
|
*/
|
|
public void setExpDtoTitle(List<PaperDetailExp> paperDetailExps) {
|
|
public void setExpDtoTitle(List<PaperDetailExp> paperDetailExps) {
|
|
for (PaperDetailExp paperDetailExp : paperDetailExps) {
|
|
for (PaperDetailExp paperDetailExp : paperDetailExps) {
|
|
@@ -974,38 +913,6 @@ public abstract class ExportPaperAbstractService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 校验大题下的小题分数是不是一样
|
|
|
|
- *
|
|
|
|
- * @param paperDetailExp
|
|
|
|
- * @return 如果分数一样,返回分数
|
|
|
|
- * 如果分数不一样,返回 null
|
|
|
|
- */
|
|
|
|
- public String checkPaperDetailUnitScore(PaperDetailExp paperDetailExp) {
|
|
|
|
- List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
|
|
|
|
- Set<Double> scoreSet = new HashSet<Double>();
|
|
|
|
- for (PaperDetailUnitExp unitExp : paperDetailUnitExps) {
|
|
|
|
- //判断套路
|
|
|
|
- if (unitExp.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
|
-// List<Question> subQuestions = unitExp.getQuestion().getSubQuestions();
|
|
|
|
-// for(Question subQuestion:subQuestions){
|
|
|
|
-// scoreSet.add(subQuestion.getScore());
|
|
|
|
-// }
|
|
|
|
- List<Double> subScoreList = unitExp.getSubScoreList();
|
|
|
|
- for (Double score : subScoreList) {
|
|
|
|
- scoreSet.add(score);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- scoreSet.add(unitExp.getScore());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (scoreSet.size() == 1) {
|
|
|
|
- return scoreSet.iterator().next() + "";
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 创建机考文件,并打包上传至又拍云
|
|
* 创建机考文件,并打包上传至又拍云
|
|
*
|
|
*
|
|
@@ -1095,14 +1002,8 @@ public abstract class ExportPaperAbstractService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void getBodyAndOptionAudioFile(ComputerTestQuestion computerTestQuestion,
|
|
|
|
- Sections bodySections,
|
|
|
|
- String jsonDirectoryPath,
|
|
|
|
- ComputerTestPaper computerTestPaper,
|
|
|
|
- String examId,
|
|
|
|
- ComputerTestPaperDetail detail,
|
|
|
|
- ComputerTestOption option,
|
|
|
|
- int number) {
|
|
|
|
|
|
+ private void getBodyAndOptionAudioFile(ComputerTestQuestion computerTestQuestion, Sections bodySections, String jsonDirectoryPath,
|
|
|
|
+ ComputerTestPaper computerTestPaper, String examId, ComputerTestPaperDetail detail, ComputerTestOption option, int number) {
|
|
List<Section> sectionList = bodySections.getSections();
|
|
List<Section> sectionList = bodySections.getSections();
|
|
int bNum = 1;
|
|
int bNum = 1;
|
|
int oNum = 1;
|
|
int oNum = 1;
|
|
@@ -1149,21 +1050,9 @@ public abstract class ExportPaperAbstractService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生成试卷或答案Word,上传至又拍云
|
|
* 生成试卷或答案Word,上传至又拍云
|
|
- *
|
|
|
|
- * @param paperExp
|
|
|
|
- * @param extractConfig
|
|
|
|
- * @param accessUser
|
|
|
|
- * @param currNum
|
|
|
|
- * @param template
|
|
|
|
- * @param examFileType
|
|
|
|
*/
|
|
*/
|
|
- protected void uploadPaperOrAnswerFile(PaperExp paperExp,
|
|
|
|
- ExtractConfig extractConfig,
|
|
|
|
- User accessUser,
|
|
|
|
- String currNum,
|
|
|
|
- Template template,
|
|
|
|
- ExamFileType examFileType,
|
|
|
|
- ExamPaper examPaper) {
|
|
|
|
|
|
+ protected void uploadPaperOrAnswerFile(PaperExp paperExp, ExtractConfig extractConfig, User accessUser, String currNum,
|
|
|
|
+ Template template, ExamFileType examFileType, ExamPaper examPaper) {
|
|
String paperfileName = currNum + examFileType.name() + DOCX_SUFFIX;
|
|
String paperfileName = currNum + examFileType.name() + DOCX_SUFFIX;
|
|
try {
|
|
try {
|
|
DocxProcessUtil.exportWord(paperExp, paperfileName, template);
|
|
DocxProcessUtil.exportWord(paperExp, paperfileName, template);
|
|
@@ -1605,12 +1494,19 @@ public abstract class ExportPaperAbstractService {
|
|
*/
|
|
*/
|
|
public PaperExp initPaperExp(String paperId) throws Exception {
|
|
public PaperExp initPaperExp(String paperId) throws Exception {
|
|
PaperExp exportPaper = initPaperExpService.initPaperExp(paperId);
|
|
PaperExp exportPaper = initPaperExpService.initPaperExp(paperId);
|
|
|
|
+
|
|
//给新的大题下所有小题排序
|
|
//给新的大题下所有小题排序
|
|
sortPaperDetailUnits(exportPaper.getPaperDetails());
|
|
sortPaperDetailUnits(exportPaper.getPaperDetails());
|
|
|
|
+
|
|
//如果每个小题分数不一样,题干后面添加分数
|
|
//如果每个小题分数不一样,题干后面添加分数
|
|
- appendScoreToQuestionBody(exportPaper.getPaperDetails());
|
|
|
|
- //1.设置题号 2.给小题选项进行排序 3.设置选项号 4.替换题干中的##为____
|
|
|
|
|
|
+ checkAndSetQuestionScore(exportPaper.getPaperDetails());
|
|
|
|
+
|
|
|
|
+ // 1.设置题号
|
|
|
|
+ // 2.给小题选项进行排序
|
|
|
|
+ // 3.设置选项号
|
|
|
|
+ // 4.替换题干中的##为____
|
|
setUnitExpNumber(exportPaper.getPaperDetails());
|
|
setUnitExpNumber(exportPaper.getPaperDetails());
|
|
|
|
+
|
|
//设置大题标题
|
|
//设置大题标题
|
|
setExpDtoTitle(exportPaper.getPaperDetails());
|
|
setExpDtoTitle(exportPaper.getPaperDetails());
|
|
return exportPaper;
|
|
return exportPaper;
|
|
@@ -1625,10 +1521,15 @@ public abstract class ExportPaperAbstractService {
|
|
//给新的大题下所有小题排序
|
|
//给新的大题下所有小题排序
|
|
sortPaperDetailUnits(previewPaper.getPaperDetails());
|
|
sortPaperDetailUnits(previewPaper.getPaperDetails());
|
|
|
|
|
|
- //如果每个小题分数不一样,题干后面添加分数
|
|
|
|
- appendScoreToQuestionBodyHtml(previewPaper.getPaperDetails());
|
|
|
|
- //1.设置题号 2.给小题选项进行排序 3.设置选项号 4.替换题干中的##为____
|
|
|
|
|
|
+ //如果每个小题分数不一致,题干后面添加分数;一致时则不用加
|
|
|
|
+ checkAndSetQuestionScore(previewPaper.getPaperDetails());
|
|
|
|
+
|
|
|
|
+ // 1.设置题号
|
|
|
|
+ // 2.给小题选项进行排序
|
|
|
|
+ // 3.设置选项号
|
|
|
|
+ // 4.替换题干中的##为____
|
|
setUnitExpNumberHtml(previewPaper.getPaperDetails());
|
|
setUnitExpNumberHtml(previewPaper.getPaperDetails());
|
|
|
|
+
|
|
//设置大题标题
|
|
//设置大题标题
|
|
setExpDtoTitle(previewPaper.getPaperDetails());
|
|
setExpDtoTitle(previewPaper.getPaperDetails());
|
|
return previewPaper;
|
|
return previewPaper;
|
|
@@ -1688,4 +1589,68 @@ public abstract class ExportPaperAbstractService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 题干上设置分数内容
|
|
|
|
+ */
|
|
|
|
+ public String appendScoreToQuestionBodyHtml(String quesBodyHtml, double score) {
|
|
|
|
+ quesBodyHtml = quesBodyHtml.replaceAll("<p>", "").replaceAll("</p>", "");
|
|
|
|
+ return "<p>" + quesBodyHtml + "(" + score + "分)</p>";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 如果每个小题分数不一致,题干后面添加分数;一致时则不用加
|
|
|
|
+ */
|
|
|
|
+ public void checkAndSetQuestionScore(List<PaperDetailExp> details) {
|
|
|
|
+ for (PaperDetailExp detail : details) {
|
|
|
|
+ if (checkPaperDetailUnitScore(detail) != null) {
|
|
|
|
+ continue;//分数一致
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (PaperDetailUnitExp unit : detail.getPaperDetailUnits()) {
|
|
|
|
+ //判断小题是否为套题
|
|
|
|
+ if (unit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
|
+ List<Question> subQuestions = unit.getQuestion().getSubQuestions();
|
|
|
|
+ for (int i = 0; i < subQuestions.size(); i++) {
|
|
|
|
+ Question subQuestion = subQuestions.get(i);
|
|
|
|
+ double subScore = unit.getSubScoreList().get(i);
|
|
|
|
+ String bodyHtml = appendScoreToQuestionBodyHtml(subQuestion.getQuesBody(), subScore);
|
|
|
|
+ subQuestion.setQuesBody(bodyHtml);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ Question question = unit.getQuestion();
|
|
|
|
+ String bodyHtml = appendScoreToQuestionBodyHtml(question.getQuesBody(), unit.getScore());
|
|
|
|
+ question.setQuesBody(bodyHtml);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验大题下的小题分数是不是一样
|
|
|
|
+ * 1.如果分数一样,返回分数
|
|
|
|
+ * 2.如果分数不一样,返回null
|
|
|
|
+ */
|
|
|
|
+ public String checkPaperDetailUnitScore(PaperDetailExp detail) {
|
|
|
|
+ Set<Double> scoreSet = new HashSet<>();
|
|
|
|
+ List<PaperDetailUnitExp> units = detail.getPaperDetailUnits();
|
|
|
|
+ for (PaperDetailUnitExp unit : units) {
|
|
|
|
+ if (unit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
|
+ /* List<Question> subQuestions = unit.getQuestion().getSubQuestions();
|
|
|
|
+ for (Question subQuestion : subQuestions) {
|
|
|
|
+ scoreSet.add(subQuestion.getScore());
|
|
|
|
+ }*/
|
|
|
|
+ List<Double> subScoreList = unit.getSubScoreList();
|
|
|
|
+ for (Double score : subScoreList) {
|
|
|
|
+ scoreSet.add(score);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ scoreSet.add(unit.getScore());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (scoreSet.size() == 1) {
|
|
|
|
+ return scoreSet.iterator().next() + "";
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|