fix: address code review issues in interactive exercises
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled

- ExerciseSort: replace unbounded shuffle recursion with deterministic swap
- ExerciseManager: add sortQuestion field so sort exercises have custom questions
- index.vue: use Promise.allSettled so exercise fetch failure doesn't break lesson content
- ExerciseManager: guard mcqAnswer index after option deletion

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-23 06:35:45 -06:00
parent 67a23c51c8
commit f00dab9c6d
3 changed files with 13 additions and 6 deletions

View File

@@ -22,7 +22,8 @@ function shuffle(arr: LineItem[]): LineItem[] {
;[a[i], a[j]] = [a[j], a[i]]
}
const isCorrect = a.every((item, i) => item.originalIdx === i)
return isCorrect && a.length > 1 ? shuffle(arr) : a
if (isCorrect && a.length > 1) [a[0], a[1]] = [a[1], a[0]]
return a
}
function init() {