diff --git a/src/components/Solutions/InteractiveSpeaking.tsx b/src/components/Solutions/InteractiveSpeaking.tsx index 4293096b..37cd76bb 100644 --- a/src/components/Solutions/InteractiveSpeaking.tsx +++ b/src/components/Solutions/InteractiveSpeaking.tsx @@ -27,7 +27,7 @@ export default function InteractiveSpeaking({ const [diffNumber, setDiffNumber] = useState<0 | 1 | 2 | 3>(0); useEffect(() => { - if (userSolutions && userSolutions.length > 0) { + if (userSolutions && userSolutions.length > 0 && userSolutions[0].solution) { Promise.all(userSolutions[0].solution.map((x) => axios.post(`/api/speaking`, {path: x.answer}, {responseType: "arraybuffer"}))).then( (values) => { setSolutionsURL( @@ -239,7 +239,11 @@ export default function InteractiveSpeaking({ onNext({ exercise: id, solutions: userSolutions, - score: {total: 100, missing: 0, correct: speakingReverseMarking[userSolutions[0]!.evaluation!.overall] || 0}, + score: { + total: 100, + missing: 0, + correct: userSolutions[0]?.evaluation ? speakingReverseMarking[userSolutions[0]!.evaluation!.overall] || 0 : 0, + }, type, }) } diff --git a/src/components/Solutions/Speaking.tsx b/src/components/Solutions/Speaking.tsx index 128750e8..d498c5c1 100644 --- a/src/components/Solutions/Speaking.tsx +++ b/src/components/Solutions/Speaking.tsx @@ -19,7 +19,7 @@ export default function Speaking({id, type, title, video_url, text, prompts, use const [showDiff, setShowDiff] = useState(false); useEffect(() => { - if (userSolutions && userSolutions.length > 0) { + if (userSolutions && userSolutions.length > 0 && userSolutions[0].solution) { axios.post(`/api/speaking`, {path: userSolutions[0].solution}, {responseType: "arraybuffer"}).then(({data}) => { const blob = new Blob([data], {type: "audio/wav"}); const url = URL.createObjectURL(blob); @@ -29,10 +29,6 @@ export default function Speaking({id, type, title, video_url, text, prompts, use } }, [userSolutions]); - useEffect(() => { - console.log(userSolutions); - }, [userSolutions]); - return ( <> setShowDiff(false)}> @@ -205,7 +201,11 @@ export default function Speaking({id, type, title, video_url, text, prompts, use onNext({ exercise: id, solutions: userSolutions, - score: {total: 100, missing: 0, correct: speakingReverseMarking[userSolutions[0]!.evaluation!.overall] || 0}, + score: { + total: 100, + missing: 0, + correct: userSolutions[0]?.evaluation ? speakingReverseMarking[userSolutions[0]!.evaluation!.overall] || 0 : 0, + }, type, }) }