From 3fee4292f14ff8583283e4ae775d2bf02b65ed2f Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 7 Aug 2023 23:39:29 +0100 Subject: [PATCH] Updated the Writing to work with another format --- src/components/Exercises/Writing.tsx | 29 +++++++++++++++++++++++++--- src/interfaces/exam.ts | 3 ++- src/pages/api/exam/[module]/index.ts | 11 +++++++---- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/components/Exercises/Writing.tsx b/src/components/Exercises/Writing.tsx index 29439d55..34c13576 100644 --- a/src/components/Exercises/Writing.tsx +++ b/src/components/Exercises/Writing.tsx @@ -7,7 +7,18 @@ import Button from "../Low/Button"; import {Dialog, Transition} from "@headlessui/react"; import useExamStore from "@/stores/examStore"; -export default function Writing({id, prompt, info, type, wordCounter, attachment, userSolutions, onNext, onBack}: WritingExercise & CommonProps) { +export default function Writing({ + id, + prompt, + prefix, + suffix, + type, + wordCounter, + attachment, + userSolutions, + onNext, + onBack, +}: WritingExercise & CommonProps) { const [isModalOpen, setIsModalOpen] = useState(false); const [inputText, setInputText] = useState(userSolutions.length === 1 ? userSolutions[0].solution : ""); const [isSubmitEnabled, setIsSubmitEnabled] = useState(false); @@ -68,7 +79,14 @@ export default function Writing({id, prompt, info, type, wordCounter, attachment )}
- {info} + + {prefix.split("\\n").map((line) => ( + <> + {line} +
+ + ))} +
{prompt.split("\\n").map((line, index) => ( @@ -89,7 +107,12 @@ export default function Writing({id, prompt, info, type, wordCounter, attachment
- You should write {wordCounter.type === "min" ? "at least" : "at most"} {wordCounter.limit} words. + {suffix.split("\\n").map((line) => ( + <> + {line} +
+ + ))}