diff --git a/src/dashboards/MasterStatistical.tsx b/src/dashboards/MasterStatistical.tsx index 71537fb4..3a4a2e57 100644 --- a/src/dashboards/MasterStatistical.tsx +++ b/src/dashboards/MasterStatistical.tsx @@ -199,6 +199,28 @@ const MasterStatistical = (props: Props) => { }); const areAllSelected = selectedCorporates.length === corporates.length; + + const getStudentsConsolidateScore = () => { + if (tableResults.length === 0) { + return { highest: null, lowest: null }; + } + + // Find the student with the highest and lowest score + return tableResults.reduce( + (acc, curr) => { + if (curr.correct > acc.highest.correct) { + acc.highest = curr; + } + if (curr.correct < acc.lowest.correct) { + acc.lowest = curr; + } + return acc; + }, + { highest: tableResults[0], lowest: tableResults[0] } + ); + }; + + const consolidateResults = getStudentsConsolidateScore(); return ( <>