From b881969bd45d7a8fd38070c5f416a81aa7b05c15 Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 19:10:41 +0000 Subject: [PATCH 1/9] Exporting a report from an user now allows access to the user data of the user that did the exam instead of the current session --- src/pages/api/stats/[id]/export.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/api/stats/[id]/export.tsx b/src/pages/api/stats/[id]/export.tsx index b3374c4c..824c74d9 100644 --- a/src/pages/api/stats/[id]/export.tsx +++ b/src/pages/api/stats/[id]/export.tsx @@ -126,6 +126,15 @@ async function post(req: NextApiRequest, res: NextApiResponse) { const stats = docsSnap.docs.map((d) => d.data()); // verify if the stats already have a pdf generated const hasPDF = stats.find((s) => s.pdf); + // find the user that generated the stats + const statIndex = stats.findIndex((s) => s.user); + + if(statIndex === -1) { + res.status(401).json({ok: false}); + return; + } + const userId = stats[statIndex].user; + if (hasPDF) { // if it does, return the pdf url @@ -138,7 +147,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) { try { // generate the pdf report - const docUser = await getDoc(doc(db, "users", req.session.user.id)); + const docUser = await getDoc(doc(db, "users", userId)); if (docUser.exists()) { // we'll need the user in order to get the user data (name, email, focus, etc); From c05df7d6b71598f09526963d4358b975d3744b8c Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 19:12:05 +0000 Subject: [PATCH 2/9] Removed condition that blocked admins/devs from exporting a pdf for assignment --- src/pages/api/assignments/[id]/export.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pages/api/assignments/[id]/export.tsx b/src/pages/api/assignments/[id]/export.tsx index b57497f2..7ccf0e83 100644 --- a/src/pages/api/assignments/[id]/export.tsx +++ b/src/pages/api/assignments/[id]/export.tsx @@ -113,10 +113,6 @@ async function post(req: NextApiRequest, res: NextApiResponse) { return; } - if (data.assigner !== req.session.user.id) { - res.status(401).json({ok: false}); - return; - } if (data.pdf) { // if it does, return the pdf url const fileRef = ref(storage, data.pdf); From 009c610033bacfe323f41a6bcf6401f46d6b8926 Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 19:26:48 +0000 Subject: [PATCH 3/9] Removed some candidate information --- src/exams/pdf/group.test.report.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/exams/pdf/group.test.report.tsx b/src/exams/pdf/group.test.report.tsx index 6d98cd8a..4fa67f28 100644 --- a/src/exams/pdf/group.test.report.tsx +++ b/src/exams/pdf/group.test.report.tsx @@ -112,11 +112,6 @@ const GroupTestReport = ({ Candidate Information: - Name: {name} - ID: {id} - Email: {email} - Gender: {gender} - Passport ID: {passportId} Total Number of Students: {numberOfStudents} From 4163076524ec6831a30e69a70f4b30ae6004c26b Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 19:27:28 +0000 Subject: [PATCH 4/9] Added passportid to the table ; removed gender column from table --- src/exams/pdf/group.test.report.tsx | 19 +++++++++++++++---- src/interfaces/module.scores.ts | 1 + src/pages/api/assignments/[id]/export.tsx | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/exams/pdf/group.test.report.tsx b/src/exams/pdf/group.test.report.tsx index 4fa67f28..633aa56f 100644 --- a/src/exams/pdf/group.test.report.tsx +++ b/src/exams/pdf/group.test.report.tsx @@ -250,7 +250,19 @@ const GroupTestReport = ({ {showLevel && Level} {studentsData.map( - ({ id, name, email, gender, date, result, level }, index) => ( + ( + { + id, + name, + email, + gender, + date, + result, + level, + passportId: studentPassportId, + }, + index + ) => ( {name} {email} - - {gender} - + {studentPassportId} + {date} diff --git a/src/interfaces/module.scores.ts b/src/interfaces/module.scores.ts index d52d51c4..144ed6aa 100644 --- a/src/interfaces/module.scores.ts +++ b/src/interfaces/module.scores.ts @@ -19,4 +19,5 @@ export interface StudentData { result: string; level?: string; bandScore: number; + passportId?: string; } diff --git a/src/pages/api/assignments/[id]/export.tsx b/src/pages/api/assignments/[id]/export.tsx index 7ccf0e83..5d8a3397 100644 --- a/src/pages/api/assignments/[id]/export.tsx +++ b/src/pages/api/assignments/[id]/export.tsx @@ -235,6 +235,8 @@ async function post(req: NextApiRequest, res: NextApiResponse) { const result = exams.length === 0 ? "N/A" : `${correct}/${total}`; + const userDemographicInformation = user?.demographicInformation as DemographicInformation; + return { id, name: user?.name || "N/A", @@ -244,6 +246,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) { result, level: showLevel ? getLevelScoreForUserExams(bandScore) : undefined, bandScore, + passportId: userDemographicInformation?.passport_id || "" }; }); }; From 7c641508ce50a5db9905d5c90aa71b8a39a8ac86 Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 19:34:15 +0000 Subject: [PATCH 5/9] Added user id to the footer of the report --- src/exams/pdf/test.report.footer.tsx | 21 +++++++++++++++++++-- src/exams/pdf/test.report.tsx | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/exams/pdf/test.report.footer.tsx b/src/exams/pdf/test.report.footer.tsx index 3771fee7..e8c493e6 100644 --- a/src/exams/pdf/test.report.footer.tsx +++ b/src/exams/pdf/test.report.footer.tsx @@ -2,7 +2,11 @@ import React from "react"; import { styles } from "./styles"; import { View, Text } from "@react-pdf/renderer"; -const TestReportFooter = () => ( +interface Props { + userId?: string; +} + +const TestReportFooter = ({ userId }: Props) => ( ( - Confidential – circulated for concern people + + Confidential –{" "} + + circulated for concern people + + + {userId && ( + + + User ID:{" "} + {userId} + + + )} Declaration diff --git a/src/exams/pdf/test.report.tsx b/src/exams/pdf/test.report.tsx index 9c409554..df1479d7 100644 --- a/src/exams/pdf/test.report.tsx +++ b/src/exams/pdf/test.report.tsx @@ -124,7 +124,7 @@ const TestReport = ({ - + @@ -165,7 +165,7 @@ const TestReport = ({ - + ); From 34b1c7f25b0cf722bf63802d53c5637d3d18e01f Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 20:07:40 +0000 Subject: [PATCH 6/9] Fixed footer paddings --- src/exams/pdf/test.report.footer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exams/pdf/test.report.footer.tsx b/src/exams/pdf/test.report.footer.tsx index e8c493e6..1f9f122e 100644 --- a/src/exams/pdf/test.report.footer.tsx +++ b/src/exams/pdf/test.report.footer.tsx @@ -38,14 +38,14 @@ const TestReportFooter = ({ userId }: Props) => ( {userId && ( - + User ID:{" "} {userId} )} - + Declaration We hereby declare that exam results on our platform, assessed by AI, are From a40c21ca53aeb6756a64c1a6add708062c35ce75 Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 20:08:10 +0000 Subject: [PATCH 7/9] Fixed table columns headers --- src/exams/pdf/group.test.report.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/exams/pdf/group.test.report.tsx b/src/exams/pdf/group.test.report.tsx index 633aa56f..81689cfb 100644 --- a/src/exams/pdf/group.test.report.tsx +++ b/src/exams/pdf/group.test.report.tsx @@ -237,10 +237,10 @@ const GroupTestReport = ({ Sr Candidate Name - Email ID - - Gender + + Passport ID + Email ID Date of test @@ -280,9 +280,8 @@ const GroupTestReport = ({ {index + 1} {name} - {email} {studentPassportId} - + {email} {date} From aef3800c08f05af247a053d738d823eaf0b1205d Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 20:08:44 +0000 Subject: [PATCH 8/9] Fixed issue with serialization on forgot password locally --- src/pages/action.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/action.tsx b/src/pages/action.tsx index 1a1046c7..ea1d9687 100644 --- a/src/pages/action.tsx +++ b/src/pages/action.tsx @@ -26,7 +26,7 @@ export function getServerSideProps({query, res}: {query: {oobCode: string; mode: code: query.oobCode, mode: query.mode, apiKey: query.apiKey, - continueUrl: query.continueUrl, + ...query.continueUrl ? { continueUrl: query.continueUrl } : {}, }, }; } From bca73dff2ef91e4cd360ca627bf2bb87f30790e7 Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sat, 27 Jan 2024 20:10:15 +0000 Subject: [PATCH 9/9] Fixed userid --- src/pages/api/stats/[id]/export.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/stats/[id]/export.tsx b/src/pages/api/stats/[id]/export.tsx index 824c74d9..2736bccf 100644 --- a/src/pages/api/stats/[id]/export.tsx +++ b/src/pages/api/stats/[id]/export.tsx @@ -278,7 +278,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) { .format("ll HH:mm:ss")} name={user.name} email={user.email} - id={user.id} + id={userId} gender={demographicInformation?.gender} summary={performanceSummary} testDetails={testDetails}