Updated part of the Selection screen to the new design
This commit is contained in:
@@ -2,6 +2,7 @@ import {Stat} from "@/interfaces/user";
|
||||
import {capitalize, groupBy} from "lodash";
|
||||
import {convertCamelCaseToReadable} from "@/utils/string";
|
||||
import {UserSolution} from "@/interfaces/exam";
|
||||
import {Module} from "@/interfaces";
|
||||
|
||||
export const totalExams = (stats: Stat[]): number => {
|
||||
const moduleStats = formatModuleTotalStats(stats);
|
||||
@@ -35,6 +36,22 @@ export const formatModuleTotalStats = (stats: Stat[]): {label: string; value: nu
|
||||
}));
|
||||
};
|
||||
|
||||
export const totalExamsByModule = (stats: Stat[], module: Module): number => {
|
||||
const moduleSessions: {[key: string]: string[]} = {};
|
||||
|
||||
stats.forEach((stat) => {
|
||||
if (stat.module in moduleSessions) {
|
||||
if (!moduleSessions[stat.module].includes(stat.session)) {
|
||||
moduleSessions[stat.module] = [...moduleSessions[stat.module], stat.session];
|
||||
}
|
||||
} else {
|
||||
moduleSessions[stat.module] = [stat.session];
|
||||
}
|
||||
});
|
||||
|
||||
return moduleSessions[module]?.length || 0;
|
||||
};
|
||||
|
||||
export const formatModuleAverageScoreStats = (stats: Stat[]): {label: string; value: number}[] => {
|
||||
const moduleScores: {[key: string]: {correct: number; total: number}} = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user