From 85c8f622ee623ce5543bcc7cfb3a48ea6b267196 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 9 Sep 2024 14:43:05 +0100 Subject: [PATCH] Added Student ID to the Master Statistical --- src/dashboards/MasterCorporate/MasterStatistical.tsx | 11 +++++++++-- src/pages/api/assignments/statistical/excel.ts | 9 +++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/dashboards/MasterCorporate/MasterStatistical.tsx b/src/dashboards/MasterCorporate/MasterStatistical.tsx index bf7b0579..ec205d6a 100644 --- a/src/dashboards/MasterCorporate/MasterStatistical.tsx +++ b/src/dashboards/MasterCorporate/MasterStatistical.tsx @@ -1,5 +1,5 @@ import React, {useEffect, useMemo, useState} from "react"; -import {CorporateUser, User} from "@/interfaces/user"; +import {CorporateUser, StudentUser, User} from "@/interfaces/user"; import {BsFileExcel, BsBank, BsPersonFill} from "react-icons/bs"; import IconCard from "../IconCard"; @@ -163,6 +163,13 @@ const MasterStatistical = (props: Props) => { return {info.getValue()}; }, }), + columnHelper.accessor("user", { + header: "Student ID", + id: "studentID", + cell: (info) => { + return {(info.getValue() as StudentUser).studentID || "N/A"}; + }, + }), ...(displaySelection ? [ columnHelper.accessor("corporate", { @@ -347,7 +354,7 @@ const MasterStatistical = (props: Props) => { {renderSearch()}
-
diff --git a/src/pages/api/assignments/statistical/excel.ts b/src/pages/api/assignments/statistical/excel.ts index 43345e88..da5befe0 100644 --- a/src/pages/api/assignments/statistical/excel.ts +++ b/src/pages/api/assignments/statistical/excel.ts @@ -11,7 +11,7 @@ import {checkAccess} from "@/utils/permissions"; import {getAssignmentsForCorporates} from "@/utils/assignments.be"; import {search} from "@/utils/search"; import {getGradingSystem} from "@/utils/grading.be"; -import {User} from "@/interfaces/user"; +import {StudentUser, User} from "@/interfaces/user"; import {calculateBandScore, getGradingLabel} from "@/utils/score"; import {Module} from "@/interfaces"; @@ -19,6 +19,7 @@ export default withIronSessionApiRoute(handler, sessionOptions); interface TableData { user: string; + studentID: string; email: string; correct: number; corporate: string; @@ -109,10 +110,10 @@ async function post(req: NextApiRequest, res: NextApiResponse) { const total = userStats.reduce((n, e) => n + e.score.total, 0); const {label: level, score} = getGradingSystemHelper(a.exams, a.assigner, userData!, correct, total); - console.log("Level", level); const commonData = { user: userData?.name || "", email: userData?.email || "", + studentID: (userData as StudentUser).studentID || "", userId: assignee, corporateId: a.corporateId, corporate: corporateUser?.name || "", @@ -164,6 +165,10 @@ async function post(req: NextApiRequest, res: NextApiResponse) { label: "Email", value: (entry: TableData) => entry.email, }, + { + label: "Student ID", + value: (entry: TableData) => entry.studentID, + }, ...(displaySelection ? [ {