Added more control over the stats appearing in the stats page

This commit is contained in:
Tiago Ribeiro
2023-12-18 22:42:14 +00:00
parent c37bb2691b
commit 438778a03c
3 changed files with 225 additions and 128 deletions

View File

@@ -1,7 +1,7 @@
import {Module} from "@/interfaces";
import {Exercise} from "@/interfaces/exam";
export const MODULE_ARRAY: Module[] = ["reading", "listening", "writing", "speaking"];
export const MODULE_ARRAY: Module[] = ["reading", "listening", "writing", "speaking", "level"];
export const moduleLabels: {[key in Module]: string} = {
listening: "Listening",
@@ -11,7 +11,7 @@ export const moduleLabels: {[key in Module]: string} = {
level: "Level",
};
export const sortByModule = (a: {module: Module}, b: {module: Module}) => {
export const sortByModule = (a: {module: Module; [key: string]: any}, b: {module: Module; [key: string]: any}) => {
return MODULE_ARRAY.findIndex((x) => a.module === x) - MODULE_ARRAY.findIndex((x) => b.module === x);
};

View File

@@ -4,6 +4,11 @@ import {convertCamelCaseToReadable} from "@/utils/string";
import {UserSolution} from "@/interfaces/exam";
import {Module} from "@/interfaces";
import {MODULES} from "@/constants/ielts";
import moment from "moment";
export const timestampToMoment = (stat: Stat): moment.Moment => {
return moment.unix(stat.date > Math.pow(10, 11) ? stat.date / 1000 : stat.date);
};
export const totalExams = (stats: Stat[]): number => {
const moduleStats = formatModuleTotalStats(stats);