mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 09:26:48 +08:00
随机选题,bug
This commit is contained in:
@@ -221,20 +221,19 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 判断试卷类型
|
// 判断试卷类型
|
||||||
if (courseExam.getPaperType() == 1 && StringUtils.isNotBlank(courseExam.getPaperContent()) && randomMode && qnum != null && qnum > 0) {
|
if (courseExam.getPaperType() == 1 && StringUtils.isNotBlank(courseExam.getPaperContent())) {
|
||||||
|
|
||||||
paperJson = courseExam.getPaperContent();
|
paperJson = courseExam.getPaperContent();
|
||||||
JsonNode rootNode = objectMapper.readTree(paperJson);
|
JsonNode rootNode = objectMapper.readTree(paperJson);
|
||||||
JsonNode itemsNode = rootNode.path("items");
|
JsonNode itemsNode = rootNode.path("items");
|
||||||
List<JsonNode> itemsNodes = new ArrayList<>();
|
List<JsonNode> itemsNodes = new ArrayList<>();
|
||||||
itemsNode.forEach(itemsNodes::add);
|
itemsNode.forEach(itemsNodes::add);
|
||||||
|
|
||||||
if (randomMode && qnum != null && qnum > 0 && itemsNodes.size() > qnum) {
|
if (randomMode && qnum != null && qnum > 0 && randomMode && qnum != null && qnum > 0 && itemsNodes.size() > qnum) {
|
||||||
Collections.shuffle(itemsNodes);
|
Collections.shuffle(itemsNodes);
|
||||||
itemsNodes = itemsNodes.subList(0, qnum);
|
itemsNodes = itemsNodes.subList(0, qnum);
|
||||||
}
|
}
|
||||||
return itemsNodes;
|
return itemsNodes;
|
||||||
} else if (courseExam.getPaperType() == 2 && randomMode && qnum != null && qnum > 0) {
|
} else if (courseExam.getPaperType() == 2) {
|
||||||
IXaskCache cache = XaskCacheProvider.getCache();
|
IXaskCache cache = XaskCacheProvider.getCache();
|
||||||
String cacheKey = "course:exam:" + courseExamId + ":" + paperId;
|
String cacheKey = "course:exam:" + courseExamId + ":" + paperId;
|
||||||
String cacheData = cache.getCacheObject(cacheKey);
|
String cacheData = cache.getCacheObject(cacheKey);
|
||||||
@@ -250,7 +249,7 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
|||||||
List<TestQuestionVo> eqVoList = objectMapper.readValue(paperJson, new TypeReference<List<TestQuestionVo>>() {
|
List<TestQuestionVo> eqVoList = objectMapper.readValue(paperJson, new TypeReference<List<TestQuestionVo>>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (eqVoList.size() > qnum) {
|
if (randomMode && qnum != null && qnum > 0 && eqVoList.size() > qnum) {
|
||||||
Collections.shuffle(eqVoList);
|
Collections.shuffle(eqVoList);
|
||||||
eqVoList = eqVoList.subList(0, qnum);
|
eqVoList = eqVoList.subList(0, qnum);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user