From d564d86feb961b33e435c94cace9b4cb8d1788e9 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Fri, 15 Nov 2024 16:02:43 +0000 Subject: [PATCH] Updated the Assignment View to ignore practice questions --- src/dashboards/AssignmentView.tsx | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/dashboards/AssignmentView.tsx b/src/dashboards/AssignmentView.tsx index 8b19aa0c..ee2506d9 100644 --- a/src/dashboards/AssignmentView.tsx +++ b/src/dashboards/AssignmentView.tsx @@ -2,23 +2,23 @@ import Button from "@/components/Low/Button"; import ProgressBar from "@/components/Low/ProgressBar"; import Modal from "@/components/Modal"; import useUsers from "@/hooks/useUsers"; -import {Module} from "@/interfaces"; -import {Assignment} from "@/interfaces/results"; -import {Stat, User} from "@/interfaces/user"; +import { Module } from "@/interfaces"; +import { Assignment } from "@/interfaces/results"; +import { Stat, User } from "@/interfaces/user"; import useExamStore from "@/stores/examStore"; -import {getExamById} from "@/utils/exams"; -import {sortByModule} from "@/utils/moduleUtils"; -import {calculateBandScore} from "@/utils/score"; -import {convertToUserSolutions} from "@/utils/stats"; -import {getUserName} from "@/utils/users"; +import { getExamById } from "@/utils/exams"; +import { sortByModule } from "@/utils/moduleUtils"; +import { calculateBandScore } from "@/utils/score"; +import { convertToUserSolutions } from "@/utils/stats"; +import { getUserName } from "@/utils/users"; import axios from "axios"; import clsx from "clsx"; -import {capitalize, uniqBy} from "lodash"; +import { capitalize, uniqBy } from "lodash"; import moment from "moment"; -import {useRouter} from "next/router"; -import {BsBook, BsClipboard, BsHeadphones, BsMegaphone, BsPen} from "react-icons/bs"; -import {toast} from "react-toastify"; -import {futureAssignmentFilter} from "@/utils/assignments"; +import { useRouter } from "next/router"; +import { BsBook, BsClipboard, BsHeadphones, BsMegaphone, BsPen } from "react-icons/bs"; +import { toast } from "react-toastify"; +import { futureAssignmentFilter } from "@/utils/assignments"; interface Props { isOpen: boolean; @@ -27,7 +27,7 @@ interface Props { onClose: () => void; } -export default function AssignmentView({isOpen, users, assignment, onClose}: Props) { +export default function AssignmentView({ isOpen, users, assignment, onClose }: Props) { const router = useRouter(); const setExams = useExamStore((state) => state.setExams); @@ -80,9 +80,9 @@ export default function AssignmentView({isOpen, users, assignment, onClose}: Pro return resultModuleBandScores.length === 0 ? -1 : resultModuleBandScores.reduce((acc, curr) => acc + curr, 0) / assignment.results.length; }; - const aggregateScoresByModule = (stats: Stat[]): {module: Module; total: number; missing: number; correct: number}[] => { + const aggregateScoresByModule = (stats: Stat[]): { module: Module; total: number; missing: number; correct: number }[] => { const scores: { - [key in Module]: {total: number; missing: number; correct: number}; + [key in Module]: { total: number; missing: number; correct: number }; } = { reading: { total: 0, @@ -111,7 +111,7 @@ export default function AssignmentView({isOpen, users, assignment, onClose}: Pro }, }; - stats.forEach((x) => { + stats.filter(x => !x.isPractice).forEach((x) => { scores[x.module!] = { total: scores[x.module!].total + x.score.total, correct: scores[x.module!].correct + x.score.correct, @@ -121,7 +121,7 @@ export default function AssignmentView({isOpen, users, assignment, onClose}: Pro return Object.keys(scores) .filter((x) => scores[x as Module].total > 0) - .map((x) => ({module: x as Module, ...scores[x as Module]})); + .map((x) => ({ module: x as Module, ...scores[x as Module] })); }; const customContent = (stats: Stat[], user: string, focus: "academic" | "general") => { @@ -180,7 +180,7 @@ export default function AssignmentView({isOpen, users, assignment, onClose}: Pro
- {aggregatedLevels.map(({module, level}) => ( + {aggregatedLevels.map(({ module, level }) => (
Average Scores
{assignment && - uniqBy(assignment.exams, (x) => x.module).map(({module}) => ( + uniqBy(assignment.exams, (x) => x.module).map(({ module }) => (