Solved merge conflicts

This commit is contained in:
Tiago Ribeiro
2024-11-26 15:33:12 +00:00
12 changed files with 2659 additions and 23241 deletions

View File

@@ -1,9 +1,9 @@
import {Stat} from "@/interfaces/user";
import {capitalize, groupBy} from "lodash";
import {convertCamelCaseToReadable} from "@/utils/string";
import {UserSolution} from "@/interfaces/exam";
import {Module} from "@/interfaces";
import {MODULES} from "@/constants/ielts";
import { Stat } from "@/interfaces/user";
import { capitalize, groupBy } from "lodash";
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 => {
@@ -16,15 +16,15 @@ export const totalExams = (stats: Stat[]): number => {
};
export const averageScore = (stats: Stat[]): number => {
const {correct, total} = stats.reduce(
(acc, current) => ({correct: acc.correct + current.score.correct, total: acc.total + current.score.total}),
{correct: 0, total: 0},
const { correct, total } = stats.reduce(
(acc, current) => ({ correct: acc.correct + current.score.correct, total: acc.total + current.score.total }),
{ correct: 0, total: 0 },
);
return parseFloat(((correct / total) * 100).toFixed(2));
};
export const formatModuleTotalStats = (stats: Stat[]): {label: string; value: number}[] => {
const moduleSessions: {[key: string]: string[]} = {};
export const formatModuleTotalStats = (stats: Stat[]): { label: string; value: number }[] => {
const moduleSessions: { [key: string]: string[] } = {};
stats.forEach((stat) => {
if (stat.module in moduleSessions) {
@@ -43,7 +43,7 @@ export const formatModuleTotalStats = (stats: Stat[]): {label: string; value: nu
};
export const totalExamsByModule = (stats: Stat[], module: Module): number => {
const moduleSessions: {[key: string]: string[]} = {};
const moduleSessions: { [key: string]: string[] } = {};
stats.forEach((stat) => {
if (stat.module in moduleSessions) {
@@ -58,8 +58,8 @@ export const totalExamsByModule = (stats: Stat[], module: Module): number => {
return moduleSessions[module]?.length || 0;
};
export const calculateModuleAverageScoreStats = (stats: Stat[]): {module: Module; value: number}[] => {
const moduleScores: {[key: string]: {correct: number; total: number}} = {};
export const calculateModuleAverageScoreStats = (stats: Stat[]): { module: Module; value: number }[] => {
const moduleScores: { [key: string]: { correct: number; total: number } } = {};
stats.forEach((stat) => {
if (stat.module in moduleScores) {
@@ -82,11 +82,11 @@ export const calculateModuleAverageScoreStats = (stats: Stat[]): {module: Module
});
};
export const formatModuleAverageScoreStats = (stats: Stat[]): {label: string; value: number}[] => {
return calculateModuleAverageScoreStats(stats).map((x) => ({label: capitalize(x.module), value: x.value}));
export const formatModuleAverageScoreStats = (stats: Stat[]): { label: string; value: number }[] => {
return calculateModuleAverageScoreStats(stats).map((x) => ({ label: capitalize(x.module), value: x.value }));
};
export const formatExerciseTotalStats = (stats: Stat[]): {label: string; value: number}[] => {
export const formatExerciseTotalStats = (stats: Stat[]): { label: string; value: number }[] => {
const totalExercises = stats.map((stat) => ({
label: convertCamelCaseToReadable(stat.type),
value: stats.filter((x) => x.type === stat.type).length,
@@ -95,8 +95,8 @@ export const formatExerciseTotalStats = (stats: Stat[]): {label: string; value:
return totalExercises.filter((ex, index) => totalExercises.findIndex((x) => x.label === ex.label) === index);
};
export const formatExerciseAverageScoreStats = (stats: Stat[]): {label: string; value: number}[] => {
const typeScores: {[key: string]: {correct: number; total: number}} = {};
export const formatExerciseAverageScoreStats = (stats: Stat[]): { label: string; value: number }[] => {
const typeScores: { [key: string]: { correct: number; total: number } } = {};
stats.forEach((stat) => {
if (stat.type in typeScores) {
@@ -110,7 +110,7 @@ export const formatExerciseAverageScoreStats = (stats: Stat[]): {label: string;
});
return Object.keys(typeScores).map((x) => {
const {correct, total} = typeScores[x as keyof typeof typeScores];
const { correct, total } = typeScores[x as keyof typeof typeScores];
return {
label: convertCamelCaseToReadable(x),
@@ -138,6 +138,7 @@ export const convertToUserSolutions = (stats: Stat[]): UserSolution[] => {
solutions: stat.solutions,
type: stat.type,
module: stat.module,
shuffleMaps: stat.shuffleMaps
shuffleMaps: stat.shuffleMaps,
isPractice: stat.isPractice
}));
};

View File

@@ -1,13 +0,0 @@
/// <reference types="@welldone-software/why-did-you-render" />
import React from "react";
if (process.env.NODE_ENV === "development") {
const whyDidYouRender = require("@welldone-software/why-did-you-render");
whyDidYouRender(React, {
trackAllPureComponents: true,
trackHooks: true,
logOwnerReasons: true,
collapseGroups: true,
});
}