"use client"; /** * Your finished attempt: the score, then every question with your answer, * the correct one, its explanation, and how long you took. * * Correct options are filled solid so they read at a glance; a wrong pick is * outlined in red. "Your answer" marks whatever you chose either way. */ import Link from "next/link"; import { Check, Clock, X } from "lucide-react"; import { RichText } from "@/lib/rich-text"; import type { QuizResult } from "@/lib/quiz"; import { cn } from "@/lib/utils"; export function fmtMs(ms?: number | null): string { if (ms == null) return "—"; if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`; return `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1000)}s`; } export function QuizResultView({ result }: { result: QuizResult }) { const pct = result.total ? Math.round((result.score / result.total) * 100) : 0; return (

Your result

{result.score} /{result.total}

{pct}% correct · {fmtMs(result.total_ms)} in total

{result.quiz.target_path && ( Back to {result.quiz.target_title || "the reading"} )}
    {result.items.map((it, i) => (
  1. {i + 1}.

    {it.is_correct ? ( ) : ( )} {it.is_correct ? "Correct" : "Incorrect"}
    {it.multi && (

    Select all that apply

    )}
      {it.options.map((o) => { const chosen = it.chosen_option_ids.includes(o.id); return (
    • {o.is_correct ? ( ) : chosen ? ( ) : ( )} {chosen && ( Your answer )}
    • ); })}
    {it.explanation && (

    )}

    {fmtMs(it.response_ms)}

  2. ))}
); }