import { InteractiveSpeakingExercise, SpeakingExercise } from "@/interfaces/exam"; import { speakingTask } from "@/stores/examEditor/sections"; export const createSpeakingExercise = (res: any) => { const taskNumber = Number(res.generating.split("_")[1]); const baseExercise = speakingTask(taskNumber); return { ...baseExercise, ...getSpeakingTaskData(taskNumber, res.result[0]) } as SpeakingExercise | InteractiveSpeakingExercise; }; const getSpeakingTaskData = (taskNumber: number, data: any) => { switch (taskNumber) { case 1: return { first_title: data.first_topic, second_title: data.second_topic, prompts: [ ...data.prompts.map((item: any) => ({ text: item, video_url: "" })) ], difficulty: data.difficulty, sectionId: 1, }; case 2: return { title: data.topic, text: data.question, prompts: data.prompts, difficulty: data.difficulty, sectionId: 2, type: "speaking" }; case 3: return { title: data.topic, prompts: data.questions.map((item: any) => ({ text: item || "", video_url: "" })), difficulty: data.difficulty, sectionId: 3, }; default: return data; } };