Only shows results for an assignments that has been released

This commit is contained in:
Tiago Ribeiro
2024-08-28 12:27:26 +01:00
parent e518323d99
commit 5d10e6564d
4 changed files with 31 additions and 16 deletions

View File

@@ -5,16 +5,16 @@ import {Stat, User} from "@/interfaces/user";
import {Module} from "@/interfaces";
import ai_usage from "@/utils/ai.detection";
import {calculateBandScore} from "@/utils/score";
import moment from 'moment';
import { Assignment } from '@/interfaces/results';
import moment from "moment";
import {Assignment} from "@/interfaces/results";
import {uuidv4} from "@firebase/util";
import {useRouter} from "next/router";
import {uniqBy} from "lodash";
import {sortByModule} from "@/utils/moduleUtils";
import {convertToUserSolutions} from "@/utils/stats";
import {getExamById} from "@/utils/exams";
import { Exam, UserSolution } from '@/interfaces/exam';
import ModuleBadge from '../ModuleBadge';
import {Exam, UserSolution} from "@/interfaces/exam";
import ModuleBadge from "../ModuleBadge";
const formatTimestamp = (timestamp: string | number) => {
const time = typeof timestamp === "string" ? parseInt(timestamp) : timestamp;
@@ -262,7 +262,7 @@ const StatsGridItem: React.FC<StatsGridItemProps> = ({
key={uuidv4()}
className={clsx(
"flex flex-col justify-between gap-4 border border-mti-gray-platinum p-4 cursor-pointer rounded-xl transition ease-in-out duration-300 -md:hidden",
isDisabled && "grayscale tooltip",
(isDisabled || (!!assignment && !assignment.released)) && "grayscale tooltip",
correct / total >= 0.7 && "hover:border-mti-purple",
correct / total >= 0.3 && correct / total < 0.7 && "hover:border-mti-red",
correct / total < 0.3 && "hover:border-mti-rose",
@@ -276,7 +276,7 @@ const StatsGridItem: React.FC<StatsGridItemProps> = ({
...(width !== undefined && {width}),
...(height !== undefined && {height}),
}}
data-tip="This exam is still being evaluated..."
data-tip={isDisabled ? "This exam is still being evaluated..." : "This exam is still locked by its assigner..."}
role="button">
{content}
</div>

View File

@@ -11,6 +11,7 @@ import {useRouter} from "next/router";
import {Fragment, useEffect, useState} from "react";
import {
BsArrowCounterclockwise,
BsBan,
BsBook,
BsClipboard,
BsClipboardFill,
@@ -27,6 +28,7 @@ import Modal from "@/components/Modal";
import {UserSolution} from "@/interfaces/exam";
import ai_usage from "@/utils/ai.detection";
import useGradingSystem from "@/hooks/useGrading";
import {Assignment} from "@/interfaces/results";
interface Score {
module: Module;
@@ -45,10 +47,11 @@ interface Props {
};
solutions: UserSolution[];
isLoading: boolean;
assignment?: Assignment;
onViewResults: (moduleIndex?: number) => void;
}
export default function Finish({user, scores, modules, information, solutions, isLoading, onViewResults}: Props) {
export default function Finish({user, scores, modules, information, solutions, isLoading, assignment, onViewResults}: Props) {
const [selectedModule, setSelectedModule] = useState(modules[0]);
const [selectedScore, setSelectedScore] = useState<Score>(scores.find((x) => x.module === modules[0])!);
const [isExtraInformationOpen, setIsExtraInformationOpen] = useState(false);
@@ -209,7 +212,18 @@ export default function Finish({user, scores, modules, information, solutions, i
</span>
</div>
)}
{!isLoading && (
{assignment && !assignment.released && (
<div className="absolute left-1/2 top-1/2 flex h-fit w-fit -translate-x-1/2 -translate-y-1/2 flex-col items-center gap-12">
{/* <span className={clsx("loading loading-infinity w-32", moduleColors[selectedModule].progress)} /> */}
<BsBan size={64} className={clsx(moduleColors[selectedModule].progress)} />
<span className={clsx("text-center text-2xl font-bold", moduleColors[selectedModule].progress)}>
This exam has not yet been released by its assigner.
<br />
You can check it later on your records page when it is released!
</span>
</div>
)}
{!isLoading && false && (
<div className="mb-20 mt-32 flex w-full items-center justify-between gap-9">
<span className="max-w-3xl">{moduleResultText(selectedModule, bandScore)}</span>
<div className="flex gap-9 px-16">

View File

@@ -459,6 +459,7 @@ export default function ExamPage({page}: Props) {
user={user!}
modules={selectedModules}
solutions={userSolutions}
assignment={assignment}
information={{
timeSpent,
inactivity: totalInactivity,