diff --git a/src/exams/Finish.tsx b/src/exams/Finish.tsx index e69de29b..86e53e75 100644 --- a/src/exams/Finish.tsx +++ b/src/exams/Finish.tsx @@ -0,0 +1,93 @@ +import ProfileLevel from "@/components/ProfileLevel"; +import {errorButtonStyle, infoButtonStyle} from "@/constants/buttonStyles"; +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 clsx from "clsx"; +import Link from "next/link"; +import router from "next/router"; + +interface Props { + user: User; + modules: Module[]; + scores: { + module?: Module; + correct: number; + total: number; + }[]; + 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>; + } + + return moduleScores.map((x, index) => ( + + {x.correct} / {x.total} + + )); + }; + + const renderModuleTotal = (module: Module) => { + const moduleScores = scores.filter((x) => x.module === module); + if (moduleScores.length === 0) { + return <>0>; + } + + const total = moduleScores.reduce((accumulator, current) => accumulator + current.total, 0); + const correct = moduleScores.reduce((accumulator, current) => accumulator + current.correct, 0); + + return ( + + {correct} / {total} | {Math.floor((correct / total) * 100)}% + + ); + }; + + return ( +