Compare commits

...

2 Commits

Author SHA1 Message Date
c648c6668b refine speaking practice filter to inspect audio rows
Filter speaking practice options using returned AUDIO question rows instead of total_count so unrelated practices are excluded reliably.

Made-with: Cursor
2026-04-07 04:28:22 -07:00
e7e64ad2ed filter speaking practice dropdown to audio-only sets
Limit the Speaking page practice filter options to sets that contain AUDIO questions and clear stale selected filter values when unavailable.

Made-with: Cursor
2026-04-07 04:23:19 -07:00

View File

@ -319,8 +319,29 @@ export function SpeakingPage() {
if (chunk.length < batchSize) break
offset += chunk.length
}
// Speaking page should only offer practices that already contain AUDIO questions.
const checks = await Promise.all(
all.map(async (practice) => {
try {
const res = await getPracticeQuestionsByPractice(practice.id, {
limit: 20,
offset: 0,
question_type: "AUDIO",
})
const questions = res.data?.data?.questions ?? []
const hasAudioQuestion = questions.some(
(question) => (question.question_type ?? "").toUpperCase() === "AUDIO",
)
return hasAudioQuestion ? practice : null
} catch {
return null
}
}),
)
const speakingPractices = checks.filter((p): p is QuestionSet => p !== null)
setPracticeOptions(
all.map((p) => ({
speakingPractices.map((p) => ({
id: p.id,
title: p.title,
})),
@ -333,6 +354,12 @@ export function SpeakingPage() {
})
}, [fetchPracticeOptions])
useEffect(() => {
if (!selectedPracticeId) return
const exists = practiceOptions.some((option) => option.id === Number(selectedPracticeId))
if (!exists) setSelectedPracticeId("")
}, [practiceOptions, selectedPracticeId])
useEffect(() => {
let cancelled = false
const fetchSubCourseOptions = async () => {