diff --git a/src/exams/pdf/group.test.report.tsx b/src/exams/pdf/group.test.report.tsx index 6d98cd8a..81689cfb 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} @@ -242,10 +237,10 @@ const GroupTestReport = ({ Sr Candidate Name - Email ID - - Gender + + Passport ID + Email ID Date of test @@ -255,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} + {studentPassportId} {email} - - {gender} - {date} diff --git a/src/exams/pdf/test.report.footer.tsx b/src/exams/pdf/test.report.footer.tsx index 3771fee7..1f9f122e 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 We hereby declare that exam results on our platform, assessed by AI, are 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 = ({ - + ); 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/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 } : {}, }, }; } diff --git a/src/pages/api/assignments/[id]/export.tsx b/src/pages/api/assignments/[id]/export.tsx index b57497f2..5d8a3397 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); @@ -239,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", @@ -248,6 +246,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) { result, level: showLevel ? getLevelScoreForUserExams(bandScore) : undefined, bandScore, + passportId: userDemographicInformation?.passport_id || "" }; }); }; diff --git a/src/pages/api/stats/[id]/export.tsx b/src/pages/api/stats/[id]/export.tsx index b3374c4c..2736bccf 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); @@ -269,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}