mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 17:36:47 +08:00
随机选题,bug
This commit is contained in:
@@ -221,20 +221,19 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
||||
|
||||
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();
|
||||
JsonNode rootNode = objectMapper.readTree(paperJson);
|
||||
JsonNode itemsNode = rootNode.path("items");
|
||||
List<JsonNode> itemsNodes = new ArrayList<>();
|
||||
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);
|
||||
itemsNodes = itemsNodes.subList(0, qnum);
|
||||
}
|
||||
return itemsNodes;
|
||||
} else if (courseExam.getPaperType() == 2 && randomMode && qnum != null && qnum > 0) {
|
||||
} else if (courseExam.getPaperType() == 2) {
|
||||
IXaskCache cache = XaskCacheProvider.getCache();
|
||||
String cacheKey = "course:exam:" + courseExamId + ":" + paperId;
|
||||
String cacheData = cache.getCacheObject(cacheKey);
|
||||
@@ -250,7 +249,7 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
||||
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);
|
||||
eqVoList = eqVoList.subList(0, qnum);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user