Update AI coach calibration, fix streak animation speed, add dashboard features and target filtering
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState, use, useRef } from "react"
|
||||
import { useActiveUser } from "@/hooks/useActiveUser"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { Clock, Flag, ChevronLeft, ChevronRight, Pause as PauseIcon, MoreVertical, Calculator as CalculatorIcon, FlaskConical, Edit3, XCircle, Play, Shield, AlertTriangle, Moon, Sun } from "lucide-react"
|
||||
@@ -32,6 +33,9 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri
|
||||
const examId = resolvedParams.examId;
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const [examType, setExamType] = useState<string>('Test');
|
||||
const [testName, setTestName] = useState<string>('AITS Full Syllabus Test');
|
||||
const { user } = useActiveUser();
|
||||
const userId = user?.id || 'b0e17378-864d-439e-8806-708dc48a891b';
|
||||
const [showCalc, setShowCalc] = useState(false);
|
||||
const [showScratchpad, setShowScratchpad] = useState(false);
|
||||
const [showPeriodicTable, setShowPeriodicTable] = useState(false);
|
||||
@@ -95,7 +99,7 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri
|
||||
async function fetchExamData() {
|
||||
try {
|
||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000';
|
||||
const testRes = await fetch(`${apiUrl}/api/tests/${examId}?user_id=b0e17378-864d-439e-8806-708dc48a891b`);
|
||||
const testRes = await fetch(`${apiUrl}/api/tests/${examId}?user_id=${userId}`);
|
||||
if (!testRes.ok) throw new Error("Failed to fetch test structure");
|
||||
const testData = await testRes.json();
|
||||
|
||||
@@ -113,6 +117,7 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri
|
||||
}
|
||||
|
||||
setExamType(testData.type);
|
||||
if (testData.title) setTestName(testData.title);
|
||||
|
||||
// Extract all question IDs from sections
|
||||
const questionIds: string[] = [];
|
||||
@@ -155,7 +160,7 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri
|
||||
}
|
||||
}
|
||||
fetchExamData();
|
||||
}, [examId, initExam]);
|
||||
}, [examId, initExam, userId]);
|
||||
|
||||
// Track time spent per question
|
||||
useEffect(() => {
|
||||
@@ -186,7 +191,7 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri
|
||||
} else if (violationCount >= 2 && status !== 'SUBMITTED' && status !== 'TIMED_OUT' && !hasAutoSubmitted.current) {
|
||||
hasAutoSubmitted.current = true;
|
||||
submitExam('SUBMITTED');
|
||||
submitAttemptToServer('b0e17378-864d-439e-8806-708dc48a891b')
|
||||
submitAttemptToServer(userId)
|
||||
.then(() => {
|
||||
window.alert("Test Auto-Submitted due to multiple tab switching violations.");
|
||||
})
|
||||
@@ -242,9 +247,9 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri
|
||||
const confirmSubmit = async () => {
|
||||
setShowSubmitConfirm(false);
|
||||
submitExam('SUBMITTED');
|
||||
const payload = getAttemptPayload('b0e17378-864d-439e-8806-708dc48a891b');
|
||||
const payload = getAttemptPayload(userId);
|
||||
console.log("EXAM SUBMITTED. PAYLOAD:", JSON.stringify(payload, null, 2));
|
||||
await submitAttemptToServer('b0e17378-864d-439e-8806-708dc48a891b');
|
||||
await submitAttemptToServer(userId);
|
||||
}
|
||||
|
||||
if (!mounted || questions.length === 0) {
|
||||
@@ -309,7 +314,7 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri
|
||||
}
|
||||
|
||||
if (status === 'SUBMITTED' || status === 'TIMED_OUT') {
|
||||
const payload = getAttemptPayload('b0e17378-864d-439e-8806-708dc48a891b');
|
||||
const payload = getAttemptPayload(userId);
|
||||
if (!payload) return <div className="p-8 text-center mt-20">Loading results...</div>;
|
||||
|
||||
return (
|
||||
@@ -415,7 +420,7 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri
|
||||
</div>
|
||||
<div className="h-6 w-px bg-border hidden md:block"></div>
|
||||
<div className="hidden md:block">
|
||||
<h1 className="font-semibold text-sm">AITS Full Syllabus Test</h1>
|
||||
<h1 className="font-semibold text-sm">{testName}</h1>
|
||||
<p className="text-xs text-muted-foreground font-medium mt-0.5">{currentQuestion.subject}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user