Updated the Speaking to also work the with exam session persistence

This commit is contained in:
Tiago Ribeiro
2024-02-07 17:15:41 +00:00
parent 65fe1ec8ed
commit 2a9e204041
8 changed files with 177 additions and 58 deletions

View File

@@ -45,16 +45,17 @@ export const evaluateSpeakingAnswer = async (exercise: SpeakingExercise | Intera
}
};
const downloadBlob = async (url: string): Promise<Buffer> => {
export const downloadBlob = async (url: string): Promise<Buffer> => {
const blobResponse = await axios.get(url, {responseType: "arraybuffer"});
return Buffer.from(blobResponse.data, "binary");
};
const evaluateSpeakingExercise = async (exercise: SpeakingExercise, exerciseId: string, solution: UserSolution, id: string) => {
const formData = new FormData();
const audioBlob = await downloadBlob(solution.solutions[0].solution.trim());
const audioFile = new File([audioBlob], "audio.wav", {type: "audio/wav"});
const formData = new FormData();
formData.append("audio", audioFile, "audio.wav");
const evaluationQuestion =
@@ -64,7 +65,7 @@ const evaluateSpeakingExercise = async (exercise: SpeakingExercise, exerciseId:
const config = {
headers: {
"Content-Type": "audio/mp3",
"Content-Type": "audio/wav",
},
};