Revamped the whole Solutions stuff with Zustand

This commit is contained in:
Tiago Ribeiro
2023-05-17 17:33:53 +01:00
parent 44ad687bcf
commit f337540629
4 changed files with 83 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
import {Stat} from "@/interfaces/user";
import {capitalize, groupBy} from "lodash";
import {convertCamelCaseToReadable} from "@/utils/string";
import {UserSolution} from "@/interfaces/exam";
export const totalExams = (stats: Stat[]): number => {
const moduleStats = formatModuleTotalStats(stats);
@@ -98,3 +99,14 @@ export const getExamsBySession = (stats: Stat[], session: string) => {
export const groupBySession = (stats: Stat[]) => groupBy(stats, "session");
export const groupByDate = (stats: Stat[]) => groupBy(stats, "date");
export const convertToUserSolutions = (stats: Stat[]): UserSolution[] => {
return stats.map((stat) => ({
exercise: stat.exercise,
exam: stat.exam,
score: stat.score,
solutions: stat.solutions,
type: stat.type,
module: stat.module,
}));
};