Updated the code to return to official-exam if they came from that page
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import Button from "@/components/Low/Button";
|
||||
import ModuleTitle from "@/components/Medium/ModuleTitle";
|
||||
import {moduleResultText} from "@/constants/ielts";
|
||||
import {Module} from "@/interfaces";
|
||||
import {User} from "@/interfaces/user";
|
||||
import { moduleResultText } from "@/constants/ielts";
|
||||
import { Module } from "@/interfaces";
|
||||
import { User } from "@/interfaces/user";
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import {calculateBandScore, getGradingLabel} from "@/utils/score";
|
||||
import { calculateBandScore, getGradingLabel } from "@/utils/score";
|
||||
import clsx from "clsx";
|
||||
import Link from "next/link";
|
||||
import {useRouter} from "next/router";
|
||||
import {Fragment, useEffect, useState} from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import { Fragment, useEffect, useState } from "react";
|
||||
import {
|
||||
BsArrowCounterclockwise,
|
||||
BsBan,
|
||||
@@ -21,14 +21,14 @@ import {
|
||||
BsPen,
|
||||
BsShareFill,
|
||||
} from "react-icons/bs";
|
||||
import {LevelScore} from "@/constants/ielts";
|
||||
import {getLevelScore} from "@/utils/score";
|
||||
import {capitalize} from "lodash";
|
||||
import { LevelScore } from "@/constants/ielts";
|
||||
import { getLevelScore } from "@/utils/score";
|
||||
import { capitalize } from "lodash";
|
||||
import Modal from "@/components/Modal";
|
||||
import {UserSolution} from "@/interfaces/exam";
|
||||
import { UserSolution } from "@/interfaces/exam";
|
||||
import ai_usage from "@/utils/ai.detection";
|
||||
import useGradingSystem from "@/hooks/useGrading";
|
||||
import {Assignment} from "@/interfaces/results";
|
||||
import { Assignment } from "@/interfaces/results";
|
||||
|
||||
interface Score {
|
||||
module: Module;
|
||||
@@ -49,20 +49,23 @@ interface Props {
|
||||
isLoading: boolean;
|
||||
assignment?: Assignment;
|
||||
onViewResults: (moduleIndex?: number) => void;
|
||||
destination?: string
|
||||
}
|
||||
|
||||
export default function Finish({user, scores, modules, information, solutions, isLoading, assignment, onViewResults}: Props) {
|
||||
export default function Finish({ user, scores, modules, information, solutions, isLoading, assignment, onViewResults, destination }: Props) {
|
||||
const [selectedModule, setSelectedModule] = useState(modules[0]);
|
||||
const [selectedScore, setSelectedScore] = useState<Score>(scores.find((x) => x.module === modules[0])!);
|
||||
const [isExtraInformationOpen, setIsExtraInformationOpen] = useState(false);
|
||||
|
||||
const aiUsage = Math.round(ai_usage(solutions) * 100);
|
||||
const exams = useExamStore((state) => state.exams);
|
||||
const {gradingSystem} = useGradingSystem();
|
||||
const { gradingSystem } = useGradingSystem();
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => setSelectedScore(scores.find((x) => x.module === selectedModule)!), [scores, selectedModule]);
|
||||
|
||||
const moduleColors: {[key in Module]: {progress: string; inner: string}} = {
|
||||
const moduleColors: { [key in Module]: { progress: string; inner: string } } = {
|
||||
reading: {
|
||||
progress: "text-ielts-reading",
|
||||
inner: "bg-ielts-reading-light",
|
||||
@@ -286,10 +289,8 @@ export default function Finish({user, scores, modules, information, solutions, i
|
||||
<div className="flex gap-8">
|
||||
<div className="flex w-fit cursor-pointer flex-col items-center gap-1">
|
||||
<button
|
||||
onClick={() => window.location.reload()}
|
||||
// disabled={user.type === "admin"}
|
||||
// TODO: temporarily disabled
|
||||
disabled
|
||||
onClick={() => router.push(destination || "/exam")}
|
||||
disabled={!!assignment}
|
||||
className="bg-mti-purple-light hover:bg-mti-purple flex h-11 w-11 items-center justify-center rounded-full transition duration-300 ease-in-out">
|
||||
<BsArrowCounterclockwise className="h-7 w-7 text-white" />
|
||||
</button>
|
||||
@@ -325,7 +326,7 @@ export default function Finish({user, scores, modules, information, solutions, i
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Link href="/" className="w-full max-w-[200px] self-end">
|
||||
<Link href={destination || "/"} className="w-full max-w-[200px] self-end">
|
||||
<Button color="purple" className="w-full max-w-[200px] self-end">
|
||||
Dashboard
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user