From 74d3f30c93fd583a5d3b387c2d6e515e28f5d89f Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Tue, 23 Jan 2024 10:11:04 +0000 Subject: [PATCH] Added the ability to choose between partial and full exams --- src/components/Diagnostic.tsx | 2 +- src/exams/Selection.tsx | 46 +++++++--- src/pages/(exam)/ExamPage.tsx | 8 +- src/pages/(generation)/SpeakingGeneration.tsx | 9 +- src/pages/api/exam/[module]/index.ts | 11 +-- src/utils/exams.be.ts | 83 +++++++++---------- src/utils/exams.ts | 10 ++- 7 files changed, 98 insertions(+), 71 deletions(-) diff --git a/src/components/Diagnostic.tsx b/src/components/Diagnostic.tsx index a221f1d2..f7b448f4 100644 --- a/src/components/Diagnostic.tsx +++ b/src/components/Diagnostic.tsx @@ -36,7 +36,7 @@ export default function Diagnostic({onFinish}: Props) { }; const selectExam = () => { - const examPromises = MODULE_ARRAY.map((module) => getExam(module, true)); + const examPromises = MODULE_ARRAY.map((module) => getExam(module, true, "partial")); Promise.all(examPromises).then((exams) => { if (exams.every((x) => !!x)) { diff --git a/src/exams/Selection.tsx b/src/exams/Selection.tsx index 2485bb70..02dcb681 100644 --- a/src/exams/Selection.tsx +++ b/src/exams/Selection.tsx @@ -12,17 +12,19 @@ import {calculateAverageLevel} from "@/utils/score"; import {sortByModuleName} from "@/utils/moduleUtils"; import {capitalize} from "lodash"; import ProfileSummary from "@/components/ProfileSummary"; +import {Variant} from "@/interfaces/exam"; interface Props { user: User; page: "exercises" | "exams"; - onStart: (modules: Module[], avoidRepeated: boolean) => void; + onStart: (modules: Module[], avoidRepeated: boolean, variant: Variant) => void; disableSelection?: boolean; } export default function Selection({user, page, onStart, disableSelection = false}: Props) { const [selectedModules, setSelectedModules] = useState([]); const [avoidRepeatedExams, setAvoidRepeatedExams] = useState(true); + const [variant, setVariant] = useState("full"); const {stats} = useStats(user?.id); const toggleModule = (module: Module) => { @@ -202,20 +204,37 @@ export default function Selection({user, page, onStart, disableSelection = false )}
-
setAvoidRepeatedExams((prev) => !prev)}> - +
- + className="flex gap-3 items-center text-mti-gray-dim text-sm cursor-pointer w-full -md:justify-center" + onClick={() => setAvoidRepeatedExams((prev) => !prev)}> + +
+ +
+ + Avoid Repeated Questions + +
+
setVariant((prev) => (prev === "full" ? "partial" : "full"))}> + +
+ +
+ Full length exams
- Avoid Repeated Questions