Added Speaking to level, fixed a bug where it was causing level to crash if the listening was already created and the section was switched, added true false exercises to listening
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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: ""
|
||||
}))
|
||||
],
|
||||
sectionId: 1,
|
||||
};
|
||||
case 2:
|
||||
return {
|
||||
title: data.topic,
|
||||
text: data.question,
|
||||
prompts: data.prompts,
|
||||
sectionId: 2,
|
||||
type: "speaking"
|
||||
};
|
||||
case 3:
|
||||
return {
|
||||
title: data.topic,
|
||||
prompts: data.questions.map((item: any) => ({
|
||||
text: item || "",
|
||||
video_url: ""
|
||||
})),
|
||||
sectionId: 3,
|
||||
};
|
||||
default:
|
||||
return data;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user