|
|
|
|
@@ -1,92 +1,199 @@
|
|
|
|
|
import ProfileLevel from "@/components/ProfileLevel";
|
|
|
|
|
import {errorButtonStyle, infoButtonStyle} from "@/constants/buttonStyles";
|
|
|
|
|
import Button from "@/components/Low/Button";
|
|
|
|
|
import ModuleTitle from "@/components/Medium/ModuleTitle";
|
|
|
|
|
import {Module} from "@/interfaces";
|
|
|
|
|
import {User} from "@/interfaces/user";
|
|
|
|
|
import {ICONS} from "@/resources/modules";
|
|
|
|
|
import {mdiArrowLeft, mdiArrowRight} from "@mdi/js";
|
|
|
|
|
import Icon from "@mdi/react";
|
|
|
|
|
import useExamStore from "@/stores/examStore";
|
|
|
|
|
import {calculateBandScore} from "@/utils/score";
|
|
|
|
|
import clsx from "clsx";
|
|
|
|
|
import Link from "next/link";
|
|
|
|
|
import router from "next/router";
|
|
|
|
|
import {useRouter} from "next/router";
|
|
|
|
|
import {useEffect, useState} from "react";
|
|
|
|
|
import {BsArrowCounterclockwise, BsBook, BsEyeFill, BsHeadphones, BsMegaphone, BsPen, BsShareFill} from "react-icons/bs";
|
|
|
|
|
|
|
|
|
|
interface Score {
|
|
|
|
|
module: Module;
|
|
|
|
|
correct: number;
|
|
|
|
|
total: number;
|
|
|
|
|
missing: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
user: User;
|
|
|
|
|
modules: Module[];
|
|
|
|
|
scores: {
|
|
|
|
|
module?: Module;
|
|
|
|
|
correct: number;
|
|
|
|
|
total: number;
|
|
|
|
|
}[];
|
|
|
|
|
scores: Score[];
|
|
|
|
|
onViewResults: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function Finish({user, scores, modules, onViewResults}: Props) {
|
|
|
|
|
const renderModuleScore = (module: Module) => {
|
|
|
|
|
const moduleScores = scores.filter((x) => x.module === module);
|
|
|
|
|
if (moduleScores.length === 0) {
|
|
|
|
|
return <>0</>;
|
|
|
|
|
}
|
|
|
|
|
const [selectedModule, setSelectedModule] = useState(modules[0]);
|
|
|
|
|
const [selectedScore, setSelectedScore] = useState<Score>(scores.find((x) => x.module === modules[0])!);
|
|
|
|
|
|
|
|
|
|
return moduleScores.map((x, index) => (
|
|
|
|
|
<span key={index}>
|
|
|
|
|
{x.correct} / {x.total}
|
|
|
|
|
</span>
|
|
|
|
|
));
|
|
|
|
|
};
|
|
|
|
|
const exams = useExamStore((state) => state.exams);
|
|
|
|
|
|
|
|
|
|
const renderModuleTotal = (module: Module) => {
|
|
|
|
|
const moduleScores = scores.filter((x) => x.module === module);
|
|
|
|
|
if (moduleScores.length === 0) {
|
|
|
|
|
return <>0</>;
|
|
|
|
|
}
|
|
|
|
|
useEffect(() => setSelectedScore(scores.find((x) => x.module === selectedModule)!), [scores, selectedModule]);
|
|
|
|
|
|
|
|
|
|
const total = moduleScores.reduce((accumulator, current) => accumulator + current.total, 0);
|
|
|
|
|
const correct = moduleScores.reduce((accumulator, current) => accumulator + current.correct, 0);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<span>
|
|
|
|
|
{correct} / {total} | {Math.floor((correct / total) * 100)}%
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
const moduleColors: {[key in Module]: {progress: string; inner: string}} = {
|
|
|
|
|
reading: {
|
|
|
|
|
progress: "text-ielts-reading",
|
|
|
|
|
inner: "bg-ielts-reading-light",
|
|
|
|
|
},
|
|
|
|
|
listening: {
|
|
|
|
|
progress: "text-ielts-listening",
|
|
|
|
|
inner: "bg-ielts-listening-light",
|
|
|
|
|
},
|
|
|
|
|
writing: {
|
|
|
|
|
progress: "text-ielts-writing",
|
|
|
|
|
inner: "bg-ielts-writing-light",
|
|
|
|
|
},
|
|
|
|
|
speaking: {
|
|
|
|
|
progress: "text-ielts-speaking",
|
|
|
|
|
inner: "bg-ielts-speaking-light",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="w-full h-full relative">
|
|
|
|
|
<section className="h-full w-full flex flex-col items-center justify-center gap-4">
|
|
|
|
|
<ProfileLevel user={user} className="h-1/2" />
|
|
|
|
|
<div className="h-2/3 w-2/3 flex flex-col items-center gap-4">
|
|
|
|
|
<div className="rounded-xl p-2 md:p-4 items-center flex lg:justify-center gap-2 md:gap-4 max-w-[100%] overflow-auto">
|
|
|
|
|
{modules.map((module) => (
|
|
|
|
|
<>
|
|
|
|
|
<div className="w-full min-h-full h-fit flex flex-col items-center justify-between gap-8">
|
|
|
|
|
<ModuleTitle
|
|
|
|
|
module={selectedModule}
|
|
|
|
|
totalExercises={exams.find((x) => x.module === selectedModule)!.exercises.length}
|
|
|
|
|
exerciseIndex={exams.find((x) => x.module === selectedModule)!.exercises.length}
|
|
|
|
|
minTimer={exams.find((x) => x.module === selectedModule)!.minTimer}
|
|
|
|
|
disableTimer
|
|
|
|
|
/>
|
|
|
|
|
<div className="flex gap-4 self-start">
|
|
|
|
|
{modules.includes("reading") && (
|
|
|
|
|
<div
|
|
|
|
|
onClick={() => setSelectedModule("reading")}
|
|
|
|
|
className={clsx(
|
|
|
|
|
"flex gap-2 items-center rounded-xl p-4 cursor-pointer hover:shadow-lg transition duration-300 ease-in-out hover:bg-ielts-reading hover:text-white",
|
|
|
|
|
selectedModule === "reading" ? "bg-ielts-reading text-white" : "bg-mti-gray-smoke text-ielts-reading",
|
|
|
|
|
)}>
|
|
|
|
|
<BsBook className="w-6 h-6" />
|
|
|
|
|
<span className="font-semibold">Reading</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{modules.includes("listening") && (
|
|
|
|
|
<div
|
|
|
|
|
onClick={() => setSelectedModule("listening")}
|
|
|
|
|
className={clsx(
|
|
|
|
|
"flex gap-2 items-center rounded-xl p-4 cursor-pointer hover:shadow-lg transition duration-300 ease-in-out hover:bg-ielts-listening hover:text-white",
|
|
|
|
|
selectedModule === "listening" ? "bg-ielts-listening text-white" : "bg-mti-gray-smoke text-ielts-listening",
|
|
|
|
|
)}>
|
|
|
|
|
<BsHeadphones className="w-6 h-6" />
|
|
|
|
|
<span className="font-semibold">Listening</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{modules.includes("writing") && (
|
|
|
|
|
<div
|
|
|
|
|
onClick={() => setSelectedModule("writing")}
|
|
|
|
|
className={clsx(
|
|
|
|
|
"flex gap-2 items-center rounded-xl p-4 cursor-pointer hover:shadow-lg transition duration-300 ease-in-out hover:bg-ielts-writing hover:text-white",
|
|
|
|
|
selectedModule === "writing" ? "bg-ielts-writing text-white" : "bg-mti-gray-smoke text-ielts-writing",
|
|
|
|
|
)}>
|
|
|
|
|
<BsPen className="w-6 h-6" />
|
|
|
|
|
<span className="font-semibold">Writing</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{modules.includes("speaking") && (
|
|
|
|
|
<div
|
|
|
|
|
onClick={() => setSelectedModule("speaking")}
|
|
|
|
|
className={clsx(
|
|
|
|
|
"flex gap-2 items-center rounded-xl p-4 cursor-pointer hover:shadow-lg transition duration-300 ease-in-out hover:bg-ielts-speaking hover:text-white",
|
|
|
|
|
selectedModule === "speaking" ? "bg-ielts-speaking text-white" : "bg-mti-gray-smoke text-ielts-speaking",
|
|
|
|
|
)}>
|
|
|
|
|
<BsMegaphone className="w-6 h-6" />
|
|
|
|
|
<span className="font-semibold">Speaking</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="w-full flex gap-9 mt-32 items-center justify-between">
|
|
|
|
|
<span className="max-w-3xl">
|
|
|
|
|
Congratulations on your exam performance! You achieved an impressive{" "}
|
|
|
|
|
<span className="font-bold">
|
|
|
|
|
level {calculateBandScore(selectedScore.correct, selectedScore.total, selectedModule, user.focus)}
|
|
|
|
|
</span>
|
|
|
|
|
, demonstrating excellent mastery of the assessed knowledge.
|
|
|
|
|
<br />
|
|
|
|
|
<br />
|
|
|
|
|
If you disagree with the result, you can request a review by a qualified teacher. We are committed to the accuracy and
|
|
|
|
|
transparency of the results. Please contact us for further information.
|
|
|
|
|
<br />
|
|
|
|
|
<br />
|
|
|
|
|
Congratulations again on your outstanding achievement! We are here to support you on your academic journey.
|
|
|
|
|
</span>
|
|
|
|
|
<div className="flex gap-9 px-16">
|
|
|
|
|
<div
|
|
|
|
|
className={clsx("radial-progress overflow-hidden", moduleColors[selectedModule].progress)}
|
|
|
|
|
style={{"--value": (selectedScore.correct / selectedScore.total) * 100, "--thickness": "12px", "--size": "13rem"} as any}>
|
|
|
|
|
<div
|
|
|
|
|
className={`flex flex-col gap-12 min-w-[176px] items-center justify-center border-2 border-ielts-${module} bg-ielts-${module}-transparent py-4 px-2 rounded-xl text-white font-semibold`}
|
|
|
|
|
key={module}>
|
|
|
|
|
<div className="flex flex-col items-center">
|
|
|
|
|
<Icon path={ICONS[module]} color="white" size={2} />
|
|
|
|
|
<span>{module.toUpperCase()}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-col">{renderModuleScore(module)}</div>
|
|
|
|
|
<div>TOTAL: {renderModuleTotal(module)}</div>
|
|
|
|
|
className={clsx(
|
|
|
|
|
"w-48 h-48 rounded-full flex flex-col items-center justify-center",
|
|
|
|
|
moduleColors[selectedModule].inner,
|
|
|
|
|
)}>
|
|
|
|
|
<span className="text-xl">Level</span>
|
|
|
|
|
<span className="text-3xl font-bold">
|
|
|
|
|
{calculateBandScore(selectedScore.correct, selectedScore.total, selectedModule, user.focus)}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="w-full flex flex-col gap-4 lg:gap-0 md:flex-row justify-center items-center lg:justify-between">
|
|
|
|
|
<Link href="/">
|
|
|
|
|
<button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)}>
|
|
|
|
|
<div className="absolute left-4">
|
|
|
|
|
<Icon path={mdiArrowLeft} color="white" size={1} />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-col gap-5">
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<div className="w-3 h-3 bg-mti-blue-light rounded-full mt-1" />
|
|
|
|
|
<div className="flex flex-col">
|
|
|
|
|
<span className="text-mti-blue-light">
|
|
|
|
|
{(((selectedScore.total - selectedScore.missing) / selectedScore.total) * 100).toFixed(0)}%
|
|
|
|
|
</span>
|
|
|
|
|
<span className="text-lg">Completion</span>
|
|
|
|
|
</div>
|
|
|
|
|
Go Home
|
|
|
|
|
</button>
|
|
|
|
|
</Link>
|
|
|
|
|
<button className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)} onClick={onViewResults}>
|
|
|
|
|
View Solutions
|
|
|
|
|
<div className="absolute right-4">
|
|
|
|
|
<Icon path={mdiArrowRight} color="white" size={1} />
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<div className="w-3 h-3 bg-mti-green-light rounded-full mt-1" />
|
|
|
|
|
<div className="flex flex-col">
|
|
|
|
|
<span className="text-mti-green-light">{selectedScore.total.toString().padStart(2, "0")}</span>
|
|
|
|
|
<span className="text-lg">Correct</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<div className="w-3 h-3 bg-mti-orange-light rounded-full mt-1" />
|
|
|
|
|
<div className="flex flex-col">
|
|
|
|
|
<span className="text-mti-orange-light">
|
|
|
|
|
{(selectedScore.total - selectedScore.correct).toString().padStart(2, "0")}
|
|
|
|
|
</span>
|
|
|
|
|
<span className="text-lg">Wrong</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="self-end flex justify-between w-full gap-8 absolute bottom-8 left-0 px-8">
|
|
|
|
|
<div className="flex gap-8">
|
|
|
|
|
<div className="w-fit flex flex-col items-center gap-1 cursor-pointer">
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => window.location.reload()}
|
|
|
|
|
className="w-11 h-11 rounded-full bg-mti-green-light hover:bg-mti-green flex items-center justify-center transition duration-300 ease-in-out">
|
|
|
|
|
<BsArrowCounterclockwise className="text-white w-7 h-7" />
|
|
|
|
|
</button>
|
|
|
|
|
<span>Play Again</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="w-fit flex flex-col items-center gap-1 cursor-pointer">
|
|
|
|
|
<button
|
|
|
|
|
onClick={onViewResults}
|
|
|
|
|
className="w-11 h-11 rounded-full bg-mti-green-light hover:bg-mti-green flex items-center justify-center transition duration-300 ease-in-out">
|
|
|
|
|
<BsEyeFill className="text-white w-7 h-7" />
|
|
|
|
|
</button>
|
|
|
|
|
<span>Review Answers</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Link href="/" className="max-w-[200px] w-full self-end">
|
|
|
|
|
<Button color="green" className="max-w-[200px] self-end w-full">
|
|
|
|
|
Dashboard
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|