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" />,
|
icon: <BsPencil className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||||
value: stats.length,
|
value: stats.length,
|
||||||
label: "Exercises",
|
label: "Modules",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: <BsStar className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
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 useExamStore from "@/stores/examStore";
|
||||||
import {getExamById} from "@/utils/exams";
|
import {getExamById} from "@/utils/exams";
|
||||||
import {getUserCorporate} from "@/utils/groups";
|
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 {getLevelLabel, getLevelScore} from "@/utils/score";
|
||||||
import {averageScore, groupBySession} from "@/utils/stats";
|
import {averageScore, groupBySession} from "@/utils/stats";
|
||||||
import {CreateOrderActions, CreateOrderData, OnApproveActions, OnApproveData, OrderResponseBody} from "@paypal/paypal-js";
|
import {CreateOrderActions, CreateOrderData, OnApproveActions, OnApproveData, OrderResponseBody} from "@paypal/paypal-js";
|
||||||
@@ -84,16 +84,16 @@ export default function StudentDashboard({user}: Props) {
|
|||||||
user={user}
|
user={user}
|
||||||
items={[
|
items={[
|
||||||
{
|
{
|
||||||
icon: <BsFileEarmarkText className="text-mti-red-light h-6 w-6 md:h-8 md:w-8" />,
|
icon: <BsFileEarmarkText className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||||
value: Object.keys(groupBySession(stats)).length,
|
value: countFullExams(stats),
|
||||||
label: "Exams",
|
label: "Exams",
|
||||||
tooltip: "Number of all conducted completed 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" />,
|
icon: <BsPencil className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||||
value: stats.length,
|
value: countExamModules(stats),
|
||||||
label: "Exercises",
|
label: "Modules",
|
||||||
tooltip: "Number of all conducted exercises including Level Test",
|
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" />,
|
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 ProgressBar from "@/components/Low/ProgressBar";
|
||||||
import Layout from "@/components/High/Layout";
|
import Layout from "@/components/High/Layout";
|
||||||
import {calculateAverageLevel, calculateBandScore} from "@/utils/score";
|
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 {Chart} from "react-chartjs-2";
|
||||||
import useUsers from "@/hooks/useUsers";
|
import useUsers from "@/hooks/useUsers";
|
||||||
import Select from "react-select";
|
import Select from "react-select";
|
||||||
@@ -39,7 +39,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
|||||||
redirect: {
|
redirect: {
|
||||||
destination: "/login",
|
destination: "/login",
|
||||||
permanent: false,
|
permanent: false,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
|||||||
redirect: {
|
redirect: {
|
||||||
destination: "/",
|
destination: "/",
|
||||||
permanent: false,
|
permanent: false,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,21 +164,21 @@ export default function Stats() {
|
|||||||
items={[
|
items={[
|
||||||
{
|
{
|
||||||
icon: <BsFileEarmarkText className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
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",
|
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" />,
|
icon: <BsPencil className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||||
value: userStats.length,
|
value: countExamModules(userStats),
|
||||||
label: "Exercises",
|
label: "Modules",
|
||||||
tooltip: 'Number of all conducted exercises including Level Test',
|
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" />,
|
icon: <BsStar className="w-6 h-6 md:w-8 md:h-8 text-mti-red-light" />,
|
||||||
value: `${userStats.length > 0 ? averageScore(userStats) : 0}%`,
|
value: `${userStats.length > 0 ? averageScore(userStats) : 0}%`,
|
||||||
label: "Average Score",
|
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 {Module} from "@/interfaces";
|
||||||
import {Exercise} from "@/interfaces/exam";
|
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"];
|
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);
|
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