interface DataViewerProps { parsedData: Record; } export function DataViewer({ parsedData }: DataViewerProps) { const questions = parsedData.questions?.[0] as { structured_data: { questions: Array<{ number: number; text: string; type: string; options: string[] | null; points: number | null }> } } | undefined; const studentAnswers = parsedData.student_answers?.[0] as { structured_data: { students: Array<{ name: string; id: string; answers: Array<{ question_number: number; answer: string }> }> } } | undefined; const teacherAnswers = parsedData.teacher_answers?.[0] as { structured_data: { answers: Array<{ question_number: number; correct_answer: string; explanation: string | null }> } } | undefined; return (
{/* Questions */} {questions && (

📝 考試題目 ({questions.structured_data.questions?.length || 0} 題)

{questions.structured_data.questions?.map((q) => ( ))}
# 題目 類型 分數
{q.number}

{q.text}

{q.options && (
{q.options.join(" | ")}
)}
{q.type} {q.points ?? "-"}
)} {/* Student Answers */} {studentAnswers && (

👨‍🎓 學生答案 ({studentAnswers.structured_data.students?.length || 0} 位學生)

{questions?.structured_data.questions?.map((q) => ( ))} {studentAnswers.structured_data.students?.map((s) => ( {(questions?.structured_data.questions || s.answers)?.map((_, i) => { const ans = s.answers?.find((a) => a.question_number === i + 1); return ( ); })} ))}
學生Q{q.number}
{s.name || s.id} {ans?.answer ?? "-"}
)} {/* Teacher Answers */} {teacherAnswers && (

✅ 標準答案

{teacherAnswers.structured_data.answers?.map((a) => (
Q{a.question_number}

{a.correct_answer}

))}
)} {!questions && !studentAnswers && !teacherAnswers && (
尚未有解析資料
)}
); }