feat(grades): add ranking trend, school-wide summary, score cell, and scope filter

- Add ranking-trend-card and school-wide-summary-card for broader analytics

- Add score-cell and grade-filters components for table rendering

- Add scope-filter and type-guards lib utilities for grade data filtering

- Update actions, data-access (analytics, ranking, main), stats-service, export

- Update schema, types, and grade-utils lib

- Update all grade chart and report components (distribution, trend, comparison, query)
This commit is contained in:
SpecialX
2026-06-23 17:37:32 +08:00
parent 2197e68069
commit 95145cd03b
32 changed files with 3202 additions and 682 deletions

View File

@@ -0,0 +1,41 @@
"use client"
import type { JSX } from "react"
import { cn } from "@/shared/lib/utils"
/**
* v4-P1-7: 成绩单元格组件,根据得分率着色。
*
* 着色规则(对标 PowerSchool / Canvas / 超星学习通):
* - 得分率 < 60%:红色(不及格)
* - 得分率 60% ~ 84%:黄色(及格但未达优秀)
* - 得分率 ≥ 85%:绿色(优秀)
* - fullScore <= 0不着色异常数据避免除零
*
* 使用语义化的 Tailwind 类名,避免动态拼接。
*/
export function ScoreCell({
score,
fullScore,
className,
}: {
score: number
fullScore: number
className?: string
}): JSX.Element {
const ratio = fullScore > 0 ? score / fullScore : 1
const isFail = ratio < 0.6
const isExcellent = ratio >= 0.85
const colorClass = isFail
? "text-red-600 font-semibold"
: isExcellent
? "text-green-600 font-semibold"
: "text-yellow-600 font-medium"
return (
<span className={cn("font-mono tabular-nums", colorClass, className)}>
{score} / {fullScore}
</span>
)
}