Compare commits
2 Commits
2fcf2b47b0
...
c648c6668b
| Author | SHA1 | Date | |
|---|---|---|---|
| c648c6668b | |||
| e7e64ad2ed |
|
|
@ -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 () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user