From 79a532b5fffe1e126ad726898175d50e4b8d61ae Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Sun, 28 May 2023 10:00:06 +0100 Subject: [PATCH] - Implemented an image attachment to the Writing exercise; - Made it so the exams are now sorted when going through the history; - Corrected some little mistakes; --- src/components/Diagnostic.tsx | 2 +- src/components/Exercises/Writing.tsx | 4 +++- src/exams/Selection.tsx | 4 +++- src/interfaces/exam.ts | 5 +++++ src/pages/api/exam/[module]/index.ts | 6 ++++-- src/pages/exam/index.tsx | 2 +- src/pages/history.tsx | 10 ++++++++-- src/utils/moduleUtils.ts | 6 ++++++ 8 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/components/Diagnostic.tsx b/src/components/Diagnostic.tsx index fe225045..a67159f5 100644 --- a/src/components/Diagnostic.tsx +++ b/src/components/Diagnostic.tsx @@ -47,7 +47,7 @@ export default function Diagnostic({onFinish}: Props) { const updateUser = (callback: () => void) => { axios - .post("/api/users/update", {focus, levels, isFirstLogin: false}) + .patch("/api/users/update", {focus, levels, isFirstLogin: false}) .then(callback) .catch(() => { toast.error("Something went wrong, please try again later!", {toastId: "user-update-error"}); diff --git a/src/components/Exercises/Writing.tsx b/src/components/Exercises/Writing.tsx index 5db9d90b..cf2d5063 100644 --- a/src/components/Exercises/Writing.tsx +++ b/src/components/Exercises/Writing.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @next/next/no-img-element */ import {errorButtonStyle, infoButtonStyle} from "@/constants/buttonStyles"; import {WritingExercise} from "@/interfaces/exam"; import {mdiArrowLeft, mdiArrowRight} from "@mdi/js"; @@ -7,7 +8,7 @@ import {CommonProps} from "."; import {Fragment, useEffect, useState} from "react"; import {toast} from "react-toastify"; -export default function Writing({id, prompt, info, type, wordCounter, onNext, onBack}: WritingExercise & CommonProps) { +export default function Writing({id, prompt, info, type, wordCounter, attachment, onNext, onBack}: WritingExercise & CommonProps) { const [inputText, setInputText] = useState(""); const [isSubmitEnabled, setIsSubmitEnabled] = useState(false); @@ -40,6 +41,7 @@ export default function Writing({id, prompt, info, type, wordCounter, onNext, on You should write {wordCounter.type === "min" ? "at least" : "at most"} {wordCounter.limit} words. + {attachment && Exercise attachment}