diff --git a/package.json b/package.json index a4dd4ce..c522f37 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "@radix-ui/react-avatar": "^1.1.11", + "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-slot": "^1.2.4", "@radix-ui/react-tabs": "^1.1.13", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1bc068c..3e53552 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@radix-ui/react-avatar': specifier: ^1.1.11 version: 1.1.11(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-dialog': + specifier: ^1.1.15 + version: 1.1.15(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@radix-ui/react-dropdown-menu': specifier: ^2.1.16 version: 2.1.16(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) @@ -498,6 +501,19 @@ packages: '@types/react': optional: true + '@radix-ui/react-dialog@1.1.15': + resolution: {integrity: sha512-TCglVRtzlffRNxRMEyR36DGBLJpeusFcgMVD9PZEzAKnUs1lKCgX5u9BmC2Yg+LL9MgZDugFFs1Vl+Jp4t/PGw==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-direction@1.1.1': resolution: {integrity: sha512-1UEWRX6jnOA2y4H5WczZ44gOOjTEmlqv1uNW4GAJEO5+bauCBhv8snY65Iw5/VOS/ghKN9gr2KjnLKxrsvoMVw==} peerDependencies: @@ -2193,6 +2209,28 @@ snapshots: optionalDependencies: '@types/react': 19.2.7 + '@radix-ui/react-dialog@1.1.15(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': + dependencies: + '@radix-ui/primitive': 1.1.3 + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.7)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.7)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.11(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-focus-guards': 1.1.3(@types/react@19.2.7)(react@19.2.3) + '@radix-ui/react-focus-scope': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.7)(react@19.2.3) + '@radix-ui/react-portal': 1.1.9(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-presence': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.3(@types/react@19.2.7)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.2.2(@types/react@19.2.7)(react@19.2.3) + aria-hidden: 1.2.6 + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + react-remove-scroll: 2.7.2(@types/react@19.2.7)(react@19.2.3) + optionalDependencies: + '@types/react': 19.2.7 + '@types/react-dom': 19.2.3(@types/react@19.2.7) + '@radix-ui/react-direction@1.1.1(@types/react@19.2.7)(react@19.2.3)': dependencies: react: 19.2.3 diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx new file mode 100644 index 0000000..daf6bf4 --- /dev/null +++ b/src/components/ui/dialog.tsx @@ -0,0 +1,156 @@ +import * as React from "react" +import * as DialogPrimitive from "@radix-ui/react-dialog" +import { XIcon } from "lucide-react" + +import { cn } from "@/lib/utils" +import { Button } from "@/components/ui/button" + +function Dialog({ + ...props +}: React.ComponentProps) { + return +} + +function DialogTrigger({ + ...props +}: React.ComponentProps) { + return +} + +function DialogPortal({ + ...props +}: React.ComponentProps) { + return +} + +function DialogClose({ + ...props +}: React.ComponentProps) { + return +} + +function DialogOverlay({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DialogContent({ + className, + children, + showCloseButton = true, + ...props +}: React.ComponentProps & { + showCloseButton?: boolean +}) { + return ( + + + + {children} + {showCloseButton && ( + + + Close + + )} + + + ) +} + +function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function DialogFooter({ + className, + showCloseButton = false, + children, + ...props +}: React.ComponentProps<"div"> & { + showCloseButton?: boolean +}) { + return ( +
+ {children} + {showCloseButton && ( + + + + )} +
+ ) +} + +function DialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogOverlay, + DialogPortal, + DialogTitle, + DialogTrigger, +} diff --git a/src/pages/student/Home.tsx b/src/pages/student/Home.tsx index 234f454..0eb0454 100644 --- a/src/pages/student/Home.tsx +++ b/src/pages/student/Home.tsx @@ -83,7 +83,7 @@ export const Home = () => { }; return ( -
+

Welcome, {user?.name || "Student"}

@@ -91,7 +91,7 @@ export const Home = () => {
diff --git a/src/pages/student/practice/Test.tsx b/src/pages/student/practice/Test.tsx index cf78603..4edf354 100644 --- a/src/pages/student/practice/Test.tsx +++ b/src/pages/student/practice/Test.tsx @@ -3,17 +3,11 @@ import { useNavigate, useParams } from "react-router-dom"; import { Card, CardContent, - CardDescription, CardHeader, CardTitle, } from "../../../components/ui/card"; -import { - Clock, - Layers, - CircleQuestionMark, - Check, - Loader2, -} from "lucide-react"; +import { Check, Loader2 } from "lucide-react"; + import { api } from "../../../utils/api"; import { useAuthStore } from "../../../stores/authStore"; import type { PracticeSheet, Question } from "../../../types/sheet"; @@ -26,6 +20,23 @@ import type { } from "../../../types/session"; import { useAuthToken } from "../../../hooks/useAuthToken"; import { renderQuestionText } from "../../../components/RenderQuestionText"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "../../../components/ui/dropdown-menu"; +import { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "../../../components/ui/dialog"; export const Test = () => { const navigate = useNavigate(); @@ -34,7 +45,6 @@ export const Test = () => { const [practiceSheet, setPracticeSheet] = useState( null, ); - // const [answer, setAnswer] = useState(""); const [answers, setAnswers] = useState>({}); const [showNavigator, setShowNavigator] = useState(false); @@ -44,7 +54,6 @@ export const Test = () => { const time = useSatTimer(); const phase = useSatExam((s) => s.phase); - // const moduleIndex = useSatExam((s) => s.moduleIndex); const currentModule = useSatExam((s) => s.currentModuleQuestions); const questionIndex = useSatExam((s) => s.questionIndex); @@ -171,6 +180,11 @@ export const Test = () => { } }; + const handleQuitExam = () => { + finishExam(); + navigate("/student/home"); + }; + useEffect(() => { resetExam(); // ✅ important }, [sheetId]); @@ -191,9 +205,6 @@ export const Test = () => { if (!user) return; }, [sheetId]); - // const isLastQuestion = - // questionIndex === (currentModule?.questions.length ?? 0) - 1; - const isFirstQuestion = questionIndex === 0; const renderAnswerInput = (question?: Question) => { @@ -391,62 +402,118 @@ export const Test = () => { Back - {/* */} + + + + - + + + setShowNavigator(true)} + > + Go to + + - {showNavigator && ( -
-
-
-

- Jump to Question -

- -
+ Quit Test + + -
- {currentModule?.questions.map((q, idx) => { - const isCurrent = idx === questionIndex; - const isAnswered = !!answers[q.id]; + + + + Want to quit the test? + + + Your progress will be saved and you can resume later. + + - return ( - - ); - })} -
+ + +
+ + + + + + + + + + Go to Question + + + Select a question to navigate directly. +
+
+
+ Answered +
+
+
+ Current +
+
+
+ Skipped +
+
+
+
+ +
+ {currentModule?.questions.map((q, idx) => { + const isCurrent = idx === questionIndex; + const isAnswered = !!answers[q.id]; + + return ( + + ); + })}
-
- )} + +
); - case "FINISHED": return (