|
|
|
@ -57,16 +57,16 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
import static cn.hutool.core.util.ArrayUtil.join;
|
|
|
|
|
import static com.ibeetl.jlw.entity.ResourcesQuestion.LINE_8;
|
|
|
|
|
import static com.ibeetl.jlw.entity.ResourcesQuestion.SPLIT_;
|
|
|
|
|
import static com.ibeetl.jlw.entity.ResourcesQuestionOptionEntity.shuffleOrderOptions;
|
|
|
|
|
import static com.ibeetl.jlw.enums.AddTypeEnum.ADMIN_ADD;
|
|
|
|
|
import static com.ibeetl.jlw.enums.AddTypeEnum.FACULTY_ADD;
|
|
|
|
|
import static com.ibeetl.jlw.service.strategy.StrategyContext.QuestionParagraphTypeEnum.OTHER;
|
|
|
|
|
import static com.ibeetl.jlw.service.strategy.StrategyContext.QuestionTypeConcatEnum.DECIDE;
|
|
|
|
|
import static com.ibeetl.jlw.service.strategy.StrategyContext.QuestionTypeConcatEnum.MULTIPLE;
|
|
|
|
|
import static com.ibeetl.jlw.service.strategy.StrategyContext.QuestionTypeConcatEnum.*;
|
|
|
|
|
import static com.ibeetl.jlw.service.strategy.WordQuestionOption.OPTION_REGEX;
|
|
|
|
|
import static java.util.stream.Collectors.groupingBy;
|
|
|
|
|
import static java.util.stream.Collectors.joining;
|
|
|
|
|
|
|
|
|
@ -896,10 +896,11 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
resourcesQuestion.setOrgId(coreUser.getOrgId());
|
|
|
|
|
resourcesQuestion.setAddType(coreUser.isAdmin() ? ADMIN_ADD : FACULTY_ADD);
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(questionStem.get())) {
|
|
|
|
|
resourcesQuestion.setQuestionStem(questionStem.get().replace("<", "<").replace(">", ">"));
|
|
|
|
|
} else {
|
|
|
|
|
resourcesQuestion.setQuestionStem(questionStem.get());
|
|
|
|
|
// 填空题 questionOptionA 存放的是空格的数量
|
|
|
|
|
if (StrUtil.isNotBlank(questionStem.get())) {
|
|
|
|
|
String replacedText = questionStem.get().replaceAll(LINE_8, SPLIT_);
|
|
|
|
|
resourcesQuestion.setQuestionOptionA(String.valueOf(StrUtil.count(replacedText, SPLIT_)));
|
|
|
|
|
resourcesQuestion.setQuestionStem(replacedText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
question.set(resourcesQuestion);
|
|
|
|
@ -951,9 +952,6 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
return resultVO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 取选项的正则 */
|
|
|
|
|
private Pattern optionPattern = Pattern.compile("^[A-Za-z][\\.\\、\\. ]");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 给题目添加选项
|
|
|
|
|
* @param text 单个选项的内容
|
|
|
|
@ -962,13 +960,9 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
public void putQuestionOption(String text, ResourcesQuestion question){
|
|
|
|
|
//text为选项
|
|
|
|
|
if (StringUtils.isNotBlank(text)){
|
|
|
|
|
text = text.replace("<","<").replace(">",">");
|
|
|
|
|
}
|
|
|
|
|
Matcher matcher = optionPattern.matcher(text);
|
|
|
|
|
if(matcher.find()){
|
|
|
|
|
String questionOption = text.substring(2);
|
|
|
|
|
question.putQuestionOptionList(Collections.singletonList(questionOption));
|
|
|
|
|
text = text.replace("<","<").replace(">",">").replaceFirst(OPTION_REGEX, "");
|
|
|
|
|
}
|
|
|
|
|
question.putQuestionOptionList(Collections.singletonList(text));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -995,24 +989,25 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
/** 题干 */
|
|
|
|
|
case STEM: {
|
|
|
|
|
questionStem.set(questionStem.get().concat(v));
|
|
|
|
|
question.get().setQuestionStem(questionStem.get());
|
|
|
|
|
String replacedText = questionStem.get().replaceAll(LINE_8, SPLIT_);
|
|
|
|
|
question.get().setQuestionOptionA(String.valueOf(StrUtil.count(replacedText, SPLIT_)));
|
|
|
|
|
question.get().setQuestionStem(replacedText);
|
|
|
|
|
} break;
|
|
|
|
|
/** 选项 */
|
|
|
|
|
case OPTION: {
|
|
|
|
|
List<String> optionList = question.get().takeQuestionOptionConcatList();
|
|
|
|
|
if (ObjectUtil.isNotEmpty(optionList)) {
|
|
|
|
|
final int[] index = { 0 };
|
|
|
|
|
optionList.forEach(str-> {
|
|
|
|
|
if(index[0] == optionList.size() -1) {
|
|
|
|
|
str = str.concat(v);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// if (ObjectUtil.isNotEmpty(questionOptions)) {
|
|
|
|
|
// QuestionOption questionOption = questionOptions.get(questionOptions.size() - 1);
|
|
|
|
|
// questionOption.setQuestionOptionContent(questionOption.getQuestionOptionContent().concat(v));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (SINGLE.equals(typeConcatEnum.get()) || MULTIPLE.equals(typeConcatEnum.get())) {
|
|
|
|
|
question.get().putQuestionOptionList(Collections.singletonList(v));
|
|
|
|
|
}
|
|
|
|
|
// 分析题和填空题
|
|
|
|
|
else if(ANALYSIS_QUESTION.equals(typeConcatEnum.get())) {
|
|
|
|
|
question.get().setQuestionOptionB(question.get().getQuestionOptionB().concat(v).replaceAll(LINE_8, SPLIT_));
|
|
|
|
|
question.get().setQuestionOptionA(String.valueOf(StrUtil.count(question.get().getQuestionOptionB(), SPLIT_)));
|
|
|
|
|
}
|
|
|
|
|
// 填空题
|
|
|
|
|
else if(FILL_QUESTION.equals(typeConcatEnum.get())) {
|
|
|
|
|
question.get().setQuestionOptionA(String.valueOf(StrUtil.count(question.get().getQuestionOptionB(), SPLIT_)));
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
/** 答案 */
|
|
|
|
|
case ANSWER: {
|
|
|
|
@ -1096,7 +1091,8 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
// <p>ABC</p> 只获取ABC 删除所有</>标签元素。
|
|
|
|
|
String replaced = questionAnswer.replaceAll(" |</?[a-zA-Z\\u4e00-\\u9fa5]*?[^<]>", "");
|
|
|
|
|
// 取中文或者字母, 也有移除空格等符号的操作
|
|
|
|
|
String res = ObjectUtil.defaultIfNull(ReUtil.getGroup0("[A-Za-z\\u4e00-\\u9fa5]+", replaced), replaced).toUpperCase();
|
|
|
|
|
// String res = ObjectUtil.defaultIfNull(ReUtil.getGroup0("[A-Za-z\\u4e00-\\u9fa5]+", replaced), replaced).toUpperCase();
|
|
|
|
|
String res = replaced.trim();
|
|
|
|
|
// 如果只有字母,则拆分规则: ABC => A,B,C
|
|
|
|
|
if (typeConcatEnum.equals(MULTIPLE) && ReUtil.isMatch("^[A-Za-z]+$",res)) {
|
|
|
|
|
// ABC => A,B,C
|
|
|
|
|