fix(question): 修复判断题答案验证逻辑
parent
498f5d681b
commit
27cff1f275
|
|
@ -136,6 +136,11 @@ public class QuestionE extends BaseE {
|
|||
}
|
||||
if (StringUtils.isEmpty(entity.getAnswer())) {
|
||||
errList.add("单选题第" + (i + 3) + "行单选答案不能为空");
|
||||
}else{
|
||||
//单选题答案只能是ABCD四个中的一个,不能多个
|
||||
if (!entity.getAnswer().matches("[A-D]") ||entity.getAnswer().length()>1) {
|
||||
errList.add("单选题第" + (i + 3) + "行答案错误");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getDescr())) {
|
||||
errList.add("单选题第" + (i + 3) + "行答案解析不能为空");
|
||||
|
|
@ -145,10 +150,7 @@ public class QuestionE extends BaseE {
|
|||
errList.add("单选题第" + (i + 3) + "行分值不能为空");
|
||||
}
|
||||
}
|
||||
//单选题答案只能是ABCD四个中的一个,不能多个
|
||||
if (!entity.getAnswer().matches("[A-D]") ||entity.getAnswer().length()>1) {
|
||||
errList.add("单选题第" + (i + 3) + "行答案错误");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(videoMultiselectList)) {
|
||||
|
|
@ -175,6 +177,12 @@ public class QuestionE extends BaseE {
|
|||
}
|
||||
if (StringUtils.isEmpty(entity.getAnswer())) {
|
||||
errList.add("多选题第" + (i + 3) + "行多选答案不能为空");
|
||||
}else{
|
||||
String answer = entity.getAnswer().toUpperCase().trim();
|
||||
//多选题答案只能是选题答案只能是ABCD四个中的值,可以多个
|
||||
if (!answer.matches("^[A-D]{2,4}$") || hasDuplicateChars(answer)) {
|
||||
errList.add("多选题第" + (i + 3) + "行答案错误");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getDescr())) {
|
||||
errList.add("多选题第" + (i + 3) + "行答案解析不能为空");
|
||||
|
|
@ -184,11 +192,7 @@ public class QuestionE extends BaseE {
|
|||
errList.add("多选题第" + (i + 3) + "行分值不能为空");
|
||||
}
|
||||
}
|
||||
String answer = entity.getAnswer().toUpperCase().trim();
|
||||
//多选题答案只能是选题答案只能是ABCD四个中的值,可以多个
|
||||
if (!answer.matches("^[A-D]{2,4}$") || hasDuplicateChars(answer)) {
|
||||
errList.add("多选题第" + (i + 3) + "行答案错误");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -200,10 +204,15 @@ public class QuestionE extends BaseE {
|
|||
continue;
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getQuestionDry())) {
|
||||
errList.add("判断题第" + (i + 3) + "行判断题目不能为空");
|
||||
errList.add("判断题第" + (i + 3) + "行题目不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getAnswer())) {
|
||||
errList.add("判断题第" + (i + 3) + "行判断答案不能为空");
|
||||
errList.add("判断题第" + (i + 3) + "行答案不能为空");
|
||||
}else{
|
||||
//判断题答案只能是AB中的一个
|
||||
if (!entity.getAnswer().matches("[F-T]") ||entity.getAnswer().length()>1) {
|
||||
errList.add("判断题第" + (i + 3) + "行答案错误");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getDescr())) {
|
||||
errList.add("判断题第" + (i + 3) + "行答案解析不能为空");
|
||||
|
|
@ -218,10 +227,7 @@ public class QuestionE extends BaseE {
|
|||
}
|
||||
}
|
||||
}
|
||||
//判断题答案只能是AB中的一个
|
||||
if (!entity.getAnswer().matches("[F-T]") ||entity.getAnswer().length()>1) {
|
||||
errList.add("判断题第" + (i + 3) + "行答案错误");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue