feat(error-book): update components, actions, data-access, and add analytics

- Add data-access-analytics for error book analytics queries

- Update actions, data-access for improved error book operations

- Update components: add-error-book-dialog, analytics-stats-cards, chapter-weakness-chart, class-error-bar-chart, class-filter, error-book-detail-dialog, error-book-filters, error-book-item-card, error-book-list, error-book-stats-cards, grouped-student-error-table, knowledge-point-weakness-chart, review-buttons, subject-distribution-chart, subject-tabs, top-wrong-questions

- Remove class-error-overview (replaced by new components)
This commit is contained in:
SpecialX
2026-07-03 10:30:41 +08:00
parent 56c3f32e2d
commit 2dd8c2197c
20 changed files with 1090 additions and 1228 deletions

View File

@@ -1,4 +1,7 @@
"use client"
import { BookOpen, Brain, CheckCircle2, Clock, TrendingUp } from "lucide-react"
import { useTranslations } from "next-intl"
import { Card, CardContent } from "@/shared/components/ui/card"
import { cn } from "@/shared/lib/utils"
@@ -26,43 +29,52 @@ export function AnalyticsStatsCards({
knowledgePointCount,
className,
}: AnalyticsStatsCardsProps) {
const t = useTranslations("error-book")
const avg = (totalStudents > 0 ? totalErrorItems / totalStudents : 0).toFixed(1)
const cards = [
{
label: "覆盖学生",
label: t("analyticsStats.coverage"),
value: studentsWithErrorBook,
sub: `/ ${totalStudents}`,
sub: t("analyticsStats.coverageSub", { total: totalStudents }),
icon: BookOpen,
color: "text-blue-600 dark:text-blue-400",
bg: "bg-blue-50 dark:bg-blue-950/30",
},
{
label: "错题总数",
label: t("analyticsStats.totalErrors"),
value: totalErrorItems,
sub: `人均 ${(totalStudents > 0 ? totalErrorItems / totalStudents : 0).toFixed(1)}`,
sub: t("analyticsStats.totalErrorsSub", { avg }),
icon: TrendingUp,
color: "text-rose-600 dark:text-rose-400",
bg: "bg-rose-50 dark:bg-rose-950/30",
},
{
label: "平均掌握率",
label: t("analyticsStats.avgMastery"),
value: `${Math.round(averageMasteryRate * 100)}%`,
sub: averageMasteryRate >= 0.6 ? "整体良好" : "需加强",
sub: averageMasteryRate >= 0.6
? t("analyticsStats.avgMasteryGood")
: t("analyticsStats.avgMasteryNeedImprove"),
icon: CheckCircle2,
color: "text-emerald-600 dark:text-emerald-400",
bg: "bg-emerald-50 dark:bg-emerald-950/30",
},
{
label: "待复习",
label: t("analyticsStats.dueReview"),
value: dueReviewCount,
sub: dueReviewCount > 0 ? "需要关注" : "无到期",
sub: dueReviewCount > 0
? t("analyticsStats.dueReviewNeedAttention")
: t("analyticsStats.dueReviewNone"),
icon: Clock,
color: "text-amber-600 dark:text-amber-400",
bg: "bg-amber-50 dark:bg-amber-950/30",
},
{
label: "涉及知识点",
label: t("analyticsStats.knowledgePoints"),
value: knowledgePointCount ?? 0,
sub: knowledgePointCount && knowledgePointCount > 5 ? "范围较广" : "集中",
sub: knowledgePointCount && knowledgePointCount > 5
? t("analyticsStats.knowledgePointsWide")
: t("analyticsStats.knowledgePointsFocused"),
icon: Brain,
color: "text-purple-600 dark:text-purple-400",
bg: "bg-purple-50 dark:bg-purple-950/30",