feat:更新训练场模块

This commit is contained in:
2026-07-30 13:08:23 +08:00
parent 78237984ec
commit 280ea9f7d0
21 changed files with 935 additions and 201 deletions

28
src/utils/practiceUtil.ts Normal file
View File

@@ -0,0 +1,28 @@
import type { IPracticeCheck } from '@/types/practice.ts'
import type { IQuestion } from '@/types/question.ts'
export const isAnswerCorrect = (answer: string[], select: string[]): boolean => {
const normAnswer = Array.from(new Set(answer)).sort()
const normSelect = Array.from(new Set(select)).sort()
if (normAnswer.length !== normSelect.length) {
return false
}
return normAnswer.every((v, i) => v === normSelect[i])
}
export const optLetter = (index: number): string => {
return String.fromCharCode(65 + index)
}
export const getMistakeList = (questions: IQuestion[],
checks: IPracticeCheck[]): IQuestion[] => {
const checkMap = new Map<number, IPracticeCheck>()
checks.forEach((c) => checkMap.set(c.id, c))
return questions.filter((q) => {
const check = checkMap.get(q.id)
return !check || !check.isCorrect
})
}