Vector Motion
Education

Quiz Result Card - Assessment Analytics

Monitor quiz results and student performance metrics. Track assessment scores and learning outcome analysis.

Quiz Result Card

The Quiz Result Card displays the most recent quiz results with score, percentage, and performance feedback.

Preview

Installation

npx shadcn@latest add https://vectormotion.vercel.app/registry/quiz-result-card.json
Quiz Result Card
'use client'import React from 'react';import { FileQuestion, Trophy, TrendingUp } from 'lucide-react';import { motion } from 'motion/react';import { clsx, type ClassValue } from "clsx";import { twMerge } from "tailwind-merge";import { ResponsiveContainer, RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Radar, Tooltip } from 'recharts';function cn(...inputs: ClassValue[]) {  return twMerge(clsx(inputs));}interface QuizData {  subject: string;  A: number;  fullMark: number;  [key: string]: any;}interface QuizResultCardProps {  className?: string;  title?: string;  subtitle?: string;  data?: QuizData[];  topScore?: string;  topSubject?: string;  avgScore?: string;  avgLabel?: string;}const DEFAULT_DATA: QuizData[] = [  { subject: 'Math', A: 95, fullMark: 100 },  { subject: 'Phys', A: 88, fullMark: 100 },  { subject: 'Bio', A: 76, fullMark: 100 },  { subject: 'Hist', A: 82, fullMark: 100 },  { subject: 'Eng', A: 90, fullMark: 100 },];const DEFAULT_TITLE = "Quiz Results";const DEFAULT_SUBTITLE = "Performance Radar";const DEFAULT_TOP_SCORE = "95%";const DEFAULT_TOP_SUBJECT = "Mathematics";const DEFAULT_AVG_SCORE = "86.2%";const DEFAULT_AVG_LABEL = "All Subjects";export const QuizResultCard: React.FC<QuizResultCardProps> = ({  className = "",  title = DEFAULT_TITLE,  subtitle = DEFAULT_SUBTITLE,  data = DEFAULT_DATA,  topScore = DEFAULT_TOP_SCORE,  topSubject = DEFAULT_TOP_SUBJECT,  avgScore = DEFAULT_AVG_SCORE,  avgLabel = DEFAULT_AVG_LABEL,}) => {  return (    <motion.div      initial={{ opacity: 0, y: 20 }}      animate={{ opacity: 1, y: 0 }}      transition={{ duration: 0.5, delay: 0.3 }}      className={cn(        "relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-all hover:border-teal-300 dark:hover:border-teal-700 hover:shadow-md flex flex-col h-full",        className      )}    >      <div className="p-5 flex flex-col h-full relative z-10">        <div className="mb-4 flex items-start justify-between">          <div>            <h3 className="font-bold text-lg text-foreground">              {title}            </h3>            <p className="text-sm text-muted-foreground font-medium">              {subtitle}            </p>          </div>          <div className="rounded-lg border-2 border-teal-100 dark:border-teal-800 p-2 text-teal-500 dark:text-teal-400 flex items-center justify-center">            <FileQuestion className="h-5 w-5" />          </div>        </div>        <div className="flex items-center gap-2 flex-1 min-h-[160px]">          {/* Left Side: Radar Chart */}          <div className="flex-1 h-[180px] -ml-4 relative">            <ResponsiveContainer width="100%" height="100%">              <RadarChart cx="50%" cy="50%" outerRadius="70%" data={data}>                <PolarGrid stroke="#e4e4e7" strokeOpacity={0.5} />                <PolarAngleAxis                  dataKey="subject"                  tick={{ fontSize: 9, fill: '#71717a', fontWeight: 600 }}                />                <PolarRadiusAxis angle={30} domain={[0, 100]} tick={false} axisLine={false} />                <Radar                  name="Student"                  dataKey="A"                  stroke="#14b8a6"                  strokeWidth={2}                  fill="#14b8a6"                  fillOpacity={0.3}                />                <Tooltip                  cursor={false}                  content={({ active, payload }) => {                    if (active && payload && payload.length) {                      return (                        <div className="rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800 p-2 shadow-sm text-xs">                          <span className="font-bold text-teal-500">                            {payload[0].payload.subject}:                          </span> {payload[0].value}%                        </div>                      );                    }                    return null;                  }}                />              </RadarChart>            </ResponsiveContainer>          </div>          {/* Right Side: Key Stats */}          <div className="w-1/3 flex flex-col gap-3 z-10">            <div className="p-2 rounded-lg bg-teal-500/10 border border-teal-100 dark:border-teal-800/50">              <div className="flex items-center gap-1.5 text-teal-500 mb-0.5">                <Trophy className="w-3 h-3" />                <span className="text-[10px] uppercase font-bold tracking-wide">Top</span>              </div>              <div className="text-xl font-bold text-foreground">{topScore}</div>              <div className="text-[10px] text-muted-foreground">{topSubject}</div>            </div>            <div className="p-2 rounded-lg bg-muted border border-zinc-100 dark:border-zinc-700">              <div className="flex items-center gap-1.5 text-muted-foreground mb-0.5">                <TrendingUp className="w-3 h-3" />                <span className="text-[10px] uppercase font-bold tracking-wide">Avg</span>              </div>              <div className="text-xl font-bold text-foreground">{avgScore}</div>              <div className="text-[10px] text-muted-foreground">{avgLabel}</div>            </div>          </div>        </div>        <div className="absolute -bottom-4 -right-4 z-0 opacity-5 pointer-events-none">          <FileQuestion className="w-40 h-40 text-teal-500" />        </div>      </div>    </motion.div>  );};

Usage

This component provides students with immediate feedback on quiz performance, displaying scores and encouraging messages.

Prop

Type