|
|
@ -21,6 +21,7 @@ import com.project.question.domain.enums.QuestionSourceTypeEnum; |
|
|
import com.project.question.domain.service.QuestionBaseService; |
|
|
import com.project.question.domain.service.QuestionBaseService; |
|
|
import com.project.question.domain.service.SaveQuestionDomainService; |
|
|
import com.project.question.domain.service.SaveQuestionDomainService; |
|
|
import com.project.task.config.ExamScoreRatioConfig; |
|
|
import com.project.task.config.ExamScoreRatioConfig; |
|
|
|
|
|
import com.project.task.domain.enums.QuestionTypeEnum; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
@ -32,6 +33,7 @@ import java.util.HashMap; |
|
|
import java.util.LinkedHashMap; |
|
|
import java.util.LinkedHashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Objects; |
|
|
import java.util.TreeMap; |
|
|
import java.util.TreeMap; |
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Pattern; |
|
|
import java.util.regex.Pattern; |
|
|
@ -102,9 +104,9 @@ public class ImportClassicPaperDomainServiceImpl implements ImportClassicPaperDo |
|
|
int singleChoiceNum = 0, multipleChoiceNum = 0, trueFalseNum = 0, shortAnswerNum = 0; |
|
|
int singleChoiceNum = 0, multipleChoiceNum = 0, trueFalseNum = 0, shortAnswerNum = 0; |
|
|
for (WordQuestionParser.ParsedQuestion pq : parsedQuestions) { |
|
|
for (WordQuestionParser.ParsedQuestion pq : parsedQuestions) { |
|
|
switch (pq.getQuestionType()) { |
|
|
switch (pq.getQuestionType()) { |
|
|
case 0 -> singleChoiceNum++; |
|
|
case 1 -> singleChoiceNum++; |
|
|
case 1 -> multipleChoiceNum++; |
|
|
case 2 -> multipleChoiceNum++; |
|
|
case 2 -> trueFalseNum++; |
|
|
case 3 -> trueFalseNum++; |
|
|
case 4 -> shortAnswerNum++; |
|
|
case 4 -> shortAnswerNum++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -157,9 +159,14 @@ public class ImportClassicPaperDomainServiceImpl implements ImportClassicPaperDo |
|
|
for (int i = 0; i < parsedQuestions.size(); i++) { |
|
|
for (int i = 0; i < parsedQuestions.size(); i++) { |
|
|
WordQuestionParser.ParsedQuestion parsed = parsedQuestions.get(i); |
|
|
WordQuestionParser.ParsedQuestion parsed = parsedQuestions.get(i); |
|
|
|
|
|
|
|
|
// 构建选项 Map
|
|
|
// 构建选项 Map(判断题直接构造选项)
|
|
|
Map<String, String> optionsMap = new TreeMap<>(); |
|
|
Map<String, String> optionsMap = new TreeMap<>(); |
|
|
if (parsed.getOptions() != null) { |
|
|
String rightAnswer = parsed.getAnswer(); |
|
|
|
|
|
if (Objects.equals(parsed.getQuestionType(), QuestionTypeEnum.TRUE_FALSE.getValue())) { |
|
|
|
|
|
optionsMap.put("A", "正确"); |
|
|
|
|
|
optionsMap.put("B", "错误"); |
|
|
|
|
|
rightAnswer = "正确".equals(parsed.getAnswer()) ? "A" : "B"; |
|
|
|
|
|
} else if (parsed.getOptions() != null) { |
|
|
for (WordQuestionParser.ParsedOption opt : parsed.getOptions()) { |
|
|
for (WordQuestionParser.ParsedOption opt : parsed.getOptions()) { |
|
|
optionsMap.put(opt.getLabel(), opt.getContent()); |
|
|
optionsMap.put(opt.getLabel(), opt.getContent()); |
|
|
} |
|
|
} |
|
|
@ -175,7 +182,7 @@ public class ImportClassicPaperDomainServiceImpl implements ImportClassicPaperDo |
|
|
detailDTO.setQuestionContent(parsed.getStem()); |
|
|
detailDTO.setQuestionContent(parsed.getStem()); |
|
|
detailDTO.setType(parsed.getQuestionType()); |
|
|
detailDTO.setType(parsed.getQuestionType()); |
|
|
detailDTO.setOptions(optionsMap.isEmpty() ? null : optionsMap); |
|
|
detailDTO.setOptions(optionsMap.isEmpty() ? null : optionsMap); |
|
|
detailDTO.setRightAnswer(parsed.getAnswer()); |
|
|
detailDTO.setRightAnswer(rightAnswer); |
|
|
detailDTO.setAnalysis(parsed.getAnalysis()); |
|
|
detailDTO.setAnalysis(parsed.getAnalysis()); |
|
|
|
|
|
|
|
|
// 简答题得分点
|
|
|
// 简答题得分点
|
|
|
|