|
@@ -158,7 +158,6 @@ public class PaperService {
|
|
|
List<SubjectAbility> abilities = subjectAbilityService.list(paper.getSubjectId());
|
|
|
//初始化数据
|
|
|
abilities.forEach(a -> data.put(a.getCode(), 0d));
|
|
|
- data.put("A0", 0d);
|
|
|
double totalScore = 0;
|
|
|
for (Question question : save.getQuestions()) {
|
|
|
question.setPid(save.getId());
|
|
@@ -176,18 +175,21 @@ public class PaperService {
|
|
|
abilityScoreService.add(score);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
for (Section section : save.getSections()) {
|
|
|
section.setPid(save.getId());
|
|
|
//保存段落
|
|
|
sectionService.add(section);
|
|
|
}
|
|
|
//不使用能力计分,并且能力数量大于0
|
|
|
- if (!paper.getUseAbility() && abilities.size() > 0) {
|
|
|
- //put第一个能力进去
|
|
|
- data.put(abilities.get(0).getCode(), (double) paper.getQuestions().size());
|
|
|
+ if (!paper.getUseAbility()) {
|
|
|
+ //put一个A0能力进去
|
|
|
+ data.put("A0", (double) paper.getQuestions().size());
|
|
|
+ paper.setTotalScore(paper.getQuestionNum());
|
|
|
+ } else {
|
|
|
+ paper.setTotalScore((int) totalScore);
|
|
|
}
|
|
|
String jsonScore = ObjectUtil.object2Json(data);
|
|
|
- paper.setTotalScore((int) totalScore);
|
|
|
paper.setJsonScore(jsonScore);
|
|
|
paperRepo.saveAndFlush(paper);
|
|
|
logger.info("试卷增加成功");
|
|
@@ -285,9 +287,6 @@ public class PaperService {
|
|
|
}
|
|
|
|
|
|
private void parsePaper(Paper paper, PaperTemplate template, XWPFDocument document) {
|
|
|
- String tagPattern = template.getSection();
|
|
|
- String questionPattern = template.getQuestion();
|
|
|
- String picturePattern = template.getPicturePattern();
|
|
|
List<XWPFParagraph> paragraphs = document.getParagraphs();
|
|
|
Assert.notEmpty(paragraphs, "未检测到段落,请检查上传的文档");
|
|
|
String name = paragraphs.get(0).getText();
|
|
@@ -314,7 +313,7 @@ public class PaperService {
|
|
|
//根据题目标签,给题目分组
|
|
|
Map<String, List<XWPFParagraph>> questions = initQuestions(current, template, ps);
|
|
|
current.setStartNumber(currentNumber);
|
|
|
- List<Question> list = parseQuestions(questions, current, template, topic, paper.getUseAbility(),abilities);
|
|
|
+ List<Question> list = parseQuestions(questions, current, template, topic, paper.getUseAbility(), abilities);
|
|
|
current.setNums(list.size());
|
|
|
currentNumber = currentNumber + list.size();
|
|
|
qs.put(s, list);
|
|
@@ -405,7 +404,7 @@ public class PaperService {
|
|
|
return sections;
|
|
|
}
|
|
|
|
|
|
- private List<Question> parseQuestions(Map<String, List<XWPFParagraph>> questions, Section section, PaperTemplate template, Map<String, String> topic, Boolean useAbility,List<String> abilities) {
|
|
|
+ private List<Question> parseQuestions(Map<String, List<XWPFParagraph>> questions, Section section, PaperTemplate template, Map<String, String> topic, Boolean useAbility, List<String> abilities) {
|
|
|
List<Question> list = new ArrayList<>();
|
|
|
//问题合集
|
|
|
Pattern pattern = Pattern.compile("\\d+");
|
|
@@ -413,7 +412,7 @@ public class PaperService {
|
|
|
Matcher matcher = pattern.matcher(k);
|
|
|
if (k.matches(template.getQuestion()) && matcher.find()) {
|
|
|
String code = matcher.group();
|
|
|
- Question question = questionService.initQuestion(section.getNumber(), section.getStartNumber(), Integer.valueOf(code),useAbility);
|
|
|
+ Question question = questionService.initQuestion(section.getNumber(), section.getStartNumber(), Integer.valueOf(code), useAbility);
|
|
|
wordService.parseQuestion(question, v, topic, template, abilities);
|
|
|
list.add(question);
|
|
|
}
|