Updated the stats
This commit is contained in:
@@ -157,7 +157,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers,
|
||||
{
|
||||
icon: <BsPencil className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||
value: stats.length,
|
||||
label: "Exercises",
|
||||
label: "Modules",
|
||||
},
|
||||
{
|
||||
icon: <BsStar className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||
|
||||
@@ -13,7 +13,7 @@ import {CorporateUser, User} from "@/interfaces/user";
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import {getExamById} from "@/utils/exams";
|
||||
import {getUserCorporate} from "@/utils/groups";
|
||||
import {MODULE_ARRAY, sortByModule, sortByModuleName} from "@/utils/moduleUtils";
|
||||
import {countExamModules, countFullExams, MODULE_ARRAY, sortByModule, sortByModuleName} from "@/utils/moduleUtils";
|
||||
import {getLevelLabel, getLevelScore} from "@/utils/score";
|
||||
import {averageScore, groupBySession} from "@/utils/stats";
|
||||
import {CreateOrderActions, CreateOrderData, OnApproveActions, OnApproveData, OrderResponseBody} from "@paypal/paypal-js";
|
||||
@@ -84,16 +84,16 @@ export default function StudentDashboard({user}: Props) {
|
||||
user={user}
|
||||
items={[
|
||||
{
|
||||
icon: <BsFileEarmarkText className="text-mti-red-light h-6 w-6 md:h-8 md:w-8" />,
|
||||
value: Object.keys(groupBySession(stats)).length,
|
||||
icon: <BsFileEarmarkText className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||
value: countFullExams(stats),
|
||||
label: "Exams",
|
||||
tooltip: "Number of all conducted completed exams",
|
||||
},
|
||||
{
|
||||
icon: <BsPencil className="text-mti-red-light h-6 w-6 md:h-8 md:w-8" />,
|
||||
value: stats.length,
|
||||
label: "Exercises",
|
||||
tooltip: "Number of all conducted exercises including Level Test",
|
||||
icon: <BsPencil className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||
value: countExamModules(stats),
|
||||
label: "Modules",
|
||||
tooltip: "Number of all exam modules performed including Level Test",
|
||||
},
|
||||
{
|
||||
icon: <BsStar className="text-mti-red-light h-6 w-6 md:h-8 md:w-8" />,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {Module} from "@/interfaces";
|
||||
import ProgressBar from "@/components/Low/ProgressBar";
|
||||
import Layout from "@/components/High/Layout";
|
||||
import {calculateAverageLevel, calculateBandScore} from "@/utils/score";
|
||||
import {MODULE_ARRAY, sortByModule} from "@/utils/moduleUtils";
|
||||
import {countExamModules, countFullExams, MODULE_ARRAY, sortByModule} from "@/utils/moduleUtils";
|
||||
import {Chart} from "react-chartjs-2";
|
||||
import useUsers from "@/hooks/useUsers";
|
||||
import Select from "react-select";
|
||||
@@ -39,7 +39,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
redirect: {
|
||||
destination: "/login",
|
||||
permanent: false,
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
redirect: {
|
||||
destination: "/",
|
||||
permanent: false,
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -164,21 +164,21 @@ export default function Stats() {
|
||||
items={[
|
||||
{
|
||||
icon: <BsFileEarmarkText className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||
value: Object.keys(groupBySession(userStats)).length,
|
||||
value: countFullExams(userStats),
|
||||
label: "Exams",
|
||||
tooltip: 'Number of all conducted completed exams',
|
||||
tooltip: "Number of all conducted completed exams",
|
||||
},
|
||||
{
|
||||
icon: <BsPencil className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||
value: userStats.length,
|
||||
label: "Exercises",
|
||||
tooltip: 'Number of all conducted exercises including Level Test',
|
||||
value: countExamModules(userStats),
|
||||
label: "Modules",
|
||||
tooltip: "Number of all exam modules performed including Level Test",
|
||||
},
|
||||
{
|
||||
icon: <BsStar className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||
value: `${userStats.length > 0 ? averageScore(userStats) : 0}%`,
|
||||
label: "Average Score",
|
||||
tooltip: 'Average success rate for questions responded',
|
||||
tooltip: "Average success rate for questions responded",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import {Module} from "@/interfaces";
|
||||
import {Exercise} from "@/interfaces/exam";
|
||||
import {Stat} from "@/interfaces/user";
|
||||
import {uniq} from "lodash";
|
||||
import {groupBySession} from "./stats";
|
||||
|
||||
export const MODULE_ARRAY: Module[] = ["reading", "listening", "writing", "speaking", "level"];
|
||||
|
||||
@@ -29,3 +32,30 @@ export const countExercises = (exercises: Exercise[]) => {
|
||||
|
||||
return lengthMap.reduce((accumulator, current) => accumulator + current, 0);
|
||||
};
|
||||
|
||||
export const countFullExams = (stats: Stat[]) => {
|
||||
const sessionExams = groupBySession(stats);
|
||||
return Object.keys(sessionExams).filter((x) => {
|
||||
const sessionStats = sessionExams[x as keyof typeof sessionExams];
|
||||
const sessionModules = uniq(sessionStats.map((x) => x.module));
|
||||
|
||||
return (
|
||||
sessionModules.includes("reading") &&
|
||||
sessionModules.includes("listening") &&
|
||||
sessionModules.includes("writing") &&
|
||||
sessionModules.includes("speaking")
|
||||
);
|
||||
}).length;
|
||||
};
|
||||
|
||||
export const countExamModules = (stats: Stat[]) => {
|
||||
const sessionExams = groupBySession(stats);
|
||||
const modulesPerSession = Object.keys(sessionExams).map((x) => {
|
||||
const sessionStats = sessionExams[x as keyof typeof sessionExams];
|
||||
const sessionModules = uniq(sessionStats.map((x) => x.module));
|
||||
|
||||
return sessionModules.length;
|
||||
});
|
||||
|
||||
return modulesPerSession.reduce((acc, curr) => curr + acc, 0);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user