/* eslint-disable @next/next/no-img-element */ import {InteractiveSpeakingExercise} from "@/interfaces/exam"; import {CommonProps} from "."; import {useEffect, useState} from "react"; import Button from "../Low/Button"; import dynamic from "next/dynamic"; import axios from "axios"; import {speakingReverseMarking} from "@/utils/score"; const Waveform = dynamic(() => import("../Waveform"), {ssr: false}); export default function InteractiveSpeaking({ id, type, title, text, prompts, userSolutions, onNext, onBack, }: InteractiveSpeakingExercise & CommonProps) { const [solutionsURL, setSolutionsURL] = useState([]); useEffect(() => { if (userSolutions && userSolutions.length > 0) { Promise.all(userSolutions[0].solution.map((x) => axios.post(`/api/speaking`, {path: x.answer}, {responseType: "arraybuffer"}))).then( (values) => { setSolutionsURL( values.map(({data}) => { const blob = new Blob([data], {type: "audio/wav"}); const url = URL.createObjectURL(blob); return url; }), ); }, ); } }, [userSolutions]); return ( <>
{title}
You should talk about the following things:
{prompts.map((x, index) => (
{x.text}
))}
{solutionsURL.map((x, index) => (
))}
{userSolutions && userSolutions.length > 0 && (
{Object.keys(userSolutions[0].evaluation!.task_response).map((key) => (
{key}: Level {userSolutions[0].evaluation!.task_response[key]}
))}
{userSolutions[0].evaluation!.comment}
)}
); }