'use client'; import { useEffect, useState } from 'react'; import { useRouter, useSearchParams } from 'next/navigation'; import { CheckCircle, XCircle, Clock, Award, BarChart3, Home, FileText } from 'lucide-react'; import { cn } from '@/utils/cn'; interface ExamResult { examId: string; examTitle: string; totalQuestions: number; correctAnswers: number; score: number; timeSpent: string; completedAt: string; answers: Array<{ questionId: string; question: string; userAnswer: any; correctAnswer: any; isCorrect: boolean; type: string; }>; } export default function ExamSummaryPage() { const router = useRouter(); const searchParams = useSearchParams(); const [examResult, setExamResult] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { // Simulate loading exam results // In real app, this would fetch from API or localStorage const mockResult: ExamResult = { examId: 'exam-1', examTitle: 'Ujian Keamanan Pangan MBG', totalQuestions: 10, correctAnswers: 8, score: 80, timeSpent: '25 menit 30 detik', completedAt: new Date().toLocaleString('id-ID'), answers: [ { questionId: '1', question: 'Suhu ideal untuk menyimpan daging segar adalah...', userAnswer: 'Di bawah 4°C', correctAnswer: 'Di bawah 4°C', isCorrect: true, type: 'multiple_choice' }, { questionId: '2', question: 'Langkah pertama dalam sistem HACCP adalah...', userAnswer: 'Analisis bahaya', correctAnswer: 'Analisis bahaya', isCorrect: true, type: 'multiple_choice' }, // Add more mock answers as needed ] }; setTimeout(() => { setExamResult(mockResult); setLoading(false); }, 1000); }, []); const getScoreColor = (score: number) => { if (score >= 80) return 'text-green-600'; if (score >= 60) return 'text-yellow-600'; return 'text-red-600'; }; const getScoreBgColor = (score: number) => { if (score >= 80) return 'bg-green-100 border-green-200'; if (score >= 60) return 'bg-yellow-100 border-yellow-200'; return 'bg-red-100 border-red-200'; }; if (loading) { return (

Memproses hasil ujian...

); } if (!examResult) { return (

Hasil ujian tidak ditemukan

); } return (
{/* Header */}
{examResult.score >= 80 ? ( ) : examResult.score >= 60 ? ( ) : ( )}

{examResult.score >= 80 ? 'Selamat!' : examResult.score >= 60 ? 'Cukup Baik!' : 'Perlu Perbaikan'}

Anda telah menyelesaikan ujian

{/* Score Summary */}

{examResult.examTitle}

{examResult.score}%

Skor Akhir

{examResult.correctAnswers}/{examResult.totalQuestions}

Jawaban Benar

{examResult.timeSpent}

Waktu Pengerjaan

{examResult.completedAt}

Selesai Pada

{/* Detailed Results */}

Detail Jawaban

{examResult.answers.map((answer, index) => (
{answer.isCorrect ? ( ) : ( )}

Soal {index + 1}: {answer.question}

Jawaban Anda:

{typeof answer.userAnswer === 'string' ? answer.userAnswer : 'Tidak dijawab'}

{!answer.isCorrect && (

Jawaban Benar:

{typeof answer.correctAnswer === 'string' ? answer.correctAnswer : 'N/A'}

)}
))}
{/* Action Buttons */}
); }