From d8bf10eaea02e53029adcea9e1d42c557052ad33 Mon Sep 17 00:00:00 2001 From: Carlos Mesquita Date: Fri, 6 Sep 2024 11:21:35 +0100 Subject: [PATCH] Small bug fix --- next.config.js | 2 +- src/pages/(generation)/LevelGeneration.tsx | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/next.config.js b/next.config.js index 2203b000..cdba31d8 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,7 @@ /** @type {import('next').NextConfig} */ const websiteUrl = process.env.NODE_ENV === 'production' ? "https://encoach.com" : "http://localhost:3000"; const nextConfig = { - reactStrictMode: false, + reactStrictMode: true, output: "standalone", async headers() { return [ diff --git a/src/pages/(generation)/LevelGeneration.tsx b/src/pages/(generation)/LevelGeneration.tsx index 20122353..a143132f 100644 --- a/src/pages/(generation)/LevelGeneration.tsx +++ b/src/pages/(generation)/LevelGeneration.tsx @@ -144,7 +144,7 @@ const TaskTab = ({ section, label, index, setSection }: { section: LevelSection; multiple_choice_underlined: "Welcome to {part} of the {label}. In this section, you'll be asked to identify the underlined word or group of words that is not correct in each sentence.\n\nFor each question, carefully review the sentence and click on the option (A, B, C, or D) that you believe contains the incorrect word or group of words. After making your selection, you can proceed to the next question by clicking \"Next\". If needed, you can go back to previous questions by clicking \"Back\".", blank_space_text: undefined, reading_passage_utas: "Welcome to {part} of the {label}. In this section, you will read a text and answer the questions that follow.\n\nCarefully read the provided text, then select the correct answer (A, B, C, or D) for each question. After making your selection, you can proceed to the next question by clicking \"Next\". If you need to review or change your answers, you can go back at any time by clicking \"Back\".", - fill_blanks_mc: "Welcome to {part} of the {label}. In this section, you will read a text and choose the correct word to fill in each blank space.\n\nFor each question, carefully read the text and click on the option (A, B, C, or D) that you believe best fits the context. Once you've made your choice, proceed to the next question by clicking \"Next\". If needed, you can go back to review or change your answers by clicking \"Back\"." + fill_blanks_mc: "Welcome to {part} of the {label}. In this section, you will read a text and choose the correct word to fill in each blank space.\n\nFor each question, carefully read the text and click on the option that you believe best fits the context." }; const getDefaultPreset = () => { @@ -177,7 +177,7 @@ const TaskTab = ({ section, label, index, setSection }: { section: LevelSection; }, [descriptionOption]) useEffect(() => { - if (section.part && ((descriptionOption.value === "Custom" || descriptionOption.value === "Default") && !section.part.intro)) { + if (section?.part && ((descriptionOption.value === "Custom" || descriptionOption.value === "Default") && !section.part.intro)) { setUpdateIntro(true); } }, [section?.part, descriptionOption, category]) @@ -590,11 +590,27 @@ const LevelGeneration = ({ id }: Props) => { setIsLoading(true); + parts.forEach((part) => { + part.part!.exercises.forEach((exercise, i) => { + switch(exercise.type) { + case 'fillBlanks': + exercise.prompt.replaceAll('\n', '\\n') + break; + case 'multipleChoice': + exercise.prompt.replaceAll('\n', '\\n') + break; + case 'writeBlanks': + exercise.prompt.replaceAll('\n', '\\n') + break; + } + }); + }) + const exam = { ...generatedExam, id, label: label, - parts: generatedExam.parts.map((p, i) => ({ ...p, exercises: parts[i].part!.exercises, category: parts[i].part?.category, intro: parts[i].part?.intro })), + parts: generatedExam.parts.map((p, i) => ({ ...p, exercises: parts[i].part!.exercises, category: parts[i].part?.category, intro: parts[i].part?.intro?.replaceAll('\n', '\\n') })), }; axios