fix(education): preserve manual collection order

This commit is contained in:
2026-07-31 10:27:49 +08:00
parent eae5a6bb3a
commit c3c244a6f5
2 changed files with 19 additions and 5 deletions

View File

@@ -465,7 +465,7 @@ public class PracticeSessionServiceImpl implements PracticeSessionService {
// ========== internal helpers ==========
/**
* 从 provider 获取题目列表按 questionId 稳定排序,取前 count 条
* 从 provider 获取题目列表。题集路由保留手工成员顺序;其他路由按 questionId 稳定排序。
* 所有筛选条件(含 nodeId完整转发到 provider不做客户端裁剪。
*/
private List<CatalogQuestionDTO> fetchAndOrderQuestions(String collectionId, String nodeId,
@@ -501,8 +501,10 @@ public class PracticeSessionServiceImpl implements PracticeSessionService {
throw exception(INSUFFICIENT_ELIGIBLE_QUESTIONS, 0, count);
}
allQuestions.sort(Comparator.comparing(CatalogQuestionDTO::getId, Comparator.nullsLast(String::compareTo))
.thenComparing(CatalogQuestionDTO::getContentVersion, Comparator.nullsLast(String::compareTo)));
if (collectionId == null || collectionId.isBlank()) {
allQuestions.sort(Comparator.comparing(CatalogQuestionDTO::getId, Comparator.nullsLast(String::compareTo))
.thenComparing(CatalogQuestionDTO::getContentVersion, Comparator.nullsLast(String::compareTo)));
}
if (allQuestions.size() > count) {
allQuestions = allQuestions.subList(0, count);
}