Finalized the Speaking module exercise

This commit is contained in:
Tiago Ribeiro
2023-07-14 12:08:25 +01:00
parent 6a2fab4f88
commit 2c10a203a5
8 changed files with 128 additions and 24 deletions

View File

@@ -38,6 +38,7 @@ export default function Speaking({id, title, text, type, prompts, onNext, onBack
const formData = new FormData();
formData.append("audio", audioFile, "audio.wav");
formData.append("question", `${text.replaceAll("\n", "")} You should talk about: ${prompts.join(", ")}`);
const config = {
headers: {
@@ -51,7 +52,7 @@ export default function Speaking({id, title, text, type, prompts, onNext, onBack
};
if (mediaBlob) uploadFile();
}, [mediaBlob]);
}, [mediaBlob, text, prompts]);
return (
<div className="flex flex-col h-full w-full gap-9">
@@ -200,14 +201,28 @@ export default function Speaking({id, title, text, type, prompts, onNext, onBack
<Button
color="green"
variant="outline"
onClick={() => onBack({exercise: id, solutions: [], score: {correct: 1, total: 1, missing: 0}, type})}
onClick={() =>
onBack({
exercise: id,
solutions: mediaBlob ? [{id, solution: mediaBlob}] : [],
score: {correct: 1, total: 1, missing: 0},
type,
})
}
className="max-w-[200px] self-end w-full">
Back
</Button>
<Button
color="green"
disabled={!mediaBlob}
onClick={() => onNext({exercise: id, solutions: [], score: {correct: 1, total: 1, missing: 0}, type})}
onClick={() =>
onNext({
exercise: id,
solutions: mediaBlob ? [{id, solution: mediaBlob}] : [],
score: {correct: 1, total: 1, missing: 0},
type,
})
}
className="max-w-[200px] self-end w-full">
Next
</Button>