Updated the Writing to work with another format

This commit is contained in:
Tiago Ribeiro
2023-08-07 23:39:29 +01:00
parent 7e9e28f134
commit 3fee4292f1
3 changed files with 35 additions and 8 deletions

View File

@@ -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
)}
<div className="flex flex-col h-full w-full gap-9 mb-20">
<div className="flex flex-col w-full gap-7 bg-mti-gray-smoke rounded-xl py-8 pb-12 px-16">
<span>{info}</span>
<span>
{prefix.split("\\n").map((line) => (
<>
{line}
<br />
</>
))}
</span>
<span className="font-semibold">
{prompt.split("\\n").map((line, index) => (
<Fragment key={index}>
@@ -89,7 +107,12 @@ export default function Writing({id, prompt, info, type, wordCounter, attachment
<div className="w-full h-full flex flex-col gap-4">
<span>
You should write {wordCounter.type === "min" ? "at least" : "at most"} {wordCounter.limit} words.
{suffix.split("\\n").map((line) => (
<>
{line}
<br />
</>
))}
</span>
<textarea
className="w-full h-full min-h-[148px] cursor-text px-7 py-8 input border-2 border-mti-gray-platinum bg-white rounded-3xl"