diff --git a/public/radial_progress/azul_0.png b/public/radial_progress/azul_0.png new file mode 100644 index 00000000..04fd0465 Binary files /dev/null and b/public/radial_progress/azul_0.png differ diff --git a/public/radial_progress/azul_10.png b/public/radial_progress/azul_10.png new file mode 100644 index 00000000..ffd21bdf Binary files /dev/null and b/public/radial_progress/azul_10.png differ diff --git a/public/radial_progress/azul_100.png b/public/radial_progress/azul_100.png new file mode 100644 index 00000000..99a924df Binary files /dev/null and b/public/radial_progress/azul_100.png differ diff --git a/public/radial_progress/azul_20.png b/public/radial_progress/azul_20.png new file mode 100644 index 00000000..51793169 Binary files /dev/null and b/public/radial_progress/azul_20.png differ diff --git a/public/radial_progress/azul_30.png b/public/radial_progress/azul_30.png new file mode 100644 index 00000000..7bdbeba9 Binary files /dev/null and b/public/radial_progress/azul_30.png differ diff --git a/public/radial_progress/azul_40.png b/public/radial_progress/azul_40.png new file mode 100644 index 00000000..9cbc692f Binary files /dev/null and b/public/radial_progress/azul_40.png differ diff --git a/public/radial_progress/azul_50.png b/public/radial_progress/azul_50.png new file mode 100644 index 00000000..3f5bf56f Binary files /dev/null and b/public/radial_progress/azul_50.png differ diff --git a/public/radial_progress/azul_60.png b/public/radial_progress/azul_60.png new file mode 100644 index 00000000..63838397 Binary files /dev/null and b/public/radial_progress/azul_60.png differ diff --git a/public/radial_progress/azul_70.png b/public/radial_progress/azul_70.png new file mode 100644 index 00000000..6351d5b8 Binary files /dev/null and b/public/radial_progress/azul_70.png differ diff --git a/public/radial_progress/azul_80.png b/public/radial_progress/azul_80.png new file mode 100644 index 00000000..714a10a1 Binary files /dev/null and b/public/radial_progress/azul_80.png differ diff --git a/public/radial_progress/azul_90.png b/public/radial_progress/azul_90.png new file mode 100644 index 00000000..93febb16 Binary files /dev/null and b/public/radial_progress/azul_90.png differ diff --git a/public/radial_progress/laranja_0.png b/public/radial_progress/laranja_0.png new file mode 100644 index 00000000..de742789 Binary files /dev/null and b/public/radial_progress/laranja_0.png differ diff --git a/public/radial_progress/laranja_10.png b/public/radial_progress/laranja_10.png new file mode 100644 index 00000000..b3bf74fb Binary files /dev/null and b/public/radial_progress/laranja_10.png differ diff --git a/public/radial_progress/laranja_100.png b/public/radial_progress/laranja_100.png new file mode 100644 index 00000000..f360e144 Binary files /dev/null and b/public/radial_progress/laranja_100.png differ diff --git a/public/radial_progress/laranja_20.png b/public/radial_progress/laranja_20.png new file mode 100644 index 00000000..9765ae01 Binary files /dev/null and b/public/radial_progress/laranja_20.png differ diff --git a/public/radial_progress/laranja_30.png b/public/radial_progress/laranja_30.png new file mode 100644 index 00000000..62a90986 Binary files /dev/null and b/public/radial_progress/laranja_30.png differ diff --git a/public/radial_progress/laranja_40.png b/public/radial_progress/laranja_40.png new file mode 100644 index 00000000..d3c71604 Binary files /dev/null and b/public/radial_progress/laranja_40.png differ diff --git a/public/radial_progress/laranja_50.png b/public/radial_progress/laranja_50.png new file mode 100644 index 00000000..9f05d69b Binary files /dev/null and b/public/radial_progress/laranja_50.png differ diff --git a/public/radial_progress/laranja_60.png b/public/radial_progress/laranja_60.png new file mode 100644 index 00000000..ef5249a5 Binary files /dev/null and b/public/radial_progress/laranja_60.png differ diff --git a/public/radial_progress/laranja_70.png b/public/radial_progress/laranja_70.png new file mode 100644 index 00000000..9db27bd0 Binary files /dev/null and b/public/radial_progress/laranja_70.png differ diff --git a/public/radial_progress/laranja_80.png b/public/radial_progress/laranja_80.png new file mode 100644 index 00000000..0b8529b5 Binary files /dev/null and b/public/radial_progress/laranja_80.png differ diff --git a/public/radial_progress/laranja_90.png b/public/radial_progress/laranja_90.png new file mode 100644 index 00000000..7110916b Binary files /dev/null and b/public/radial_progress/laranja_90.png differ diff --git a/src/exams/pdf/details/radial.result.tsx b/src/exams/pdf/details/radial.result.tsx index df999000..00a26888 100644 --- a/src/exams/pdf/details/radial.result.tsx +++ b/src/exams/pdf/details/radial.result.tsx @@ -1,36 +1,50 @@ +/* eslint-disable jsx-a11y/alt-text */ import React from "react"; import { - Document, - Page, View, Text, - StyleSheet, Image, } from "@react-pdf/renderer"; import { styles } from "../styles"; import { ModuleScore } from "@/interfaces/module.scores"; -export const RadialResult = ({ module, score, total }: ModuleScore) => ( +export const RadialResult = ({ module, score, total, png }: ModuleScore) => ( - + {module} - {score} - Out of {total} + + + {score} + out of {total} + ); diff --git a/src/interfaces/module.scores.ts b/src/interfaces/module.scores.ts index cd4b0ea2..622f9ba4 100644 --- a/src/interfaces/module.scores.ts +++ b/src/interfaces/module.scores.ts @@ -5,4 +5,5 @@ export interface ModuleScore { total: number; module: Module | 'Overall'; feedback?: string, + png?: string, } \ No newline at end of file diff --git a/src/pages/api/stats/[id]/export.tsx b/src/pages/api/stats/[id]/export.tsx index 4a8829b9..7c345516 100644 --- a/src/pages/api/stats/[id]/export.tsx +++ b/src/pages/api/stats/[id]/export.tsx @@ -125,6 +125,15 @@ const generateQRCode = async (link: string) => { } }; +type RADIAL_PROGRESS_COLOR = 'laranja' | 'azul'; + +const getRadialProgressPNG = (color: RADIAL_PROGRESS_COLOR, score: number, total: number) => { + const percent = (score / total) * 100; + const remainder = percent % 10; + const roundedPercent = percent - remainder; + return `public/radial_progress/${color}_${roundedPercent}.png`; +} + async function post(req: NextApiRequest, res: NextApiResponse) { if (req.session.user) { const { id } = req.query as { id: string }; @@ -154,7 +163,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) { const user = docUser.data() as User; const stats = docsSnap.docs.map((d) => d.data()); - const results = stats.reduce((accm: ModuleScore[], { module, score }) => { + const results = (stats.reduce((accm: ModuleScore[], { module, score }) => { const fixedModuleStr = module[0].toUpperCase() + module.substring(1); if (accm.find((e: ModuleScore) => e.module === fixedModuleStr)) { return accm.map((e: ModuleScore) => { @@ -179,7 +188,13 @@ async function post(req: NextApiRequest, res: NextApiResponse) { feedback: getFeedback(module), }, ]; - }, []) as ModuleScore[]; + }, []) as ModuleScore[]).map((moduleScore) => { + const { score, total } = moduleScore; + return { + ...moduleScore, + png: getRadialProgressPNG('azul', score, total), + } + }); const [stat] = stats as Stat[]; @@ -196,6 +211,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) { module: "Overall", score: overallScore, total: overallTotal, + png: getRadialProgressPNG('laranja', overallScore, overallTotal), } as ModuleScore; const testDetails = [overallDetail, ...results]; const renderDetails = () => {