feat(app): add lesson-plans, practice, and grade dashboard routes
- Add admin/lesson-plans, parent/lesson-plans, student/lesson-plans routes - Add student/practice and teacher/practice routes for adaptive practice - Add management/grade/dashboard and management/grade/practice routes - Add teacher/lesson-plans error and loading boundaries - Update existing admin, parent, student, teacher pages with new features - Update globals.css and proxy middleware
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
import { AiProviderSettingsCard } from "@/modules/settings/components/ai-provider-settings-card"
|
import { AiProviderSettingsCard } from "@/modules/settings/components/ai-provider-settings-card"
|
||||||
import { AiUsageDashboard } from "@/modules/ai/components/ai-usage-dashboard"
|
import { AiUsageDashboard } from "@/modules/ai/components/ai-usage-dashboard"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "AI 配置 - Next_Edu",
|
const t = await getTranslations("ai")
|
||||||
description: "统一管理 AI 服务商、API 密钥与使用统计",
|
return {
|
||||||
|
title: `${t("admin.settings.title")} - Next_Edu`,
|
||||||
|
description: t("admin.settings.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
@@ -18,25 +22,31 @@ export const dynamic = "force-dynamic"
|
|||||||
*
|
*
|
||||||
* 作为 AI 模块的独立配置入口,取代:
|
* 作为 AI 模块的独立配置入口,取代:
|
||||||
* - /settings?tab=ai(已移除 AI 标签页)
|
* - /settings?tab=ai(已移除 AI 标签页)
|
||||||
* - 考试页面内嵌的 AI 配置弹窗(已改为跳转链接)
|
* - 考试页面内嵌的 AI 配置弹窗(已移除)
|
||||||
*
|
*
|
||||||
* 权限:AI_CONFIGURE(当前仅 admin 角色拥有)
|
* 权限规则:
|
||||||
|
* - AI_CHAT 用户均可访问(管理自己的 private provider)
|
||||||
|
* - AI_CONFIGURE 用户(管理员)可额外管理 public provider 与他人 private provider
|
||||||
*/
|
*/
|
||||||
export default async function AiSettingsPage(): Promise<JSX.Element> {
|
export default async function AiSettingsPage(): Promise<JSX.Element> {
|
||||||
await requirePermission(Permissions.AI_CONFIGURE)
|
const t = await getTranslations("ai")
|
||||||
|
const ctx = await requirePermission(Permissions.AI_CHAT)
|
||||||
|
const isAdmin = ctx.permissions.includes(Permissions.AI_CONFIGURE)
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col gap-8 p-8">
|
<div className="flex h-full flex-col gap-8 p-8">
|
||||||
<div className="flex flex-col justify-between gap-4 md:flex-row md:items-center">
|
<div className="flex flex-col justify-between gap-4 md:flex-row md:items-center">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h1 className="text-3xl font-bold tracking-tight">AI 配置</h1>
|
<h1 className="text-3xl font-bold tracking-tight">{t("admin.settings.title")}</h1>
|
||||||
<div className="text-sm text-muted-foreground">
|
<div className="text-sm text-muted-foreground">
|
||||||
统一管理 AI 服务商、API 密钥与使用统计
|
{isAdmin
|
||||||
|
? t("admin.settings.description")
|
||||||
|
: t("admin.settings.userDescription")}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<AiProviderSettingsCard />
|
<AiProviderSettingsCard isAdmin={isAdmin} currentUserId={ctx.userId} />
|
||||||
<AiUsageDashboard />
|
{isAdmin ? <AiUsageDashboard /> : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -13,9 +14,12 @@ import { DataChangeLogTable } from "@/modules/audit/components/data-change-log-t
|
|||||||
import { AuditLogExportButton } from "@/modules/audit/components/audit-log-export-button"
|
import { AuditLogExportButton } from "@/modules/audit/components/audit-log-export-button"
|
||||||
import type { DataChangeAction } from "@/modules/audit/types"
|
import type { DataChangeAction } from "@/modules/audit/types"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "数据变更日志 - Next_Edu",
|
const t = await getTranslations("audit")
|
||||||
description: "追踪系统所有数据变更(增删改),保障合规",
|
return {
|
||||||
|
title: `${t("dataChanges.title")} - Next_Edu`,
|
||||||
|
description: t("dataChanges.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
@@ -28,6 +32,7 @@ export default async function DataChangeLogsPage({
|
|||||||
}: {
|
}: {
|
||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}): Promise<JSX.Element> {
|
}): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("audit")
|
||||||
await requirePermission(Permissions.AUDIT_LOG_READ)
|
await requirePermission(Permissions.AUDIT_LOG_READ)
|
||||||
|
|
||||||
const params = await searchParams
|
const params = await searchParams
|
||||||
@@ -54,10 +59,8 @@ export default async function DataChangeLogsPage({
|
|||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="flex items-start justify-between gap-4">
|
<div className="flex items-start justify-between gap-4">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">数据变更日志</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("dataChanges.title")}</h2>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">{t("dataChanges.description")}</p>
|
||||||
追踪系统所有数据变更(增删改),保障合规。
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<AuditLogExportButton exportType="dataChange" params={exportParams} />
|
<AuditLogExportButton exportType="dataChange" params={exportParams} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -9,9 +10,12 @@ import { LoginLogView } from "@/modules/audit/components/login-log-view"
|
|||||||
import { AuditLogExportButton } from "@/modules/audit/components/audit-log-export-button"
|
import { AuditLogExportButton } from "@/modules/audit/components/audit-log-export-button"
|
||||||
import type { LoginLogAction, LoginLogStatus } from "@/modules/audit/types"
|
import type { LoginLogAction, LoginLogStatus } from "@/modules/audit/types"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "登录日志 - Next_Edu",
|
const t = await getTranslations("audit")
|
||||||
description: "监控所有认证事件,包括登录、登出与注册",
|
return {
|
||||||
|
title: `${t("loginLogs.title")} - Next_Edu`,
|
||||||
|
description: t("loginLogs.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
@@ -27,6 +31,7 @@ export default async function LoginLogsPage({
|
|||||||
}: {
|
}: {
|
||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}): Promise<JSX.Element> {
|
}): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("audit")
|
||||||
await requirePermission(Permissions.AUDIT_LOG_READ)
|
await requirePermission(Permissions.AUDIT_LOG_READ)
|
||||||
|
|
||||||
const params = await searchParams
|
const params = await searchParams
|
||||||
@@ -50,9 +55,9 @@ export default async function LoginLogsPage({
|
|||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="flex items-start justify-between gap-4">
|
<div className="flex items-start justify-between gap-4">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">登录日志</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("loginLogs.title")}</h2>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
监控所有认证事件,包括登录、登出与注册。
|
{t("loginLogs.description")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<AuditLogExportButton exportType="login" params={exportParams} />
|
<AuditLogExportButton exportType="login" params={exportParams} />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -9,9 +10,12 @@ import { AuditLogView } from "@/modules/audit/components/audit-log-view"
|
|||||||
import { AuditLogExportButton } from "@/modules/audit/components/audit-log-export-button"
|
import { AuditLogExportButton } from "@/modules/audit/components/audit-log-export-button"
|
||||||
import type { AuditLogStatus } from "@/modules/audit/types"
|
import type { AuditLogStatus } from "@/modules/audit/types"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "审计日志 - Next_Edu",
|
const t = await getTranslations("audit")
|
||||||
description: "追踪系统内所有用户操作,保障安全与合规",
|
return {
|
||||||
|
title: `${t("title")} - Next_Edu`,
|
||||||
|
description: t("description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
@@ -24,6 +28,7 @@ export default async function AuditLogsPage({
|
|||||||
}: {
|
}: {
|
||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}): Promise<JSX.Element> {
|
}): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("audit")
|
||||||
await requirePermission(Permissions.AUDIT_LOG_READ)
|
await requirePermission(Permissions.AUDIT_LOG_READ)
|
||||||
|
|
||||||
const params = await searchParams
|
const params = await searchParams
|
||||||
@@ -51,10 +56,8 @@ export default async function AuditLogsPage({
|
|||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="flex items-start justify-between gap-4">
|
<div className="flex items-start justify-between gap-4">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">审计日志</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("title")}</h2>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">{t("description")}</p>
|
||||||
追踪系统内所有用户操作,保障安全与合规。
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<AuditLogExportButton exportType="audit" params={exportParams} />
|
<AuditLogExportButton exportType="audit" params={exportParams} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
import { notFound } from "next/navigation"
|
import { notFound } from "next/navigation"
|
||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getCoursePlanById, getSubjectOptions } from "@/modules/course-plans/data-access"
|
import { getCoursePlanById, getSubjectOptions } from "@/modules/course-plans/data-access"
|
||||||
import { getAdminClasses } from "@/modules/classes/data-access"
|
import { getAdminClasses } from "@/modules/classes/data-access"
|
||||||
import { getAcademicYears, getStaffOptions } from "@/modules/school/data-access"
|
import { getAcademicYears, getStaffOptions } from "@/modules/school/data-access"
|
||||||
import { CoursePlanForm } from "@/modules/course-plans/components/course-plan-form"
|
import { CoursePlanForm } from "@/modules/course-plans/components/course-plan-form"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "编辑课程计划 - Next_Edu",
|
const t = await getTranslations("coursePlans")
|
||||||
description: "更新课程计划详情",
|
return {
|
||||||
|
title: `${t("edit.title")} - Next_Edu`,
|
||||||
|
description: t("edit.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
@@ -19,6 +23,7 @@ export default async function EditCoursePlanPage({
|
|||||||
}: {
|
}: {
|
||||||
params: Promise<{ id: string }>
|
params: Promise<{ id: string }>
|
||||||
}): Promise<JSX.Element> {
|
}): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("coursePlans")
|
||||||
const { id } = await params
|
const { id } = await params
|
||||||
|
|
||||||
const [plan, classes, subjects, teachers, academicYears] = await Promise.all([
|
const [plan, classes, subjects, teachers, academicYears] = await Promise.all([
|
||||||
@@ -34,8 +39,8 @@ export default async function EditCoursePlanPage({
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">编辑课程计划</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("edit.title")}</h2>
|
||||||
<p className="text-muted-foreground">更新课程计划详情。</p>
|
<p className="text-muted-foreground">{t("edit.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<CoursePlanForm
|
<CoursePlanForm
|
||||||
mode="edit"
|
mode="edit"
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
import { notFound } from "next/navigation"
|
import { notFound } from "next/navigation"
|
||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getCoursePlanById } from "@/modules/course-plans/data-access"
|
import { getCoursePlanById } from "@/modules/course-plans/data-access"
|
||||||
import { CoursePlanDetail } from "@/modules/course-plans/components/course-plan-detail"
|
import { CoursePlanDetail } from "@/modules/course-plans/components/course-plan-detail"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "课程计划详情 - Next_Edu",
|
const t = await getTranslations("coursePlans")
|
||||||
description: "查看课程计划详情",
|
return {
|
||||||
|
title: `${t("detail.title")} - Next_Edu`,
|
||||||
|
description: t("detail.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getAdminClasses } from "@/modules/classes/data-access"
|
import { getAdminClasses } from "@/modules/classes/data-access"
|
||||||
import { getAcademicYears, getStaffOptions } from "@/modules/school/data-access"
|
import { getAcademicYears, getStaffOptions } from "@/modules/school/data-access"
|
||||||
import { getSubjectOptions } from "@/modules/course-plans/data-access"
|
import { getSubjectOptions } from "@/modules/course-plans/data-access"
|
||||||
import { CoursePlanForm } from "@/modules/course-plans/components/course-plan-form"
|
import { CoursePlanForm } from "@/modules/course-plans/components/course-plan-form"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "新建课程计划 - Next_Edu",
|
const t = await getTranslations("coursePlans")
|
||||||
description: "创建新的课程教学计划",
|
return {
|
||||||
|
title: `${t("create.title")} - Next_Edu`,
|
||||||
|
description: t("create.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function CreateCoursePlanPage(): Promise<JSX.Element> {
|
export default async function CreateCoursePlanPage(): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("coursePlans")
|
||||||
const [classes, subjects, teachers, academicYears] = await Promise.all([
|
const [classes, subjects, teachers, academicYears] = await Promise.all([
|
||||||
getAdminClasses(),
|
getAdminClasses(),
|
||||||
getSubjectOptions(),
|
getSubjectOptions(),
|
||||||
@@ -24,8 +29,8 @@ export default async function CreateCoursePlanPage(): Promise<JSX.Element> {
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">新建课程计划</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("create.title")}</h2>
|
||||||
<p className="text-muted-foreground">创建新的课程教学计划。</p>
|
<p className="text-muted-foreground">{t("create.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<CoursePlanForm
|
<CoursePlanForm
|
||||||
mode="create"
|
mode="create"
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getCoursePlans } from "@/modules/course-plans/data-access"
|
import { getCoursePlans } from "@/modules/course-plans/data-access"
|
||||||
import { CoursePlanList } from "@/modules/course-plans/components/course-plan-list"
|
import { CoursePlanList } from "@/modules/course-plans/components/course-plan-list"
|
||||||
import { getSearchParam, type SearchParams } from "@/shared/lib/utils"
|
import { getSearchParam, type SearchParams } from "@/shared/lib/utils"
|
||||||
import type { CoursePlanStatus } from "@/modules/course-plans/types"
|
import type { CoursePlanStatus } from "@/modules/course-plans/types"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "课程计划 - Next_Edu",
|
const t = await getTranslations("coursePlans")
|
||||||
description: "管理课程教学计划与周课时安排",
|
return {
|
||||||
|
title: `${t("title")} - Next_Edu`,
|
||||||
|
description: t("description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
@@ -21,6 +25,7 @@ export default async function AdminCoursePlansPage({
|
|||||||
}: {
|
}: {
|
||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}): Promise<JSX.Element> {
|
}): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("coursePlans")
|
||||||
const sp = await searchParams
|
const sp = await searchParams
|
||||||
const statusParam = getSearchParam(sp, "status")
|
const statusParam = getSearchParam(sp, "status")
|
||||||
const status = isValidStatus(statusParam) ? statusParam : undefined
|
const status = isValidStatus(statusParam) ? statusParam : undefined
|
||||||
@@ -30,10 +35,8 @@ export default async function AdminCoursePlansPage({
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">课程计划</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("title")}</h2>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">{t("description")}</p>
|
||||||
管理课程教学计划与周课时安排。
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<CoursePlanList
|
<CoursePlanList
|
||||||
plans={plans}
|
plans={plans}
|
||||||
|
|||||||
@@ -1,57 +1,84 @@
|
|||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import type { Metadata } from "next"
|
||||||
|
import { Suspense } from "react"
|
||||||
import { BarChart3 } from "lucide-react"
|
import { BarChart3 } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getStudentErrorBookSummaries,
|
getStudentErrorBookSummaries,
|
||||||
getTopWrongQuestionsByStudentIds,
|
getTopWrongQuestionsByStudentIds,
|
||||||
getKnowledgePointWeakness,
|
getKnowledgePointWeakness,
|
||||||
getSubjectErrorDistribution,
|
|
||||||
getStudentNameMap,
|
getStudentNameMap,
|
||||||
|
getSubjectErrorOverviews,
|
||||||
|
getSubjectErrorDistribution,
|
||||||
|
getChapterWeakness,
|
||||||
getAllStudentIds,
|
getAllStudentIds,
|
||||||
} from "@/modules/error-book/data-access"
|
} from "@/modules/error-book/data-access"
|
||||||
import { ClassErrorBookOverview, StudentErrorTable } from "@/modules/error-book/components/class-error-overview"
|
|
||||||
import { TopWrongQuestions } from "@/modules/error-book/components/top-wrong-questions"
|
import { TopWrongQuestions } from "@/modules/error-book/components/top-wrong-questions"
|
||||||
|
import { SubjectTabs } from "@/modules/error-book/components/subject-tabs"
|
||||||
|
import { AnalyticsStatsCards } from "@/modules/error-book/components/analytics-stats-cards"
|
||||||
|
import { SubjectDistributionChart } from "@/modules/error-book/components/subject-distribution-chart"
|
||||||
|
import { KnowledgePointWeaknessChart } from "@/modules/error-book/components/knowledge-point-weakness-chart"
|
||||||
|
import { ChapterWeaknessChart } from "@/modules/error-book/components/chapter-weakness-chart"
|
||||||
|
import { GroupedStudentErrorTable } from "@/modules/error-book/components/grouped-student-error-table"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function AdminErrorBookPage(): Promise<JSX.Element> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
const t = await getTranslations("errorBook")
|
||||||
|
return {
|
||||||
|
title: `${t("admin.title")} - Next_Edu`,
|
||||||
|
description: t("admin.description"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function AdminErrorBookContent({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<SearchParams>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("errorBook")
|
||||||
const ctx = await requirePermission(Permissions.ERROR_BOOK_ANALYTICS_READ)
|
const ctx = await requirePermission(Permissions.ERROR_BOOK_ANALYTICS_READ)
|
||||||
|
|
||||||
if (ctx.dataScope.type !== "all") {
|
if (ctx.dataScope.type !== "all") {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">全校错题分析</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{t("admin.title")}</h1>
|
||||||
<p className="text-muted-foreground">查看全校学生的错题统计与薄弱知识点。</p>
|
<p className="text-muted-foreground">{t("admin.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title="权限不足"
|
title={t("admin.noPermissionTitle")}
|
||||||
description="您没有权限查看全校错题分析数据。"
|
description={t("admin.noPermissionDescription")}
|
||||||
className="h-[360px] bg-card"
|
className="h-[360px] bg-card"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过 data-access 层查询所有学生 ID(遵循三层架构,app 层不直接访问 DB)
|
const params = await searchParams
|
||||||
const studentIds = await getAllStudentIds()
|
|
||||||
|
|
||||||
if (studentIds.length === 0) {
|
// 通过 data-access 层查询所有学生 ID(遵循三层架构)
|
||||||
|
const allStudentIds = await getAllStudentIds()
|
||||||
|
|
||||||
|
if (allStudentIds.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">全校错题分析</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{t("admin.title")}</h1>
|
||||||
<p className="text-muted-foreground">查看全校学生的错题统计与薄弱知识点。</p>
|
<p className="text-muted-foreground">{t("admin.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title="暂无学生数据"
|
title={t("admin.noStudentsTitle")}
|
||||||
description="系统中还没有学生用户,无法查看错题分析。"
|
description={t("admin.noStudentsDescription")}
|
||||||
className="h-[360px] bg-card"
|
className="h-[360px] bg-card"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -59,21 +86,33 @@ export default async function AdminErrorBookPage(): Promise<JSX.Element> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 限制查询数量,避免性能问题(取最近活跃的 500 名学生)
|
// 限制查询数量,避免性能问题(取最近活跃的 500 名学生)
|
||||||
const limitedStudentIds = studentIds.slice(0, 500)
|
const limitedStudentIds = allStudentIds.slice(0, 500)
|
||||||
|
|
||||||
const [summaries, topWrongQuestions, weakKps, subjectDist, nameMap] = await Promise.all([
|
// 解析 URL 参数:学科筛选
|
||||||
getStudentErrorBookSummaries(limitedStudentIds),
|
const subjectParam = getParam(params, "subject")
|
||||||
getTopWrongQuestionsByStudentIds(limitedStudentIds, 10),
|
|
||||||
getKnowledgePointWeakness(limitedStudentIds, 10),
|
// 学科概览(用于 Tab 显示,不受学科筛选影响)
|
||||||
|
const [subjectOverviews, subjectDist] = await Promise.all([
|
||||||
|
getSubjectErrorOverviews(limitedStudentIds),
|
||||||
getSubjectErrorDistribution(limitedStudentIds),
|
getSubjectErrorDistribution(limitedStudentIds),
|
||||||
|
])
|
||||||
|
|
||||||
|
// 并行查询所有统计数据(按学科过滤)
|
||||||
|
const [summaries, topWrongQuestions, weakKps, chapterWeakness, nameMap] = await Promise.all([
|
||||||
|
getStudentErrorBookSummaries(limitedStudentIds, subjectParam),
|
||||||
|
getTopWrongQuestionsByStudentIds(limitedStudentIds, 10, subjectParam),
|
||||||
|
getKnowledgePointWeakness(limitedStudentIds, 10, subjectParam),
|
||||||
|
getChapterWeakness(limitedStudentIds, 10, subjectParam),
|
||||||
getStudentNameMap(limitedStudentIds),
|
getStudentNameMap(limitedStudentIds),
|
||||||
])
|
])
|
||||||
|
|
||||||
const studentsWithErrorBook = summaries.filter((s) => s.totalCount > 0)
|
const studentsWithErrorBook = summaries.filter((s) => s.totalCount > 0)
|
||||||
const totalErrorItems = summaries.reduce((sum, s) => sum + s.totalCount, 0)
|
const totalErrorItems = summaries.reduce((sum, s) => sum + s.totalCount, 0)
|
||||||
|
const totalDueReview = summaries.reduce((sum, s) => sum + s.dueReviewCount, 0)
|
||||||
const averageMasteryRate = studentsWithErrorBook.length > 0
|
const averageMasteryRate = studentsWithErrorBook.length > 0
|
||||||
? studentsWithErrorBook.reduce((sum, s) => sum + s.masteredRate, 0) / studentsWithErrorBook.length
|
? studentsWithErrorBook.reduce((sum, s) => sum + s.masteredRate, 0) / studentsWithErrorBook.length
|
||||||
: 0
|
: 0
|
||||||
|
const knowledgePointCount = weakKps.length
|
||||||
|
|
||||||
const sortedSummaries = [...summaries]
|
const sortedSummaries = [...summaries]
|
||||||
.filter((s) => s.totalCount > 0)
|
.filter((s) => s.totalCount > 0)
|
||||||
@@ -81,33 +120,114 @@ export default async function AdminErrorBookPage(): Promise<JSX.Element> {
|
|||||||
.slice(0, 50)
|
.slice(0, 50)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-6 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">全校错题分析</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{t("admin.title")}</h1>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">{t("admin.description")}</p>
|
||||||
全校错题统计与薄弱知识点分析,辅助教学决策。
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ClassErrorBookOverview
|
{/* 学科 Tab */}
|
||||||
totalStudents={studentIds.length}
|
{subjectOverviews.length > 0 ? (
|
||||||
|
<Suspense fallback={<Skeleton className="h-10 w-full" />}>
|
||||||
|
<SubjectTabs
|
||||||
|
subjects={subjectOverviews}
|
||||||
|
currentSubjectId={subjectParam ?? null}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 统计卡片 */}
|
||||||
|
<AnalyticsStatsCards
|
||||||
|
totalStudents={limitedStudentIds.length}
|
||||||
studentsWithErrorBook={studentsWithErrorBook.length}
|
studentsWithErrorBook={studentsWithErrorBook.length}
|
||||||
totalErrorItems={totalErrorItems}
|
totalErrorItems={totalErrorItems}
|
||||||
averageMasteryRate={averageMasteryRate}
|
averageMasteryRate={averageMasteryRate}
|
||||||
topWeakKnowledgePoints={weakKps}
|
dueReviewCount={totalDueReview}
|
||||||
subjectDistribution={subjectDist}
|
knowledgePointCount={knowledgePointCount}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="space-y-4">
|
{/* 学科错题分布图(仅在"全部学科"视图下显示) */}
|
||||||
<h2 className="text-lg font-semibold">错题最多的学生 Top 50</h2>
|
{!subjectParam && subjectDist.length > 0 ? (
|
||||||
<StudentErrorTable
|
<SubjectDistributionChart data={subjectDist} />
|
||||||
students={sortedSummaries}
|
) : null}
|
||||||
studentNames={nameMap}
|
|
||||||
basePath="/admin/error-book"
|
{/* 章节错题分布 + 知识点薄弱度(并排) */}
|
||||||
/>
|
<div className="grid gap-4 lg:grid-cols-2">
|
||||||
|
{chapterWeakness.length > 0 ? (
|
||||||
|
<ChapterWeaknessChart data={chapterWeakness} />
|
||||||
|
) : (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("admin.noChapterDataTitle")}
|
||||||
|
description={t("admin.noChapterDataDescription")}
|
||||||
|
className="h-[300px] bg-card"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{weakKps.length > 0 ? (
|
||||||
|
<KnowledgePointWeaknessChart data={weakKps} />
|
||||||
|
) : (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("admin.noKnowledgePointDataTitle")}
|
||||||
|
description={t("admin.noKnowledgePointDataDescription")}
|
||||||
|
className="h-[300px] bg-card"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TopWrongQuestions questions={topWrongQuestions} />
|
{/* 错题最多的学生 Top 50 */}
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<h2 className="text-lg font-semibold">{t("admin.topStudents")}</h2>
|
||||||
|
<span className="text-sm text-muted-foreground">
|
||||||
|
{t("admin.studentsWithErrors", { count: studentsWithErrorBook.length })}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{sortedSummaries.length > 0 ? (
|
||||||
|
<GroupedStudentErrorTable
|
||||||
|
students={sortedSummaries}
|
||||||
|
studentNames={nameMap}
|
||||||
|
basePath="/admin/error-book"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("admin.noStudentErrorsTitle")}
|
||||||
|
description={t("admin.noStudentErrorsDescription")}
|
||||||
|
className="h-[200px] bg-card"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 高频错题 Top 10 */}
|
||||||
|
{topWrongQuestions.length > 0 ? (
|
||||||
|
<TopWrongQuestions questions={topWrongQuestions} />
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default async function AdminErrorBookPage({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<SearchParams>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
return (
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<Skeleton className="h-10 w-48" />
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-5">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[100px]" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-[300px] w-full" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<AdminErrorBookContent searchParams={searchParams} />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -9,9 +10,12 @@ import {
|
|||||||
} from "@/modules/files/data-access"
|
} from "@/modules/files/data-access"
|
||||||
import { AdminFilesView } from "@/modules/files/components/admin-files-view"
|
import { AdminFilesView } from "@/modules/files/components/admin-files-view"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "文件管理 - Next_Edu",
|
const t = await getTranslations("files")
|
||||||
description: "查看与管理系统中所有上传文件",
|
return {
|
||||||
|
title: `${t("title")} - Next_Edu`,
|
||||||
|
description: t("description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import { getAuthContext } from "@/shared/lib/auth-guard"
|
|
||||||
|
|
||||||
export default async function AdminLayout({
|
export default async function AdminLayout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}): Promise<React.ReactNode> {
|
}): Promise<React.ReactNode> {
|
||||||
await getAuthContext()
|
|
||||||
return <>{children}</>
|
return <>{children}</>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function AdminLessonPlanViewError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function AdminLessonPlanViewLoading() {
|
||||||
|
return (
|
||||||
|
<div className="h-[calc(100vh-4rem)]">
|
||||||
|
<div className="flex h-full items-center justify-center">
|
||||||
|
<Skeleton className="h-[80%] w-[80%]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import type { JSX } from "react"
|
||||||
|
import { Suspense } from "react"
|
||||||
|
import { notFound } from "next/navigation"
|
||||||
|
import { getAuthContext } from "@/shared/lib/auth-guard"
|
||||||
|
import { getLessonPlanById } from "@/modules/lesson-preparation/data-access"
|
||||||
|
import { getTextbookById, getChaptersByTextbookId } from "@/modules/textbooks/data-access"
|
||||||
|
import { LessonPlanReadonlyView } from "@/modules/lesson-preparation/components/lesson-plan-readonly-view"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function AdminLessonPlanViewPage({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ planId: string }>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
const { planId } = await params
|
||||||
|
const ctx = await getAuthContext()
|
||||||
|
|
||||||
|
const plan = await getLessonPlanById(planId, ctx.userId)
|
||||||
|
if (!plan) notFound()
|
||||||
|
|
||||||
|
let textbookTitle: string | undefined
|
||||||
|
let chapterTitle: string | undefined
|
||||||
|
if (plan.textbookId) {
|
||||||
|
const textbook = await getTextbookById(plan.textbookId)
|
||||||
|
textbookTitle = textbook?.title
|
||||||
|
if (plan.chapterId) {
|
||||||
|
const chapters = await getChaptersByTextbookId(plan.textbookId)
|
||||||
|
const findChapter = (list: typeof chapters): typeof chapters[number] | undefined => {
|
||||||
|
for (const ch of list) {
|
||||||
|
if (ch.id === plan.chapterId) return ch
|
||||||
|
if (ch.children && ch.children.length > 0) {
|
||||||
|
const found = findChapter(ch.children as typeof chapters)
|
||||||
|
if (found) return found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const chapter = findChapter(chapters)
|
||||||
|
chapterTitle = chapter?.title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="h-[calc(100vh-4rem)]">
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="flex h-full items-center justify-center">
|
||||||
|
<Skeleton className="h-[80%] w-[80%]" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LessonPlanReadonlyView
|
||||||
|
doc={plan.content}
|
||||||
|
textbookTitle={textbookTitle}
|
||||||
|
chapterTitle={chapterTitle}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
20
src/app/(dashboard)/admin/lesson-plans/error.tsx
Normal file
20
src/app/(dashboard)/admin/lesson-plans/error.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function AdminLessonPlansError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
22
src/app/(dashboard)/admin/lesson-plans/loading.tsx
Normal file
22
src/app/(dashboard)/admin/lesson-plans/loading.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function AdminLessonPlansLoading() {
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-[180px]" />
|
||||||
|
<Skeleton className="h-4 w-[300px]" />
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||||
|
{Array.from({ length: 4 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[100px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[180px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
88
src/app/(dashboard)/admin/lesson-plans/page.tsx
Normal file
88
src/app/(dashboard)/admin/lesson-plans/page.tsx
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
import type { JSX } from "react"
|
||||||
|
import { Suspense } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
import { getAuthContext } from "@/shared/lib/auth-guard"
|
||||||
|
import { getLessonPlans, getLessonPlanStats } from "@/modules/lesson-preparation/data-access"
|
||||||
|
import { getSubjectOptions } from "@/modules/school/data-access"
|
||||||
|
import { LessonPlanList } from "@/modules/lesson-preparation/components/lesson-plan-list"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function AdminLessonPlansPage(): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("lessonPreparation")
|
||||||
|
const ctx = await getAuthContext()
|
||||||
|
|
||||||
|
// 通过 data-access 层查询,避免 app 层直接访问数据库(P0-1 修复)
|
||||||
|
const [items, subjects, stats] = await Promise.all([
|
||||||
|
getLessonPlans({}, ctx.dataScope, ctx.userId),
|
||||||
|
getSubjectOptions(),
|
||||||
|
getLessonPlanStats(),
|
||||||
|
])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">{t("admin.title")}</h1>
|
||||||
|
<p className="text-muted-foreground">{t("admin.description")}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 统计卡片 */}
|
||||||
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||||
|
<Card>
|
||||||
|
<CardHeader className="pb-2">
|
||||||
|
<CardTitle className="text-sm font-medium text-on-surface-variant">
|
||||||
|
{t("admin.stats.total")}
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="text-2xl font-bold">{stats.total}</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<CardHeader className="pb-2">
|
||||||
|
<CardTitle className="text-sm font-medium text-on-surface-variant">
|
||||||
|
{t("admin.stats.published")}
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="text-2xl font-bold text-primary">{stats.published}</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<CardHeader className="pb-2">
|
||||||
|
<CardTitle className="text-sm font-medium text-on-surface-variant">
|
||||||
|
{t("admin.stats.draft")}
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="text-2xl font-bold text-on-surface-variant">{stats.draft}</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<CardHeader className="pb-2">
|
||||||
|
<CardTitle className="text-sm font-medium text-on-surface-variant">
|
||||||
|
{t("admin.stats.archived")}
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="text-2xl font-bold text-on-surface-variant">{stats.archived}</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[180px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LessonPlanList initialItems={items} subjects={subjects} viewMode="admin" />
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { CalendarClock, ClipboardList, Settings2 } from "lucide-react"
|
import { CalendarClock, ClipboardList, Settings2 } from "lucide-react"
|
||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -10,14 +11,18 @@ import { EmptyState } from "@/shared/components/ui/empty-state"
|
|||||||
import { getAdminClassesForScheduling } from "@/modules/scheduling/data-access"
|
import { getAdminClassesForScheduling } from "@/modules/scheduling/data-access"
|
||||||
import { AutoSchedulePanel } from "@/modules/scheduling/components/auto-schedule-panel"
|
import { AutoSchedulePanel } from "@/modules/scheduling/components/auto-schedule-panel"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "自动排课 - Next_Edu",
|
const t = await getTranslations("scheduling")
|
||||||
description: "基于规则与学科分配自动生成周课表",
|
return {
|
||||||
|
title: `${t("auto.title")} - Next_Edu`,
|
||||||
|
description: t("auto.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function AdminSchedulingAutoPage(): Promise<JSX.Element> {
|
export default async function AdminSchedulingAutoPage(): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("scheduling")
|
||||||
await requirePermission(Permissions.SCHEDULE_AUTO)
|
await requirePermission(Permissions.SCHEDULE_AUTO)
|
||||||
const classes = await getAdminClassesForScheduling()
|
const classes = await getAdminClassesForScheduling()
|
||||||
const classOptions = classes.map((c) => ({ id: c.id, name: c.name, grade: c.grade }))
|
const classOptions = classes.map((c) => ({ id: c.id, name: c.name, grade: c.grade }))
|
||||||
@@ -26,15 +31,13 @@ export default async function AdminSchedulingAutoPage(): Promise<JSX.Element> {
|
|||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="flex items-center justify-between space-y-2">
|
<div className="flex items-center justify-between space-y-2">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">自动排课</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("auto.title")}</h2>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">{t("auto.description")}</p>
|
||||||
基于规则与学科分配自动生成周课表。
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<Button asChild variant="outline">
|
<Button asChild variant="outline">
|
||||||
<Link href="/admin/scheduling/rules">
|
<Link href="/admin/scheduling/rules">
|
||||||
<Settings2 className="mr-2 h-4 w-4" />
|
<Settings2 className="mr-2 h-4 w-4" />
|
||||||
配置规则
|
{t("auto.configureRules")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,8 +45,8 @@ export default async function AdminSchedulingAutoPage(): Promise<JSX.Element> {
|
|||||||
{classOptions.length === 0 ? (
|
{classOptions.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={ClipboardList}
|
icon={ClipboardList}
|
||||||
title="暂无可用班级"
|
title={t("auto.noClassesTitle")}
|
||||||
description="请先创建班级,再进行自动排课。"
|
description={t("auto.noClassesDescription")}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<AutoSchedulePanel classes={classOptions} />
|
<AutoSchedulePanel classes={classOptions} />
|
||||||
@@ -51,7 +54,7 @@ export default async function AdminSchedulingAutoPage(): Promise<JSX.Element> {
|
|||||||
|
|
||||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||||
<CalendarClock className="h-4 w-4" />
|
<CalendarClock className="h-4 w-4" />
|
||||||
<span>应用新课表将替换所选班级的现有课表。</span>
|
<span>{t("auto.hint")}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { PlusCircle, ClipboardList } from "lucide-react"
|
import { PlusCircle, ClipboardList } from "lucide-react"
|
||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -18,9 +19,12 @@ import { ScheduleConflictsView } from "@/modules/scheduling/components/schedule-
|
|||||||
import { ScheduleGridView } from "@/modules/scheduling/components/schedule-grid-view"
|
import { ScheduleGridView } from "@/modules/scheduling/components/schedule-grid-view"
|
||||||
import type { ScheduleChangeStatus } from "@/modules/scheduling/types"
|
import type { ScheduleChangeStatus } from "@/modules/scheduling/types"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "课表变更申请 - Next_Edu",
|
const t = await getTranslations("scheduling")
|
||||||
description: "审核、批准或拒绝课表变更与代课申请",
|
return {
|
||||||
|
title: `${t("changes.title")} - Next_Edu`,
|
||||||
|
description: t("changes.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
@@ -33,6 +37,7 @@ export default async function AdminSchedulingChangesPage({
|
|||||||
}: {
|
}: {
|
||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}): Promise<JSX.Element> {
|
}): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("scheduling")
|
||||||
await requirePermission(Permissions.SCHEDULE_ADJUST)
|
await requirePermission(Permissions.SCHEDULE_ADJUST)
|
||||||
const sp = await searchParams
|
const sp = await searchParams
|
||||||
const statusParam = getSearchParam(sp, "status")
|
const statusParam = getSearchParam(sp, "status")
|
||||||
@@ -51,15 +56,15 @@ export default async function AdminSchedulingChangesPage({
|
|||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="flex items-center justify-between space-y-2">
|
<div className="flex items-center justify-between space-y-2">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">课表变更申请</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("changes.title")}</h2>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
审核、批准或拒绝课表变更与代课申请。
|
{t("changes.description")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Button asChild>
|
<Button asChild>
|
||||||
<Link href="/teacher/schedule-changes">
|
<Link href="/teacher/schedule-changes">
|
||||||
<PlusCircle className="mr-2 h-4 w-4" />
|
<PlusCircle className="mr-2 h-4 w-4" />
|
||||||
新建申请
|
{t("changes.newRequest")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,10 +72,10 @@ export default async function AdminSchedulingChangesPage({
|
|||||||
{items.length === 0 && !status && !classId ? (
|
{items.length === 0 && !status && !classId ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={ClipboardList}
|
icon={ClipboardList}
|
||||||
title="暂无课表变更申请"
|
title={t("changes.noChangesTitle")}
|
||||||
description="系统中尚未产生任何课表变更申请。"
|
description={t("changes.noChangesDescription")}
|
||||||
action={{
|
action={{
|
||||||
label: "新建申请",
|
label: t("changes.newRequest"),
|
||||||
href: "/teacher/schedule-changes",
|
href: "/teacher/schedule-changes",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -79,15 +84,15 @@ export default async function AdminSchedulingChangesPage({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<h3 className="text-lg font-semibold">冲突检测</h3>
|
<h3 className="text-lg font-semibold">{t("changes.conflictDetection")}</h3>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
检测现有班级课表中的时间重叠。
|
{t("changes.conflictDetectionDescription")}
|
||||||
</p>
|
</p>
|
||||||
{classOptions.length === 0 ? (
|
{classOptions.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={ClipboardList}
|
icon={ClipboardList}
|
||||||
title="暂无可用班级"
|
title={t("changes.noClassesTitle")}
|
||||||
description="请先创建班级,再进行冲突检测。"
|
description={t("changes.noClassesDescription")}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ScheduleConflictsView classes={classOptions} />
|
<ScheduleConflictsView classes={classOptions} />
|
||||||
@@ -95,9 +100,9 @@ export default async function AdminSchedulingChangesPage({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<h3 className="text-lg font-semibold">课表网格</h3>
|
<h3 className="text-lg font-semibold">{t("changes.scheduleGrid")}</h3>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
按班级查看当前课表分布。
|
{t("changes.scheduleGridDescription")}
|
||||||
</p>
|
</p>
|
||||||
<ScheduleGridView entries={scheduleEntries} classes={classOptions} />
|
<ScheduleGridView entries={scheduleEntries} classes={classOptions} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { CalendarCog, ClipboardList } from "lucide-react"
|
import { CalendarCog, ClipboardList } from "lucide-react"
|
||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -11,14 +12,18 @@ import {
|
|||||||
} from "@/modules/scheduling/data-access"
|
} from "@/modules/scheduling/data-access"
|
||||||
import { SchedulingRulesForm } from "@/modules/scheduling/components/scheduling-rules-form"
|
import { SchedulingRulesForm } from "@/modules/scheduling/components/scheduling-rules-form"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "排课规则 - Next_Edu",
|
const t = await getTranslations("scheduling")
|
||||||
description: "配置每日课时上限、课间窗口与均衡偏好",
|
return {
|
||||||
|
title: `${t("rules.title")} - Next_Edu`,
|
||||||
|
description: t("rules.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function AdminSchedulingRulesPage(): Promise<JSX.Element> {
|
export default async function AdminSchedulingRulesPage(): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("scheduling")
|
||||||
await requirePermission(Permissions.SCHEDULE_ADJUST)
|
await requirePermission(Permissions.SCHEDULE_ADJUST)
|
||||||
const [classes, existingRules] = await Promise.all([
|
const [classes, existingRules] = await Promise.all([
|
||||||
getAdminClassesForScheduling(),
|
getAdminClassesForScheduling(),
|
||||||
@@ -30,17 +35,15 @@ export default async function AdminSchedulingRulesPage(): Promise<JSX.Element> {
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">排课规则</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("rules.title")}</h2>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">{t("rules.description")}</p>
|
||||||
配置每日课时上限、课间窗口与均衡偏好。
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{classOptions.length === 0 ? (
|
{classOptions.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={ClipboardList}
|
icon={ClipboardList}
|
||||||
title="暂无可用班级"
|
title={t("rules.noClassesTitle")}
|
||||||
description="请先创建班级,再配置排课规则。"
|
description={t("rules.noClassesDescription")}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<SchedulingRulesForm classes={classOptions} existingRules={existingRules} />
|
<SchedulingRulesForm classes={classOptions} existingRules={existingRules} />
|
||||||
@@ -48,7 +51,7 @@ export default async function AdminSchedulingRulesPage(): Promise<JSX.Element> {
|
|||||||
|
|
||||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||||
<CalendarCog className="h-4 w-4" />
|
<CalendarCog className="h-4 w-4" />
|
||||||
<span>提示:未选择具体班级时保存的规则将作为全局默认。</span>
|
<span>{t("rules.hint")}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Link from "next/link"
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
import { BarChart3 } from "lucide-react"
|
import { BarChart3 } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -9,6 +10,7 @@ import { getGrades } from "@/modules/school/data-access"
|
|||||||
import { getGradeHomeworkInsights } from "@/modules/classes/data-access"
|
import { getGradeHomeworkInsights } from "@/modules/classes/data-access"
|
||||||
import { getSchoolWideGradeSummary } from "@/modules/grades/data-access-analytics"
|
import { getSchoolWideGradeSummary } from "@/modules/grades/data-access-analytics"
|
||||||
import { SchoolWideSummaryCard } from "@/modules/grades/components/school-wide-summary-card"
|
import { SchoolWideSummaryCard } from "@/modules/grades/components/school-wide-summary-card"
|
||||||
|
import { GradeInsightsFilters } from "@/modules/school/components/grade-insights-filters"
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
import { StatCard } from "@/shared/components/ui/stat-card"
|
import { StatCard } from "@/shared/components/ui/stat-card"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
||||||
@@ -18,19 +20,23 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@
|
|||||||
import { formatDate, formatNumber } from "@/shared/lib/utils"
|
import { formatDate, formatNumber } from "@/shared/lib/utils"
|
||||||
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
|
||||||
title: "年级作业洞察 - Next_Edu",
|
|
||||||
description: "按年级聚合的作业统计与班级排名",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
const t = await getTranslations("school")
|
||||||
|
return {
|
||||||
|
title: `${t("grades.gradeInsights.title")} - Next_Edu`,
|
||||||
|
description: t("grades.gradeInsights.description"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default async function AdminGradeInsightsPage({
|
export default async function AdminGradeInsightsPage({
|
||||||
searchParams,
|
searchParams,
|
||||||
}: {
|
}: {
|
||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}): Promise<JSX.Element> {
|
}): Promise<JSX.Element> {
|
||||||
const ctx = await requirePermission(Permissions.SCHOOL_MANAGE)
|
const ctx = await requirePermission(Permissions.SCHOOL_MANAGE)
|
||||||
|
const t = await getTranslations("school")
|
||||||
const params = await searchParams
|
const params = await searchParams
|
||||||
const gradeId = getParam(params, "gradeId")
|
const gradeId = getParam(params, "gradeId")
|
||||||
const selected = gradeId && gradeId !== "all" ? gradeId : ""
|
const selected = gradeId && gradeId !== "all" ? gradeId : ""
|
||||||
@@ -43,15 +49,22 @@ export default async function AdminGradeInsightsPage({
|
|||||||
getSchoolWideGradeSummary(ctx.dataScope),
|
getSchoolWideGradeSummary(ctx.dataScope),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const buildHref = (gId: string): string => {
|
||||||
|
const p = new URLSearchParams()
|
||||||
|
if (gId && gId !== "all") p.set("gradeId", gId)
|
||||||
|
const qs = p.toString()
|
||||||
|
return qs ? `/admin/school/grades/insights?${qs}` : "/admin/school/grades/insights"
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="flex flex-col gap-4 md:flex-row md:items-end md:justify-between">
|
<div className="flex flex-col gap-4 md:flex-row md:items-end md:justify-between">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">年级作业洞察</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("grades.gradeInsights.title")}</h2>
|
||||||
<p className="text-muted-foreground">按年级聚合的作业统计与班级排名。</p>
|
<p className="text-muted-foreground">{t("grades.gradeInsights.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<Button asChild variant="outline">
|
<Button asChild variant="outline">
|
||||||
<Link href="/admin/school/grades">管理年级</Link>
|
<Link href="/admin/school/grades">{t("grades.gradeInsights.manageGrades")}</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -60,86 +73,57 @@ export default async function AdminGradeInsightsPage({
|
|||||||
<SchoolWideSummaryCard summary={schoolWideSummary} />
|
<SchoolWideSummaryCard summary={schoolWideSummary} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Card className="shadow-none">
|
{/* 年级筛选:ChipNav 即时切换,无整页刷新 */}
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
<GradeInsightsFilters
|
||||||
<CardTitle className="text-base">筛选</CardTitle>
|
grades={grades.map((g) => ({ id: g.id, name: g.name, schoolName: g.school.name }))}
|
||||||
<Badge variant="secondary" className="tabular-nums">
|
currentGradeId={selected || "all"}
|
||||||
{grades.length}
|
buildHref={buildHref}
|
||||||
</Badge>
|
/>
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<form
|
|
||||||
action="/admin/school/grades/insights"
|
|
||||||
method="get"
|
|
||||||
className="flex flex-col gap-3 md:flex-row md:items-center"
|
|
||||||
>
|
|
||||||
<label htmlFor="grade-filter" className="text-sm font-medium">
|
|
||||||
年级
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
id="grade-filter"
|
|
||||||
name="gradeId"
|
|
||||||
defaultValue={selected || "all"}
|
|
||||||
className="h-10 w-full rounded-md border bg-background px-3 text-sm md:w-80"
|
|
||||||
>
|
|
||||||
<option value="all">请选择年级</option>
|
|
||||||
{grades.map((g) => (
|
|
||||||
<option key={g.id} value={g.id}>
|
|
||||||
{g.school.name} / {g.name}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
<Button type="submit" className="md:ml-2">
|
|
||||||
应用
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{!selected ? (
|
{!selected ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title="请选择年级以查看洞察"
|
title={t("grades.gradeInsights.selectToView")}
|
||||||
description="选择一个年级,查看最新作业与历史成绩统计。"
|
description={t("grades.gradeInsights.selectToViewDescription")}
|
||||||
className="h-80 bg-card"
|
className="h-80 bg-card"
|
||||||
/>
|
/>
|
||||||
) : !insights ? (
|
) : !insights ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title="年级未找到"
|
title={t("grades.gradeInsights.notFound")}
|
||||||
description="该年级可能不存在或无可访问数据。"
|
description={t("grades.gradeInsights.notFoundDescription")}
|
||||||
className="h-80 bg-card"
|
className="h-80 bg-card"
|
||||||
/>
|
/>
|
||||||
) : insights.assignments.length === 0 ? (
|
) : insights.assignments.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title="该年级暂无作业数据"
|
title={t("grades.gradeInsights.noData")}
|
||||||
description="尚未向该年级学生布置任何作业。"
|
description={t("grades.gradeInsights.noDataDescription")}
|
||||||
className="h-80 bg-card"
|
className="h-80 bg-card"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div className="grid gap-4 md:grid-cols-4">
|
<div className="grid gap-4 md:grid-cols-4">
|
||||||
<StatCard
|
<StatCard
|
||||||
title="班级数"
|
title={t("grades.gradeInsights.classes")}
|
||||||
value={insights.classCount}
|
value={insights.classCount}
|
||||||
description={`${insights.grade.school.name} / ${insights.grade.name}`}
|
description={`${insights.grade.school.name} / ${insights.grade.name}`}
|
||||||
valueClassName="tabular-nums"
|
valueClassName="tabular-nums"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="学生数"
|
title={t("grades.gradeInsights.students")}
|
||||||
value={insights.studentCounts.total}
|
value={insights.studentCounts.total}
|
||||||
description={`在读 ${insights.studentCounts.active} • 停用 ${insights.studentCounts.inactive}`}
|
description={`${t("grades.gradeInsights.active")} ${insights.studentCounts.active} • ${t("grades.gradeInsights.inactive")} ${insights.studentCounts.inactive}`}
|
||||||
valueClassName="tabular-nums"
|
valueClassName="tabular-nums"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="总体均分"
|
title={t("grades.gradeInsights.overallAvg")}
|
||||||
value={formatNumber(insights.overallScores.avg)}
|
value={formatNumber(insights.overallScores.avg)}
|
||||||
description="基于已批改作业"
|
description="-"
|
||||||
valueClassName="tabular-nums"
|
valueClassName="tabular-nums"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title="最新均分"
|
title={t("grades.gradeInsights.latestAvg")}
|
||||||
value={formatNumber(insights.latest?.scoreStats.avg ?? null)}
|
value={formatNumber(insights.latest?.scoreStats.avg ?? null)}
|
||||||
description={insights.latest?.title ?? "-"}
|
description={insights.latest?.title ?? "-"}
|
||||||
valueClassName="tabular-nums"
|
valueClassName="tabular-nums"
|
||||||
@@ -148,87 +132,93 @@ export default async function AdminGradeInsightsPage({
|
|||||||
|
|
||||||
<Card className="shadow-none">
|
<Card className="shadow-none">
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
||||||
<CardTitle className="text-base">最新作业</CardTitle>
|
<CardTitle className="text-base">{t("grades.gradeInsights.homeworkTimeline")}</CardTitle>
|
||||||
<Badge variant="secondary" className="tabular-nums">
|
<Badge variant="secondary" className="tabular-nums">
|
||||||
{insights.assignments.length}
|
{insights.assignments.length}
|
||||||
</Badge>
|
</Badge>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="rounded-md border">
|
<div className="rounded-md border">
|
||||||
<Table>
|
{/* v4-P1-10: 移动端表格水平滚动 */}
|
||||||
<TableHeader>
|
<div className="overflow-x-auto">
|
||||||
<TableRow className="bg-muted/50">
|
<Table>
|
||||||
<TableHead>作业</TableHead>
|
<TableHeader>
|
||||||
<TableHead>状态</TableHead>
|
<TableRow className="bg-muted/50">
|
||||||
<TableHead>创建时间</TableHead>
|
<TableHead>{t("grades.gradeInsights.assignment")}</TableHead>
|
||||||
<TableHead className="text-right">目标数</TableHead>
|
<TableHead>{t("grades.gradeInsights.status")}</TableHead>
|
||||||
<TableHead className="text-right">提交数</TableHead>
|
<TableHead>{t("grades.gradeInsights.created")}</TableHead>
|
||||||
<TableHead className="text-right">已批改</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.targeted")}</TableHead>
|
||||||
<TableHead className="text-right">均分</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.submitted")}</TableHead>
|
||||||
<TableHead className="text-right">中位数</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.graded")}</TableHead>
|
||||||
</TableRow>
|
<TableHead className="text-right">{t("grades.gradeInsights.avg")}</TableHead>
|
||||||
</TableHeader>
|
<TableHead className="text-right">{t("grades.gradeInsights.median")}</TableHead>
|
||||||
<TableBody>
|
|
||||||
{insights.assignments.map((a) => (
|
|
||||||
<TableRow key={a.assignmentId}>
|
|
||||||
<TableCell className="font-medium">{a.title}</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Badge variant="secondary" className="capitalize">
|
|
||||||
{a.status}
|
|
||||||
</Badge>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className="text-muted-foreground">{formatDate(a.createdAt)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{a.targetCount}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{a.submittedCount}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{a.gradedCount}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatNumber(a.scoreStats.avg)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatNumber(a.scoreStats.median)}</TableCell>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
</TableHeader>
|
||||||
</TableBody>
|
<TableBody>
|
||||||
</Table>
|
{insights.assignments.map((a) => (
|
||||||
|
<TableRow key={a.assignmentId}>
|
||||||
|
<TableCell className="font-medium">{a.title}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Badge variant="secondary" className="capitalize">
|
||||||
|
{a.status}
|
||||||
|
</Badge>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="text-muted-foreground">{formatDate(a.createdAt)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{a.targetCount}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{a.submittedCount}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{a.gradedCount}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(a.scoreStats.avg)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(a.scoreStats.median)}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card className="shadow-none">
|
<Card className="shadow-none">
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
||||||
<CardTitle className="text-base">班级排名</CardTitle>
|
<CardTitle className="text-base">{t("grades.gradeInsights.classRanking")}</CardTitle>
|
||||||
<Badge variant="secondary" className="tabular-nums">
|
<Badge variant="secondary" className="tabular-nums">
|
||||||
{insights.classes.length}
|
{insights.classes.length}
|
||||||
</Badge>
|
</Badge>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="rounded-md border">
|
<div className="rounded-md border">
|
||||||
<Table>
|
{/* v4-P1-10: 移动端表格水平滚动 */}
|
||||||
<TableHeader>
|
<div className="overflow-x-auto">
|
||||||
<TableRow className="bg-muted/50">
|
<Table>
|
||||||
<TableHead>班级</TableHead>
|
<TableHeader>
|
||||||
<TableHead className="text-right">学生数</TableHead>
|
<TableRow className="bg-muted/50">
|
||||||
<TableHead className="text-right">最新均分</TableHead>
|
<TableHead>{t("grades.gradeInsights.class")}</TableHead>
|
||||||
<TableHead className="text-right">上次均分</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.students")}</TableHead>
|
||||||
<TableHead className="text-right">Δ</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.latestAvgCol")}</TableHead>
|
||||||
<TableHead className="text-right">总体均分</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.prevAvg")}</TableHead>
|
||||||
</TableRow>
|
<TableHead className="text-right">{t("grades.gradeInsights.delta")}</TableHead>
|
||||||
</TableHeader>
|
<TableHead className="text-right">{t("grades.gradeInsights.overallAvgCol")}</TableHead>
|
||||||
<TableBody>
|
|
||||||
{insights.classes.map((c) => (
|
|
||||||
<TableRow key={c.class.id}>
|
|
||||||
<TableCell className="font-medium">
|
|
||||||
{c.class.name}
|
|
||||||
{c.class.homeroom ? (
|
|
||||||
<span className="text-muted-foreground"> • {c.class.homeroom}</span>
|
|
||||||
) : null}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{c.studentCounts.total}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatNumber(c.latestAvg)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatNumber(c.prevAvg)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatNumber(c.deltaAvg)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatNumber(c.overallScores.avg)}</TableCell>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
</TableHeader>
|
||||||
</TableBody>
|
<TableBody>
|
||||||
</Table>
|
{insights.classes.map((c) => (
|
||||||
|
<TableRow key={c.class.id}>
|
||||||
|
<TableCell className="font-medium">
|
||||||
|
{c.class.name}
|
||||||
|
{c.class.homeroom ? (
|
||||||
|
<span className="text-muted-foreground"> • {c.class.homeroom}</span>
|
||||||
|
) : null}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{c.studentCounts.total}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(c.latestAvg)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(c.prevAvg)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(c.deltaAvg)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(c.overallScores.avg)}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { requirePermission } from "@/shared/lib/auth-guard"
|
|||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
import { GradesClient } from "@/modules/school/components/grades-view"
|
import { GradesClient } from "@/modules/school/components/grades-view"
|
||||||
import { SchoolErrorBoundary } from "@/modules/school/components/school-error-boundary"
|
import { SchoolErrorBoundary } from "@/modules/school/components/school-error-boundary"
|
||||||
import { getGrades, getSchools, getStaffOptions } from "@/modules/school/data-access"
|
import { getGrades, getSchools, getStaffOptions, getGradeOverviewStats } from "@/modules/school/data-access"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
@@ -21,7 +21,12 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
export default async function AdminGradesPage(): Promise<JSX.Element> {
|
export default async function AdminGradesPage(): Promise<JSX.Element> {
|
||||||
await requirePermission(Permissions.SCHOOL_MANAGE)
|
await requirePermission(Permissions.SCHOOL_MANAGE)
|
||||||
const t = await getTranslations("school")
|
const t = await getTranslations("school")
|
||||||
const [grades, schools, staff] = await Promise.all([getGrades(), getSchools(), getStaffOptions()])
|
const [grades, schools, staff, gradeStats] = await Promise.all([
|
||||||
|
getGrades(),
|
||||||
|
getSchools(),
|
||||||
|
getStaffOptions(),
|
||||||
|
getGradeOverviewStats(),
|
||||||
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
@@ -30,7 +35,7 @@ export default async function AdminGradesPage(): Promise<JSX.Element> {
|
|||||||
<p className="text-muted-foreground">{t("grades.description")}</p>
|
<p className="text-muted-foreground">{t("grades.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<SchoolErrorBoundary>
|
<SchoolErrorBoundary>
|
||||||
<GradesClient grades={grades} schools={schools} staff={staff} />
|
<GradesClient grades={grades} schools={schools} staff={staff} gradeStats={gradeStats} />
|
||||||
</SchoolErrorBoundary>
|
</SchoolErrorBoundary>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
import { AdminSettingsView } from "@/modules/settings/components/admin-settings-view"
|
import { AdminSettingsView } from "@/modules/settings/components/admin-settings-view"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "系统设置 - Next_Edu",
|
const t = await getTranslations("settings")
|
||||||
description: "管理系统基础信息与运行参数",
|
return {
|
||||||
|
title: `${t("admin.title")} - Next_Edu`,
|
||||||
|
description: t("admin.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { Metadata } from "next"
|
import { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { ArrowLeft, Users, FileSpreadsheet, Info } from "lucide-react"
|
import { ArrowLeft, Users, FileSpreadsheet, Info } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -17,14 +18,18 @@ import {
|
|||||||
} from "@/shared/components/ui/table"
|
} from "@/shared/components/ui/table"
|
||||||
import { UserImportDialog } from "@/modules/users/components/user-import-dialog"
|
import { UserImportDialog } from "@/modules/users/components/user-import-dialog"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "批量导入用户 - Next_Edu",
|
const t = await getTranslations("users")
|
||||||
description: "通过 Excel 批量导入用户",
|
return {
|
||||||
|
title: `${t("import.title")} - Next_Edu`,
|
||||||
|
description: t("import.description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function UserImportPage(): Promise<JSX.Element> {
|
export default async function UserImportPage(): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("users")
|
||||||
await requirePermission(Permissions.USER_MANAGE)
|
await requirePermission(Permissions.USER_MANAGE)
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex-1 flex-col space-y-6 p-8 md:flex">
|
<div className="h-full flex-1 flex-col space-y-6 p-8 md:flex">
|
||||||
@@ -34,13 +39,13 @@ export default async function UserImportPage(): Promise<JSX.Element> {
|
|||||||
<Button asChild variant="ghost" size="sm">
|
<Button asChild variant="ghost" size="sm">
|
||||||
<Link href="/admin/dashboard">
|
<Link href="/admin/dashboard">
|
||||||
<ArrowLeft className="mr-1 h-4 w-4" />
|
<ArrowLeft className="mr-1 h-4 w-4" />
|
||||||
返回
|
{t("import.back")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">批量导入用户</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("import.title")}</h2>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-muted-foreground mt-1">
|
<p className="text-muted-foreground mt-1">
|
||||||
通过 Excel 文件批量创建用户账号,支持学生自动加入班级。
|
{t("import.subtitle")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<UserImportDialog />
|
<UserImportDialog />
|
||||||
@@ -51,26 +56,26 @@ export default async function UserImportPage(): Promise<JSX.Element> {
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<FileSpreadsheet className="h-5 w-5 text-primary" />
|
<FileSpreadsheet className="h-5 w-5 text-primary" />
|
||||||
<CardTitle className="text-base">导入说明</CardTitle>
|
<CardTitle className="text-base">{t("import.instructionsTitle")}</CardTitle>
|
||||||
</div>
|
</div>
|
||||||
<CardDescription>使用 Excel 批量导入用户的步骤</CardDescription>
|
<CardDescription>{t("import.instructionsDescription")}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-3 text-sm">
|
<CardContent className="space-y-3 text-sm">
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">1</span>
|
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">1</span>
|
||||||
<p>点击「批量导入用户」按钮,下载导入模板。</p>
|
<p>{t("import.step1")}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">2</span>
|
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">2</span>
|
||||||
<p>按模板格式填写用户信息(姓名、邮箱、角色、手机、班级邀请码)。</p>
|
<p>{t("import.step2")}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">3</span>
|
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">3</span>
|
||||||
<p>上传填写好的 Excel 文件,系统将解析并预览数据。</p>
|
<p>{t("import.step3")}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">4</span>
|
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">4</span>
|
||||||
<p>确认预览数据无误后,点击「确认导入」完成批量创建。</p>
|
<p>{t("import.step4")}</p>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -79,17 +84,17 @@ export default async function UserImportPage(): Promise<JSX.Element> {
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Info className="h-5 w-5 text-muted-foreground" />
|
<Info className="h-5 w-5 text-muted-foreground" />
|
||||||
<CardTitle className="text-base">注意事项</CardTitle>
|
<CardTitle className="text-base">{t("import.notesTitle")}</CardTitle>
|
||||||
</div>
|
</div>
|
||||||
<CardDescription>导入前请仔细阅读</CardDescription>
|
<CardDescription>{t("import.notesDescription")}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-2 text-sm text-muted-foreground">
|
<CardContent className="space-y-2 text-sm text-muted-foreground">
|
||||||
<p>• 默认密码为 <code className="rounded bg-muted px-1 py-0.5 text-xs">123456</code>,请提示用户首次登录后修改。</p>
|
<p>{t("import.note1")}</p>
|
||||||
<p>• 邮箱必须唯一,重复邮箱将被跳过并记录在错误报告中。</p>
|
<p>{t("import.note2")}</p>
|
||||||
<p>• 角色可选:admin / teacher / student / parent / grade_head / teaching_head。</p>
|
<p>{t("import.note3")}</p>
|
||||||
<p>• 班级邀请码仅对 student 角色有效,填写后学生将自动加入对应班级。</p>
|
<p>{t("import.note4")}</p>
|
||||||
<p>• 单次最多导入 10MB 的文件,建议单次不超过 500 条记录。</p>
|
<p>{t("import.note5")}</p>
|
||||||
<p>• 导入完成后将显示成功数、失败数及详细错误信息。</p>
|
<p>{t("import.note6")}</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
@@ -98,45 +103,45 @@ export default async function UserImportPage(): Promise<JSX.Element> {
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Users className="h-5 w-5 text-primary" />
|
<Users className="h-5 w-5 text-primary" />
|
||||||
<CardTitle className="text-base">模板字段说明</CardTitle>
|
<CardTitle className="text-base">{t("import.templateTitle")}</CardTitle>
|
||||||
</div>
|
</div>
|
||||||
<CardDescription>Excel 模板各列含义与要求</CardDescription>
|
<CardDescription>{t("import.templateDescription")}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableHead>列名</TableHead>
|
<TableHead>{t("import.columnName")}</TableHead>
|
||||||
<TableHead>是否必填</TableHead>
|
<TableHead>{t("import.columnRequired")}</TableHead>
|
||||||
<TableHead>说明</TableHead>
|
<TableHead>{t("import.columnDescription")}</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell className="font-medium">姓名</TableCell>
|
<TableCell className="font-medium">{t("import.fieldName")}</TableCell>
|
||||||
<TableCell>必填</TableCell>
|
<TableCell>{t("import.fieldNameRequired")}</TableCell>
|
||||||
<TableCell className="text-muted-foreground">用户姓名</TableCell>
|
<TableCell className="text-muted-foreground">{t("import.fieldNameDescription")}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell className="font-medium">邮箱</TableCell>
|
<TableCell className="font-medium">{t("import.fieldEmail")}</TableCell>
|
||||||
<TableCell>必填</TableCell>
|
<TableCell>{t("import.fieldEmailRequired")}</TableCell>
|
||||||
<TableCell className="text-muted-foreground">登录账号,需符合邮箱格式且唯一</TableCell>
|
<TableCell className="text-muted-foreground">{t("import.fieldEmailDescription")}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell className="font-medium">角色</TableCell>
|
<TableCell className="font-medium">{t("import.fieldRole")}</TableCell>
|
||||||
<TableCell>必填</TableCell>
|
<TableCell>{t("import.fieldRoleRequired")}</TableCell>
|
||||||
<TableCell className="text-muted-foreground">admin / teacher / student / parent / grade_head / teaching_head</TableCell>
|
<TableCell className="text-muted-foreground">{t("import.fieldRoleDescription")}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell className="font-medium">手机</TableCell>
|
<TableCell className="font-medium">{t("import.fieldPhone")}</TableCell>
|
||||||
<TableCell>选填</TableCell>
|
<TableCell>{t("import.fieldPhoneRequired")}</TableCell>
|
||||||
<TableCell className="text-muted-foreground">联系电话</TableCell>
|
<TableCell className="text-muted-foreground">{t("import.fieldPhoneDescription")}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell className="font-medium">班级邀请码</TableCell>
|
<TableCell className="font-medium">{t("import.fieldInviteCode")}</TableCell>
|
||||||
<TableCell>选填</TableCell>
|
<TableCell>{t("import.fieldInviteCodeRequired")}</TableCell>
|
||||||
<TableCell className="text-muted-foreground">仅 student 角色有效,6 位邀请码</TableCell>
|
<TableCell className="text-muted-foreground">{t("import.fieldInviteCodeDescription")}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -7,9 +8,12 @@ import { getSearchParam, type SearchParams } from "@/shared/lib/utils"
|
|||||||
import { getAdminUsers, getAdminUserRoles } from "@/modules/users/data-access"
|
import { getAdminUsers, getAdminUserRoles } from "@/modules/users/data-access"
|
||||||
import { AdminUsersView } from "@/modules/users/components/admin-users-view"
|
import { AdminUsersView } from "@/modules/users/components/admin-users-view"
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
title: "用户管理 - Next_Edu",
|
const t = await getTranslations("users")
|
||||||
description: "管理系统所有用户",
|
return {
|
||||||
|
title: `${t("title")} - Next_Edu`,
|
||||||
|
description: t("description"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|||||||
42
src/app/(dashboard)/management/grade/dashboard/loading.tsx
Normal file
42
src/app/(dashboard)/management/grade/dashboard/loading.tsx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { Card, CardContent, CardHeader } from "@/shared/components/ui/card"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function ManagementGradeDashboardLoading() {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-48" />
|
||||||
|
<Skeleton className="h-4 w-64" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Skeleton className="h-10 w-full max-w-md" />
|
||||||
|
|
||||||
|
<Skeleton className="h-10 w-full max-w-2xl" />
|
||||||
|
|
||||||
|
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||||
|
{Array.from({ length: 4 }).map((_, i) => (
|
||||||
|
<Card key={i}>
|
||||||
|
<CardHeader className="pb-2">
|
||||||
|
<Skeleton className="h-4 w-24" />
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<Skeleton className="h-8 w-16" />
|
||||||
|
<Skeleton className="mt-2 h-3 w-28" />
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<Skeleton className="h-5 w-32" />
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="space-y-3">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-12 w-full" />
|
||||||
|
))}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
178
src/app/(dashboard)/management/grade/dashboard/page.tsx
Normal file
178
src/app/(dashboard)/management/grade/dashboard/page.tsx
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
import type { Metadata } from "next"
|
||||||
|
import type { JSX } from "react"
|
||||||
|
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
|
import { getTeacherIdForMutations } from "@/modules/classes/data-access"
|
||||||
|
import { getGradeHomeworkInsights } from "@/modules/classes/data-access"
|
||||||
|
import { getGradesForStaff } from "@/modules/school/data-access"
|
||||||
|
import { getGradeDistributionByGradeId } from "@/modules/grades/data-access-analytics"
|
||||||
|
import { getExamsByGradeId } from "@/modules/exams/data-access"
|
||||||
|
import { getGradeCoursePlanProgress } from "@/modules/course-plans/data-access"
|
||||||
|
import { GradeInsightsFilters } from "@/modules/school/components/grade-insights-filters"
|
||||||
|
import { GradeDistributionPanel } from "@/modules/school/components/grade-dashboard/grade-distribution-panel"
|
||||||
|
import { GradeHomeworkPanel } from "@/modules/school/components/grade-dashboard/grade-homework-panel"
|
||||||
|
import { GradeExamsPanel } from "@/modules/school/components/grade-dashboard/grade-exams-panel"
|
||||||
|
import { GradeProgressPanel } from "@/modules/school/components/grade-dashboard/grade-progress-panel"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
import { ChipNav } from "@/shared/components/ui/chip-nav"
|
||||||
|
import { BarChart3 } from "lucide-react"
|
||||||
|
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
const TAB_OPTIONS = [
|
||||||
|
{ id: "distribution", name: "" },
|
||||||
|
{ id: "homework", name: "" },
|
||||||
|
{ id: "exams", name: "" },
|
||||||
|
{ id: "progress", name: "" },
|
||||||
|
] as const
|
||||||
|
|
||||||
|
type TabId = (typeof TAB_OPTIONS)[number]["id"]
|
||||||
|
|
||||||
|
const isTabId = (v: string): v is TabId =>
|
||||||
|
v === "distribution" || v === "homework" || v === "exams" || v === "progress"
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
const t = await getTranslations("school")
|
||||||
|
return {
|
||||||
|
title: `${t("grades.gradeDashboard.title")} - Next_Edu`,
|
||||||
|
description: t("grades.gradeDashboard.description"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function GradeDashboardPage({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<SearchParams>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
const ctx = await requirePermission(Permissions.GRADE_RECORD_READ)
|
||||||
|
const t = await getTranslations("school")
|
||||||
|
const params = await searchParams
|
||||||
|
const gradeId = getParam(params, "gradeId")
|
||||||
|
const tabRaw = getParam(params, "tab") || "distribution"
|
||||||
|
const tab: TabId = isTabId(tabRaw) ? tabRaw : "distribution"
|
||||||
|
|
||||||
|
const teacherId = await getTeacherIdForMutations()
|
||||||
|
const grades = await getGradesForStaff(teacherId)
|
||||||
|
const allowedIds = new Set(grades.map((g) => g.id))
|
||||||
|
const selected = gradeId && gradeId !== "all" && allowedIds.has(gradeId) ? gradeId : ""
|
||||||
|
|
||||||
|
const buildHref = (gId: string): string => {
|
||||||
|
const p = new URLSearchParams()
|
||||||
|
if (gId && gId !== "all") p.set("gradeId", gId)
|
||||||
|
if (tab !== "distribution") p.set("tab", tab)
|
||||||
|
const qs = p.toString()
|
||||||
|
return qs ? `/management/grade/dashboard?${qs}` : "/management/grade/dashboard"
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildTabHref = (tId: string): string => {
|
||||||
|
const p = new URLSearchParams()
|
||||||
|
if (selected) p.set("gradeId", selected)
|
||||||
|
if (tId !== "distribution") p.set("tab", tId)
|
||||||
|
const qs = p.toString()
|
||||||
|
return qs ? `/management/grade/dashboard?${qs}` : "/management/grade/dashboard"
|
||||||
|
}
|
||||||
|
|
||||||
|
const tabOptions = TAB_OPTIONS.map((o) => ({
|
||||||
|
id: o.id,
|
||||||
|
name: t(`grades.gradeDashboard.tabs.${o.id}` as const),
|
||||||
|
}))
|
||||||
|
|
||||||
|
if (grades.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<h2 className="text-2xl font-bold tracking-tight">{t("grades.gradeDashboard.title")}</h2>
|
||||||
|
<p className="text-muted-foreground">{t("grades.gradeDashboard.description")}</p>
|
||||||
|
</div>
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("grades.gradeDashboard.selectToView")}
|
||||||
|
description={t("grades.gradeDashboard.selectToViewDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch data for the active tab only
|
||||||
|
let distributionData = null
|
||||||
|
let homeworkData = null
|
||||||
|
let examsData = null
|
||||||
|
let progressData = null
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
if (tab === "distribution") {
|
||||||
|
distributionData = await getGradeDistributionByGradeId({
|
||||||
|
gradeId: selected,
|
||||||
|
scope: ctx.dataScope,
|
||||||
|
})
|
||||||
|
} else if (tab === "homework") {
|
||||||
|
homeworkData = await getGradeHomeworkInsights({ gradeId: selected, limit: 50 })
|
||||||
|
} else if (tab === "exams") {
|
||||||
|
examsData = await getExamsByGradeId({ gradeId: selected, scope: ctx.dataScope })
|
||||||
|
} else if (tab === "progress") {
|
||||||
|
progressData = await getGradeCoursePlanProgress({ gradeId: selected })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<h2 className="text-2xl font-bold tracking-tight">{t("grades.gradeDashboard.title")}</h2>
|
||||||
|
<p className="text-muted-foreground">{t("grades.gradeDashboard.description")}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<GradeInsightsFilters
|
||||||
|
grades={grades.map((g) => ({ id: g.id, name: g.name, schoolName: g.school.name }))}
|
||||||
|
currentGradeId={selected || "all"}
|
||||||
|
buildHref={buildHref}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{!selected ? (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("grades.gradeDashboard.selectToView")}
|
||||||
|
description={t("grades.gradeDashboard.selectToViewDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-6">
|
||||||
|
<ChipNav
|
||||||
|
options={tabOptions}
|
||||||
|
currentId={tab}
|
||||||
|
buildHref={buildTabHref}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{tab === "distribution" && distributionData && (
|
||||||
|
<GradeDistributionPanel data={distributionData} />
|
||||||
|
)}
|
||||||
|
{tab === "homework" && homeworkData && (
|
||||||
|
<GradeHomeworkPanel data={homeworkData} />
|
||||||
|
)}
|
||||||
|
{tab === "exams" && examsData && (
|
||||||
|
<GradeExamsPanel data={examsData} />
|
||||||
|
)}
|
||||||
|
{tab === "progress" && progressData && (
|
||||||
|
<GradeProgressPanel data={progressData} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Fallback: data was null (e.g. homework insights returned null) */}
|
||||||
|
{((tab === "distribution" && !distributionData) ||
|
||||||
|
(tab === "homework" && !homeworkData) ||
|
||||||
|
(tab === "exams" && !examsData) ||
|
||||||
|
(tab === "progress" && !progressData)) && (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("grades.gradeDashboard.noData")}
|
||||||
|
description={t("grades.gradeDashboard.noDataDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -7,25 +7,23 @@ import { Permissions } from "@/shared/types/permissions"
|
|||||||
import { getTeacherIdForMutations } from "@/modules/classes/data-access"
|
import { getTeacherIdForMutations } from "@/modules/classes/data-access"
|
||||||
import { getGradeHomeworkInsights } from "@/modules/classes/data-access"
|
import { getGradeHomeworkInsights } from "@/modules/classes/data-access"
|
||||||
import { getGradesForStaff } from "@/modules/school/data-access"
|
import { getGradesForStaff } from "@/modules/school/data-access"
|
||||||
|
import { GradeInsightsFilters } from "@/modules/school/components/grade-insights-filters"
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
import { StatCard } from "@/shared/components/ui/stat-card"
|
import { StatCard } from "@/shared/components/ui/stat-card"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
||||||
import { Badge } from "@/shared/components/ui/badge"
|
import { Badge } from "@/shared/components/ui/badge"
|
||||||
import { Button } from "@/shared/components/ui/button"
|
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/shared/components/ui/table"
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/shared/components/ui/table"
|
||||||
import { BarChart3 } from "lucide-react"
|
import { BarChart3 } from "lucide-react"
|
||||||
import { formatDate } from "@/shared/lib/utils"
|
import { formatDate, formatNumber } from "@/shared/lib/utils"
|
||||||
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
const formatScore = (v: number | null, digits = 1) => (typeof v === "number" && Number.isFinite(v) ? v.toFixed(digits) : "-")
|
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
const t = await getTranslations("school")
|
const t = await getTranslations("school")
|
||||||
return {
|
return {
|
||||||
title: `${t("classManagement.grade.insights.title")} - Next_Edu`,
|
title: `${t("grades.gradeInsights.title")} - Next_Edu`,
|
||||||
description: t("classManagement.grade.insights.description"),
|
description: t("grades.gradeInsights.description"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,17 +40,24 @@ export default async function TeacherGradeInsightsPage({ searchParams }: { searc
|
|||||||
|
|
||||||
const insights = selected ? await getGradeHomeworkInsights({ gradeId: selected, limit: 50 }) : null
|
const insights = selected ? await getGradeHomeworkInsights({ gradeId: selected, limit: 50 }) : null
|
||||||
|
|
||||||
|
const buildHref = (gId: string): string => {
|
||||||
|
const p = new URLSearchParams()
|
||||||
|
if (gId && gId !== "all") p.set("gradeId", gId)
|
||||||
|
const qs = p.toString()
|
||||||
|
return qs ? `/management/grade/insights?${qs}` : "/management/grade/insights"
|
||||||
|
}
|
||||||
|
|
||||||
if (grades.length === 0) {
|
if (grades.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">{t("classManagement.grade.insights.title")}</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("grades.gradeInsights.title")}</h2>
|
||||||
<p className="text-muted-foreground">{t("classManagement.grade.insights.description")}</p>
|
<p className="text-muted-foreground">{t("grades.gradeInsights.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title={t("classManagement.grade.insights.noGrades")}
|
title={t("grades.gradeInsights.selectToView")}
|
||||||
description={t("classManagement.grade.insights.noGradesDescription")}
|
description={t("grades.gradeInsights.selectToViewDescription")}
|
||||||
className="h-[360px] bg-card"
|
className="h-[360px] bg-card"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -62,85 +67,62 @@ export default async function TeacherGradeInsightsPage({ searchParams }: { searc
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">{t("classManagement.grade.insights.title")}</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("grades.gradeInsights.title")}</h2>
|
||||||
<p className="text-muted-foreground">{t("classManagement.grade.insights.description")}</p>
|
<p className="text-muted-foreground">{t("grades.gradeInsights.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card className="shadow-none">
|
{/* 年级筛选:ChipNav 即时切换,无整页刷新 */}
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
<GradeInsightsFilters
|
||||||
<CardTitle className="text-base">{t("classManagement.grade.insights.filters")}</CardTitle>
|
grades={grades.map((g) => ({ id: g.id, name: g.name, schoolName: g.school.name }))}
|
||||||
<Badge variant="secondary" className="tabular-nums">
|
currentGradeId={selected || "all"}
|
||||||
{grades.length}
|
buildHref={buildHref}
|
||||||
</Badge>
|
/>
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<form action="/management/grade/insights" method="get" className="flex flex-col gap-3 md:flex-row md:items-center">
|
|
||||||
<label htmlFor="gradeId" className="text-sm font-medium">{t("classManagement.grade.insights.grade")}</label>
|
|
||||||
<select
|
|
||||||
id="gradeId"
|
|
||||||
name="gradeId"
|
|
||||||
defaultValue={selected || "all"}
|
|
||||||
className="h-10 w-full rounded-md border bg-background px-3 text-sm md:w-[360px]"
|
|
||||||
>
|
|
||||||
<option value="all">{t("classManagement.grade.insights.selectGrade")}</option>
|
|
||||||
{grades.map((g) => (
|
|
||||||
<option key={g.id} value={g.id}>
|
|
||||||
{g.school.name} / {g.name}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
<Button type="submit" className="md:ml-2">
|
|
||||||
{t("classManagement.grade.insights.apply")}
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{!selected ? (
|
{!selected ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title={t("classManagement.grade.insights.selectToView")}
|
title={t("grades.gradeInsights.selectToView")}
|
||||||
description={t("classManagement.grade.insights.selectToViewDescription")}
|
description={t("grades.gradeInsights.selectToViewDescription")}
|
||||||
className="h-[360px] bg-card"
|
className="h-[360px] bg-card"
|
||||||
/>
|
/>
|
||||||
) : !insights ? (
|
) : !insights ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title={t("classManagement.grade.insights.notFound")}
|
title={t("grades.gradeInsights.notFound")}
|
||||||
description={t("classManagement.grade.insights.notFoundDescription")}
|
description={t("grades.gradeInsights.notFoundDescription")}
|
||||||
className="h-[360px] bg-card"
|
className="h-[360px] bg-card"
|
||||||
/>
|
/>
|
||||||
) : insights.assignments.length === 0 ? (
|
) : insights.assignments.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
title={t("classManagement.grade.insights.noData")}
|
title={t("grades.gradeInsights.noData")}
|
||||||
description={t("classManagement.grade.insights.noDataDescription")}
|
description={t("grades.gradeInsights.noDataDescription")}
|
||||||
className="h-[360px] bg-card"
|
className="h-[360px] bg-card"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div className="grid gap-4 md:grid-cols-4">
|
<div className="grid gap-4 md:grid-cols-4">
|
||||||
<StatCard
|
<StatCard
|
||||||
title={t("classManagement.grade.insights.classes")}
|
title={t("grades.gradeInsights.classes")}
|
||||||
value={insights.classCount}
|
value={insights.classCount}
|
||||||
description={`${insights.grade.school.name} / ${insights.grade.name}`}
|
description={`${insights.grade.school.name} / ${insights.grade.name}`}
|
||||||
valueClassName="tabular-nums"
|
valueClassName="tabular-nums"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title={t("classManagement.grade.insights.students")}
|
title={t("grades.gradeInsights.students")}
|
||||||
value={insights.studentCounts.total}
|
value={insights.studentCounts.total}
|
||||||
description={`${t("classManagement.grade.insights.active")} ${insights.studentCounts.active} • ${t("classManagement.grade.insights.inactive")} ${insights.studentCounts.inactive}`}
|
description={`${t("grades.gradeInsights.active")} ${insights.studentCounts.active} • ${t("grades.gradeInsights.inactive")} ${insights.studentCounts.inactive}`}
|
||||||
valueClassName="tabular-nums"
|
valueClassName="tabular-nums"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title={t("classManagement.grade.insights.overallAvg")}
|
title={t("grades.gradeInsights.overallAvg")}
|
||||||
value={formatScore(insights.overallScores.avg)}
|
value={formatNumber(insights.overallScores.avg)}
|
||||||
description="-"
|
description="-"
|
||||||
valueClassName="tabular-nums"
|
valueClassName="tabular-nums"
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
title={t("classManagement.grade.insights.latestAvg")}
|
title={t("grades.gradeInsights.latestAvg")}
|
||||||
value={formatScore(insights.latest?.scoreStats.avg ?? null)}
|
value={formatNumber(insights.latest?.scoreStats.avg ?? null)}
|
||||||
description={insights.latest ? insights.latest.title : "-"}
|
description={insights.latest ? insights.latest.title : "-"}
|
||||||
valueClassName="tabular-nums"
|
valueClassName="tabular-nums"
|
||||||
/>
|
/>
|
||||||
@@ -148,85 +130,91 @@ export default async function TeacherGradeInsightsPage({ searchParams }: { searc
|
|||||||
|
|
||||||
<Card className="shadow-none">
|
<Card className="shadow-none">
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
||||||
<CardTitle className="text-base">{t("classManagement.grade.insights.homeworkTimeline")}</CardTitle>
|
<CardTitle className="text-base">{t("grades.gradeInsights.homeworkTimeline")}</CardTitle>
|
||||||
<Badge variant="secondary" className="tabular-nums">
|
<Badge variant="secondary" className="tabular-nums">
|
||||||
{insights.assignments.length}
|
{insights.assignments.length}
|
||||||
</Badge>
|
</Badge>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="rounded-md border">
|
<div className="rounded-md border">
|
||||||
<Table>
|
{/* v4-P1-11: 移动端表格水平滚动 */}
|
||||||
<TableHeader>
|
<div className="overflow-x-auto">
|
||||||
<TableRow className="bg-muted/50">
|
<Table>
|
||||||
<TableHead>{t("classManagement.grade.insights.assignment")}</TableHead>
|
<TableHeader>
|
||||||
<TableHead>{t("classManagement.grade.insights.status")}</TableHead>
|
<TableRow className="bg-muted/50">
|
||||||
<TableHead>{t("classManagement.grade.insights.created")}</TableHead>
|
<TableHead>{t("grades.gradeInsights.assignment")}</TableHead>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.targeted")}</TableHead>
|
<TableHead>{t("grades.gradeInsights.status")}</TableHead>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.submitted")}</TableHead>
|
<TableHead>{t("grades.gradeInsights.created")}</TableHead>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.graded")}</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.targeted")}</TableHead>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.avg")}</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.submitted")}</TableHead>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.median")}</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.graded")}</TableHead>
|
||||||
</TableRow>
|
<TableHead className="text-right">{t("grades.gradeInsights.avg")}</TableHead>
|
||||||
</TableHeader>
|
<TableHead className="text-right">{t("grades.gradeInsights.median")}</TableHead>
|
||||||
<TableBody>
|
|
||||||
{insights.assignments.map((a) => (
|
|
||||||
<TableRow key={a.assignmentId}>
|
|
||||||
<TableCell className="font-medium">{a.title}</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Badge variant="secondary" className="capitalize">
|
|
||||||
{a.status}
|
|
||||||
</Badge>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className="text-muted-foreground">{formatDate(a.createdAt)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{a.targetCount}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{a.submittedCount}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{a.gradedCount}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatScore(a.scoreStats.avg)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatScore(a.scoreStats.median)}</TableCell>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
</TableHeader>
|
||||||
</TableBody>
|
<TableBody>
|
||||||
</Table>
|
{insights.assignments.map((a) => (
|
||||||
|
<TableRow key={a.assignmentId}>
|
||||||
|
<TableCell className="font-medium">{a.title}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Badge variant="secondary" className="capitalize">
|
||||||
|
{a.status}
|
||||||
|
</Badge>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="text-muted-foreground">{formatDate(a.createdAt)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{a.targetCount}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{a.submittedCount}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{a.gradedCount}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(a.scoreStats.avg)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(a.scoreStats.median)}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card className="shadow-none">
|
<Card className="shadow-none">
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
||||||
<CardTitle className="text-base">{t("classManagement.grade.insights.classRanking")}</CardTitle>
|
<CardTitle className="text-base">{t("grades.gradeInsights.classRanking")}</CardTitle>
|
||||||
<Badge variant="secondary" className="tabular-nums">
|
<Badge variant="secondary" className="tabular-nums">
|
||||||
{insights.classes.length}
|
{insights.classes.length}
|
||||||
</Badge>
|
</Badge>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="rounded-md border">
|
<div className="rounded-md border">
|
||||||
<Table>
|
{/* v4-P1-11: 移动端表格水平滚动 */}
|
||||||
<TableHeader>
|
<div className="overflow-x-auto">
|
||||||
<TableRow className="bg-muted/50">
|
<Table>
|
||||||
<TableHead>{t("classManagement.grade.insights.class")}</TableHead>
|
<TableHeader>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.students")}</TableHead>
|
<TableRow className="bg-muted/50">
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.latestAvgCol")}</TableHead>
|
<TableHead>{t("grades.gradeInsights.class")}</TableHead>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.prevAvg")}</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.students")}</TableHead>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.delta")}</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.latestAvgCol")}</TableHead>
|
||||||
<TableHead className="text-right">{t("classManagement.grade.insights.overallAvgCol")}</TableHead>
|
<TableHead className="text-right">{t("grades.gradeInsights.prevAvg")}</TableHead>
|
||||||
</TableRow>
|
<TableHead className="text-right">{t("grades.gradeInsights.delta")}</TableHead>
|
||||||
</TableHeader>
|
<TableHead className="text-right">{t("grades.gradeInsights.overallAvgCol")}</TableHead>
|
||||||
<TableBody>
|
|
||||||
{insights.classes.map((c) => (
|
|
||||||
<TableRow key={c.class.id}>
|
|
||||||
<TableCell className="font-medium">
|
|
||||||
{c.class.name}
|
|
||||||
{c.class.homeroom ? <span className="text-muted-foreground"> • {c.class.homeroom}</span> : null}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{c.studentCounts.total}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatScore(c.latestAvg)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatScore(c.prevAvg)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatScore(c.deltaAvg)}</TableCell>
|
|
||||||
<TableCell className="text-right tabular-nums">{formatScore(c.overallScores.avg)}</TableCell>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
</TableHeader>
|
||||||
</TableBody>
|
<TableBody>
|
||||||
</Table>
|
{insights.classes.map((c) => (
|
||||||
|
<TableRow key={c.class.id}>
|
||||||
|
<TableCell className="font-medium">
|
||||||
|
{c.class.name}
|
||||||
|
{c.class.homeroom ? <span className="text-muted-foreground"> • {c.class.homeroom}</span> : null}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{c.studentCounts.total}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(c.latestAvg)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(c.prevAvg)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(c.deltaAvg)}</TableCell>
|
||||||
|
<TableCell className="text-right tabular-nums">{formatNumber(c.overallScores.avg)}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
27
src/app/(dashboard)/management/grade/practice/error.tsx
Normal file
27
src/app/(dashboard)/management/grade/practice/error.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useEffect } from "react"
|
||||||
|
import { BarChart3 } from "lucide-react"
|
||||||
|
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function Error() {
|
||||||
|
useEffect(() => {
|
||||||
|
console.error("Grade practice analytics page error")
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">年级专项练习总览</h1>
|
||||||
|
<p className="text-muted-foreground">加载年级练习数据时发生错误</p>
|
||||||
|
</div>
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title="加载失败"
|
||||||
|
description="请刷新页面重试,或联系管理员检查数据访问权限。"
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
16
src/app/(dashboard)/management/grade/practice/loading.tsx
Normal file
16
src/app/(dashboard)/management/grade/practice/loading.tsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function Loading() {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<Skeleton className="h-10 w-48" />
|
||||||
|
<Skeleton className="h-20 w-full" />
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-5">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[100px]" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-[300px] w-full" />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
141
src/app/(dashboard)/management/grade/practice/page.tsx
Normal file
141
src/app/(dashboard)/management/grade/practice/page.tsx
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
import type { Metadata } from "next"
|
||||||
|
import type { JSX } from "react"
|
||||||
|
import { BarChart3 } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||||
|
import { getTeacherIdForMutations } from "@/modules/classes/data-access"
|
||||||
|
import { getGradesForStaff } from "@/modules/school/data-access"
|
||||||
|
import { GradeInsightsFilters } from "@/modules/school/components/grade-insights-filters"
|
||||||
|
|
||||||
|
import {
|
||||||
|
getGradePracticeOverview,
|
||||||
|
getGradeClassPracticeComparison,
|
||||||
|
getPracticeTypeBreakdown,
|
||||||
|
} from "@/modules/adaptive-practice/data-access-analytics"
|
||||||
|
import { getUserIdsByGradeId } from "@/modules/users/data-access"
|
||||||
|
import { PracticeOverviewStatsCards } from "@/modules/adaptive-practice/components/practice-overview-stats-cards"
|
||||||
|
import { ClassPracticeComparisonTable } from "@/modules/adaptive-practice/components/class-practice-comparison-table"
|
||||||
|
import { PracticeTypeBreakdownChart } from "@/modules/adaptive-practice/components/practice-type-breakdown-chart"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
const t = await getTranslations("practice")
|
||||||
|
return {
|
||||||
|
title: `${t("grade.title")} - Next_Edu`,
|
||||||
|
description: t("grade.description"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function GradePracticePage({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<SearchParams>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
await requirePermission(Permissions.ADAPTIVE_PRACTICE_READ)
|
||||||
|
const t = await getTranslations("practice")
|
||||||
|
const params = await searchParams
|
||||||
|
const gradeId = getParam(params, "gradeId")
|
||||||
|
|
||||||
|
const teacherId = await getTeacherIdForMutations()
|
||||||
|
const grades = await getGradesForStaff(teacherId)
|
||||||
|
const allowedIds = new Set(grades.map((g) => g.id))
|
||||||
|
const selected = gradeId && gradeId !== "all" && allowedIds.has(gradeId) ? gradeId : ""
|
||||||
|
|
||||||
|
const buildHref = (gId: string): string => {
|
||||||
|
const p = new URLSearchParams()
|
||||||
|
if (gId && gId !== "all") p.set("gradeId", gId)
|
||||||
|
const qs = p.toString()
|
||||||
|
return qs ? `/management/grade/practice?${qs}` : "/management/grade/practice"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grades.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<h2 className="text-2xl font-bold tracking-tight">{t("grade.title")}</h2>
|
||||||
|
<p className="text-muted-foreground">{t("grade.description")}</p>
|
||||||
|
</div>
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("grade.noGrade")}
|
||||||
|
description={t("grade.noGradeDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仅在选中年级时查询数据
|
||||||
|
let overview: Awaited<ReturnType<typeof getGradePracticeOverview>> = null
|
||||||
|
let classComparison: Awaited<ReturnType<typeof getGradeClassPracticeComparison>> = []
|
||||||
|
let typeBreakdown: Awaited<ReturnType<typeof getPracticeTypeBreakdown>> = []
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
const studentIds = await getUserIdsByGradeId(selected)
|
||||||
|
const [ov, cmp, breakdown] = await Promise.all([
|
||||||
|
getGradePracticeOverview(selected),
|
||||||
|
getGradeClassPracticeComparison(selected),
|
||||||
|
getPracticeTypeBreakdown(studentIds),
|
||||||
|
])
|
||||||
|
overview = ov
|
||||||
|
classComparison = cmp
|
||||||
|
typeBreakdown = breakdown
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<h2 className="text-2xl font-bold tracking-tight">{t("grade.title")}</h2>
|
||||||
|
<p className="text-muted-foreground">{t("grade.description")}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<GradeInsightsFilters
|
||||||
|
grades={grades.map((g) => ({ id: g.id, name: g.name, schoolName: g.school.name }))}
|
||||||
|
currentGradeId={selected || "all"}
|
||||||
|
buildHref={buildHref}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{!selected ? (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("grade.noGrade")}
|
||||||
|
description={t("grade.noGradeDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
) : !overview ? (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("teacher.noData")}
|
||||||
|
description={t("teacher.noDataDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-6">
|
||||||
|
{/* 年级整体统计卡片 */}
|
||||||
|
<PracticeOverviewStatsCards
|
||||||
|
totalClasses={overview.totalClasses}
|
||||||
|
totalSessions={overview.totalSessions}
|
||||||
|
totalAnswered={overview.totalQuestionsAnswered}
|
||||||
|
averageAccuracy={overview.averageAccuracy}
|
||||||
|
participationRate={overview.participationRate}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 各班级练习对比表 */}
|
||||||
|
{classComparison.length > 0 ? (
|
||||||
|
<ClassPracticeComparisonTable data={classComparison} />
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 练习类型分布图 */}
|
||||||
|
{typeBreakdown.length > 0 ? (
|
||||||
|
<PracticeTypeBreakdownChart data={typeBreakdown} />
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from "@/modules/parent/components/child-detail-panel"
|
} from "@/modules/parent/components/child-detail-panel"
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
import { ShieldAlert } from "lucide-react"
|
import { ShieldAlert } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ export default async function ChildDetailPage({
|
|||||||
const { studentId } = await params
|
const { studentId } = await params
|
||||||
const sp = await searchParams
|
const sp = await searchParams
|
||||||
const ctx = await requireAuth()
|
const ctx = await requireAuth()
|
||||||
|
const t = await getTranslations("common")
|
||||||
|
|
||||||
// 校验当前家长与该子女存在关系(同时按 parentId + studentId 过滤,防止跨家庭信息泄露)
|
// 校验当前家长与该子女存在关系(同时按 parentId + studentId 过滤,防止跨家庭信息泄露)
|
||||||
const relation = await verifyParentChildRelation(studentId, ctx.userId)
|
const relation = await verifyParentChildRelation(studentId, ctx.userId)
|
||||||
@@ -41,8 +43,8 @@ export default async function ChildDetailPage({
|
|||||||
<div className="p-6 md:p-8">
|
<div className="p-6 md:p-8">
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={ShieldAlert}
|
icon={ShieldAlert}
|
||||||
title="Access denied"
|
title={t("accessDenied")}
|
||||||
description="This student is not linked to your account. Please contact the school administrator if you believe this is an error."
|
description={t("accessDeniedDesc")}
|
||||||
className="border-none shadow-none"
|
className="border-none shadow-none"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
} from "@/modules/parent/components/parent-children-data-page"
|
} from "@/modules/parent/components/parent-children-data-page"
|
||||||
import { getUserNamesByIds } from "@/modules/users/data-access"
|
import { getUserNamesByIds } from "@/modules/users/data-access"
|
||||||
import { Card, CardContent } from "@/shared/components/ui/card"
|
import { Card, CardContent } from "@/shared/components/ui/card"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
@@ -34,15 +35,16 @@ type ChildDiagnosticItem = ChildDiagnosticSuccessItem | ChildDiagnosticErrorItem
|
|||||||
|
|
||||||
export default async function ParentDiagnosticPage() {
|
export default async function ParentDiagnosticPage() {
|
||||||
const ctx = await requirePermission(Permissions.DIAGNOSTIC_READ)
|
const ctx = await requirePermission(Permissions.DIAGNOSTIC_READ)
|
||||||
|
const t = await getTranslations("diagnostic")
|
||||||
|
|
||||||
if (ctx.dataScope.type !== "children" || ctx.dataScope.childrenIds.length === 0) {
|
if (ctx.dataScope.type !== "children" || ctx.dataScope.childrenIds.length === 0) {
|
||||||
return (
|
return (
|
||||||
<ParentNoChildrenPage
|
<ParentNoChildrenPage
|
||||||
title="Children Diagnostic"
|
title={t("parent.title")}
|
||||||
description="View your children's knowledge point mastery and diagnostic reports."
|
description={t("parent.description")}
|
||||||
icon={Stethoscope}
|
icon={Stethoscope}
|
||||||
emptyTitle="No children linked"
|
emptyTitle={t("parent.noChildren")}
|
||||||
emptyDescription="Your account is not linked to any student accounts yet. Please contact the school administrator."
|
emptyDescription={t("parent.noChildrenDesc")}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -68,7 +70,7 @@ export default async function ParentDiagnosticPage() {
|
|||||||
|
|
||||||
const items: ChildDiagnosticItem[] = results.map((r, idx) => {
|
const items: ChildDiagnosticItem[] = results.map((r, idx) => {
|
||||||
const studentId = childrenIds[idx]
|
const studentId = childrenIds[idx]
|
||||||
const studentName = nameMap.get(studentId)?.name ?? "Unknown student"
|
const studentName = nameMap.get(studentId)?.name ?? t("parent.selectChild")
|
||||||
if (r.status === "fulfilled") {
|
if (r.status === "fulfilled") {
|
||||||
return {
|
return {
|
||||||
studentId,
|
studentId,
|
||||||
@@ -88,11 +90,11 @@ export default async function ParentDiagnosticPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ParentChildrenDataPage
|
<ParentChildrenDataPage
|
||||||
title="Children Diagnostic"
|
title={t("parent.title")}
|
||||||
description="View knowledge point mastery and diagnostic reports for all your children."
|
description={t("parent.description")}
|
||||||
icon={Stethoscope}
|
icon={Stethoscope}
|
||||||
noRecordsTitle="No diagnostic data"
|
noRecordsTitle={t("parent.noReports")}
|
||||||
noRecordsDescription="Your children don't have any diagnostic data yet."
|
noRecordsDescription={t("parent.noReports")}
|
||||||
items={items}
|
items={items}
|
||||||
renderItem={(item) => (
|
renderItem={(item) => (
|
||||||
<>
|
<>
|
||||||
@@ -111,10 +113,10 @@ export default async function ParentDiagnosticPage() {
|
|||||||
<CardContent className="flex flex-col items-center gap-3 py-8 text-center">
|
<CardContent className="flex flex-col items-center gap-3 py-8 text-center">
|
||||||
<AlertCircle className="h-8 w-8 text-destructive" aria-hidden="true" />
|
<AlertCircle className="h-8 w-8 text-destructive" aria-hidden="true" />
|
||||||
<p className="text-sm font-medium text-destructive">
|
<p className="text-sm font-medium text-destructive">
|
||||||
Failed to load diagnostic data for {item.studentName}.
|
{t("error.loadFailed")} for {item.studentName}.
|
||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
Please refresh the page or contact the school administrator if the problem persists.
|
{t("error.loadFailed")}. Please refresh the page or contact the school administrator if the problem persists.
|
||||||
</p>
|
</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -17,23 +17,25 @@ import {
|
|||||||
} from "@/modules/error-book/data-access"
|
} from "@/modules/error-book/data-access"
|
||||||
import { ErrorBookStatsCards } from "@/modules/error-book/components/error-book-stats-cards"
|
import { ErrorBookStatsCards } from "@/modules/error-book/components/error-book-stats-cards"
|
||||||
import { TopWrongQuestions } from "@/modules/error-book/components/top-wrong-questions"
|
import { TopWrongQuestions } from "@/modules/error-book/components/top-wrong-questions"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function ParentErrorBookPage(): Promise<JSX.Element> {
|
export default async function ParentErrorBookPage(): Promise<JSX.Element> {
|
||||||
const ctx = await requirePermission(Permissions.ERROR_BOOK_READ)
|
const ctx = await requirePermission(Permissions.ERROR_BOOK_READ)
|
||||||
|
const t = await getTranslations("errorBook")
|
||||||
|
|
||||||
if (ctx.dataScope.type !== "children" || ctx.dataScope.childrenIds.length === 0) {
|
if (ctx.dataScope.type !== "children" || ctx.dataScope.childrenIds.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">子女错题本</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{t("parent.title")}</h1>
|
||||||
<p className="text-muted-foreground">查看子女的错题情况与学习进度。</p>
|
<p className="text-muted-foreground">{t("parent.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={Users}
|
icon={Users}
|
||||||
title="暂无子女关联"
|
title={t("parent.noChild")}
|
||||||
description="您的账号尚未关联子女,请联系学校管理员进行关联。"
|
description={t("parent.noChildDesc")}
|
||||||
className="h-[360px] bg-card"
|
className="h-[360px] bg-card"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,8 +58,8 @@ export default async function ParentErrorBookPage(): Promise<JSX.Element> {
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">子女错题本</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{t("parent.title")}</h1>
|
||||||
<p className="text-muted-foreground">查看子女的错题情况与学习进度。</p>
|
<p className="text-muted-foreground">{t("parent.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{childrenIds.length === 1 ? (
|
{childrenIds.length === 1 ? (
|
||||||
@@ -68,35 +70,35 @@ export default async function ParentErrorBookPage(): Promise<JSX.Element> {
|
|||||||
<div className="grid gap-4 md:grid-cols-2">
|
<div className="grid gap-4 md:grid-cols-2">
|
||||||
{childrenIds.map((childId, idx) => {
|
{childrenIds.map((childId, idx) => {
|
||||||
const stats = childStatsList[idx]
|
const stats = childStatsList[idx]
|
||||||
const name = nameMap.get(childId) ?? "未知"
|
const name = nameMap.get(childId) ?? t("parent.unknown")
|
||||||
return (
|
return (
|
||||||
<Card key={childId}>
|
<Card key={childId}>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="flex items-center justify-between text-base">
|
<CardTitle className="flex items-center justify-between text-base">
|
||||||
<span>{name}</span>
|
<span>{name}</span>
|
||||||
<Badge variant="outline">
|
<Badge variant="outline">
|
||||||
{formatNumber(stats.masteredRate * 100, 0)}% 掌握
|
{t("parent.mastery", { rate: formatNumber(stats.masteredRate * 100, 0) })}
|
||||||
</Badge>
|
</Badge>
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-3">
|
<CardContent className="space-y-3">
|
||||||
<div className="grid grid-cols-2 gap-3 text-sm">
|
<div className="grid grid-cols-2 gap-3 text-sm">
|
||||||
<div>
|
<div>
|
||||||
<div className="text-muted-foreground">错题总数</div>
|
<div className="text-muted-foreground">{t("parent.totalErrors")}</div>
|
||||||
<div className="text-lg font-bold">{stats.totalCount}</div>
|
<div className="text-lg font-bold">{stats.totalCount}</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-muted-foreground">待复习</div>
|
<div className="text-muted-foreground">{t("parent.dueReview")}</div>
|
||||||
<div className="text-lg font-bold text-rose-600 dark:text-rose-400">
|
<div className="text-lg font-bold text-rose-600 dark:text-rose-400">
|
||||||
{stats.dueReviewCount}
|
{stats.dueReviewCount}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-muted-foreground">待学习</div>
|
<div className="text-muted-foreground">{t("parent.newItems")}</div>
|
||||||
<div className="font-medium text-blue-600 dark:text-blue-400">{stats.newCount}</div>
|
<div className="font-medium text-blue-600 dark:text-blue-400">{stats.newCount}</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-muted-foreground">已掌握</div>
|
<div className="text-muted-foreground">{t("parent.mastered")}</div>
|
||||||
<div className="font-medium text-emerald-600 dark:text-emerald-400">{stats.masteredCount}</div>
|
<div className="font-medium text-emerald-600 dark:text-emerald-400">{stats.masteredCount}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -112,7 +114,7 @@ export default async function ParentErrorBookPage(): Promise<JSX.Element> {
|
|||||||
{weakKps.length > 0 ? (
|
{weakKps.length > 0 ? (
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-base">薄弱知识点</CardTitle>
|
<CardTitle className="text-base">{t("parent.weakPoints")}</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
@@ -121,7 +123,7 @@ export default async function ParentErrorBookPage(): Promise<JSX.Element> {
|
|||||||
<div className="flex items-center justify-between text-sm">
|
<div className="flex items-center justify-between text-sm">
|
||||||
<span>{kp.knowledgePointName}</span>
|
<span>{kp.knowledgePointName}</span>
|
||||||
<span className="text-muted-foreground">
|
<span className="text-muted-foreground">
|
||||||
{kp.errorCount} 错 · {formatNumber(kp.masteryRate * 100, 0)}% 掌握
|
{t("parent.errorsAndMastery", { count: kp.errorCount, rate: formatNumber(kp.masteryRate * 100, 0) })}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Progress value={kp.masteryRate * 100} className="h-1.5" />
|
<Progress value={kp.masteryRate * 100} className="h-1.5" />
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
import { AlertTriangle } from "lucide-react"
|
import { AlertTriangle } from "lucide-react"
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
|
||||||
export default function ParentError({
|
export default function ParentError({
|
||||||
error,
|
error,
|
||||||
@@ -10,13 +11,15 @@ export default function ParentError({
|
|||||||
error: Error & { digest?: string }
|
error: Error & { digest?: string }
|
||||||
reset: () => void
|
reset: () => void
|
||||||
}) {
|
}) {
|
||||||
|
const t = useTranslations("common")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 md:p-8">
|
<div className="p-6 md:p-8">
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={AlertTriangle}
|
icon={AlertTriangle}
|
||||||
title="Something went wrong"
|
title={t("somethingWentWrong")}
|
||||||
description={error.message || "An unexpected error occurred. Please try again."}
|
description={error.message || "An unexpected error occurred. Please try again."}
|
||||||
action={{ label: "Try again", onClick: reset }}
|
action={{ label: t("tryAgain"), onClick: reset }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
import { ParentExportButton } from "@/modules/parent/components/parent-export-button"
|
import { ParentExportButton } from "@/modules/parent/components/parent-export-button"
|
||||||
import { GraduationCap } from "lucide-react"
|
import { GraduationCap } from "lucide-react"
|
||||||
import type { ClassAverageTrendResult } from "@/modules/grades/types"
|
import type { ClassAverageTrendResult } from "@/modules/grades/types"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
@@ -22,15 +23,16 @@ interface ChildGradeItem {
|
|||||||
|
|
||||||
export default async function ParentGradesPage() {
|
export default async function ParentGradesPage() {
|
||||||
const ctx = await requirePermission(Permissions.GRADE_RECORD_READ)
|
const ctx = await requirePermission(Permissions.GRADE_RECORD_READ)
|
||||||
|
const t = await getTranslations("grades")
|
||||||
|
|
||||||
if (ctx.dataScope.type !== "children" || ctx.dataScope.childrenIds.length === 0) {
|
if (ctx.dataScope.type !== "children" || ctx.dataScope.childrenIds.length === 0) {
|
||||||
return (
|
return (
|
||||||
<ParentNoChildrenPage
|
<ParentNoChildrenPage
|
||||||
title="Children Grades"
|
title={t("parent.title")}
|
||||||
description="View your children's grade records."
|
description={t("parent.description")}
|
||||||
icon={GraduationCap}
|
icon={GraduationCap}
|
||||||
emptyTitle="No children linked"
|
emptyTitle={t("parent.noChildren")}
|
||||||
emptyDescription="Your account is not linked to any student accounts yet. Please contact the school administrator."
|
emptyDescription={t("parent.noChildrenDesc")}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -64,11 +66,11 @@ export default async function ParentGradesPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ParentChildrenDataPage
|
<ParentChildrenDataPage
|
||||||
title="Children Grades"
|
title={t("parent.title")}
|
||||||
description="Compare grades across all your children. For single-child analysis, open the child's detail page."
|
description={t("parent.description")}
|
||||||
icon={GraduationCap}
|
icon={GraduationCap}
|
||||||
noRecordsTitle="No grade records"
|
noRecordsTitle={t("parent.noGrades")}
|
||||||
noRecordsDescription="Your children don't have any grade records yet."
|
noRecordsDescription={t("parent.noGradesDesc")}
|
||||||
items={validItems}
|
items={validItems}
|
||||||
renderItem={({ studentId, summary, classAverageTrend }) => (
|
renderItem={({ studentId, summary, classAverageTrend }) => (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -4,23 +4,26 @@ import { CalendarDays, ArrowLeft, Phone, Mail } from "lucide-react"
|
|||||||
import { Button } from "@/shared/components/ui/button"
|
import { Button } from "@/shared/components/ui/button"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function ParentLeavePage() {
|
export default async function ParentLeavePage() {
|
||||||
|
const t = await getTranslations("leave")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 md:p-8 space-y-6">
|
<div className="p-6 md:p-8 space-y-6">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<h1 className="text-2xl font-bold tracking-tight">Leave Request</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{t("title")}</h1>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Submit a leave request for your child.
|
{t("description")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button asChild variant="ghost" size="sm" className="gap-2 -ml-2">
|
<Button asChild variant="ghost" size="sm" className="gap-2 -ml-2">
|
||||||
<Link href="/parent/dashboard" aria-label="Back to Dashboard">
|
<Link href="/parent/dashboard" aria-label={t("backToDashboard")}>
|
||||||
<ArrowLeft className="h-4 w-4" />
|
<ArrowLeft className="h-4 w-4" />
|
||||||
Back to Dashboard
|
{t("backToDashboard")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
@@ -28,33 +31,33 @@ export default async function ParentLeavePage() {
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="flex items-center gap-2 text-base">
|
<CardTitle className="flex items-center gap-2 text-base">
|
||||||
<CalendarDays className="h-4 w-4 text-muted-foreground" aria-hidden />
|
<CalendarDays className="h-4 w-4 text-muted-foreground" aria-hidden />
|
||||||
Online Leave Request
|
{t("onlineLeave")}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-4">
|
<CardContent className="space-y-4">
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={CalendarDays}
|
icon={CalendarDays}
|
||||||
title="Coming soon"
|
title={t("comingSoon")}
|
||||||
description="The online leave request feature is being developed and will be available soon. For now, please contact the homeroom teacher or school office directly."
|
description={t("comingSoonDesc")}
|
||||||
className="border-none shadow-none"
|
className="border-none shadow-none"
|
||||||
/>
|
/>
|
||||||
<div className="rounded-md border bg-muted/30 p-4 space-y-2">
|
<div className="rounded-md border bg-muted/30 p-4 space-y-2">
|
||||||
<div className="text-sm font-medium">Contact options</div>
|
<div className="text-sm font-medium">{t("contactOptions")}</div>
|
||||||
<ul className="space-y-2 text-sm text-muted-foreground">
|
<ul className="space-y-2 text-sm text-muted-foreground">
|
||||||
<li className="flex items-center gap-2">
|
<li className="flex items-center gap-2">
|
||||||
<Phone className="h-4 w-4" aria-hidden />
|
<Phone className="h-4 w-4" aria-hidden />
|
||||||
<span>Call the school office during working hours</span>
|
<span>{t("callOffice")}</span>
|
||||||
</li>
|
</li>
|
||||||
<li className="flex items-center gap-2">
|
<li className="flex items-center gap-2">
|
||||||
<Mail className="h-4 w-4" aria-hidden />
|
<Mail className="h-4 w-4" aria-hidden />
|
||||||
<span>Send a message to the homeroom teacher via the Messages page</span>
|
<span>{t("sendMessage")}</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<Link
|
<Link
|
||||||
href="/messages"
|
href="/messages"
|
||||||
className="inline-flex h-9 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
className="inline-flex h-9 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
||||||
>
|
>
|
||||||
Go to Messages
|
{t("goToMessages")}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function ParentLessonPlanViewError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function ParentLessonPlanViewLoading() {
|
||||||
|
return (
|
||||||
|
<div className="h-[calc(100vh-4rem)]">
|
||||||
|
<div className="flex h-full items-center justify-center">
|
||||||
|
<Skeleton className="h-[80%] w-[80%]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import type { JSX } from "react"
|
||||||
|
import { Suspense } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
import { getAuthContext } from "@/shared/lib/auth-guard"
|
||||||
|
import { getLessonPlanById } from "@/modules/lesson-preparation/data-access"
|
||||||
|
import { getTextbookById, getChaptersByTextbookId } from "@/modules/textbooks/data-access"
|
||||||
|
import { LessonPlanReadonlyView } from "@/modules/lesson-preparation/components/lesson-plan-readonly-view"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function ParentLessonPlanViewPage({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ planId: string }>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
const { planId } = await params
|
||||||
|
const t = await getTranslations("lessonPreparation")
|
||||||
|
const ctx = await getAuthContext()
|
||||||
|
|
||||||
|
const plan = await getLessonPlanById(planId, ctx.userId)
|
||||||
|
if (!plan) {
|
||||||
|
return (
|
||||||
|
<div className="p-6">
|
||||||
|
<div className="rounded-md border border-outline-variant bg-surface-container-low p-4 text-on-surface-variant">
|
||||||
|
{t("readonly.notFound")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plan.status !== "published") {
|
||||||
|
return (
|
||||||
|
<div className="p-6">
|
||||||
|
<div className="rounded-md border border-outline-variant bg-surface-container-low p-4 text-on-surface-variant">
|
||||||
|
{t("readonly.notPublished")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
let textbookTitle: string | undefined
|
||||||
|
let chapterTitle: string | undefined
|
||||||
|
if (plan.textbookId) {
|
||||||
|
const textbook = await getTextbookById(plan.textbookId)
|
||||||
|
textbookTitle = textbook?.title
|
||||||
|
if (plan.chapterId) {
|
||||||
|
const chapters = await getChaptersByTextbookId(plan.textbookId)
|
||||||
|
const findChapter = (list: typeof chapters): typeof chapters[number] | undefined => {
|
||||||
|
for (const ch of list) {
|
||||||
|
if (ch.id === plan.chapterId) return ch
|
||||||
|
if (ch.children && ch.children.length > 0) {
|
||||||
|
const found = findChapter(ch.children as typeof chapters)
|
||||||
|
if (found) return found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const chapter = findChapter(chapters)
|
||||||
|
chapterTitle = chapter?.title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="h-[calc(100vh-4rem)]">
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="flex h-full items-center justify-center">
|
||||||
|
<Skeleton className="h-[80%] w-[80%]" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LessonPlanReadonlyView
|
||||||
|
doc={plan.content}
|
||||||
|
textbookTitle={textbookTitle}
|
||||||
|
chapterTitle={chapterTitle}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
20
src/app/(dashboard)/parent/lesson-plans/error.tsx
Normal file
20
src/app/(dashboard)/parent/lesson-plans/error.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function ParentLessonPlansError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
17
src/app/(dashboard)/parent/lesson-plans/loading.tsx
Normal file
17
src/app/(dashboard)/parent/lesson-plans/loading.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function ParentLessonPlansLoading() {
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-[180px]" />
|
||||||
|
<Skeleton className="h-4 w-[300px]" />
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[180px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
44
src/app/(dashboard)/parent/lesson-plans/page.tsx
Normal file
44
src/app/(dashboard)/parent/lesson-plans/page.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import type { JSX } from "react"
|
||||||
|
import { Suspense } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
import { getAuthContext } from "@/shared/lib/auth-guard"
|
||||||
|
import { getLessonPlans } from "@/modules/lesson-preparation/data-access"
|
||||||
|
import { getSubjectOptions } from "@/modules/school/data-access"
|
||||||
|
import { LessonPlanList } from "@/modules/lesson-preparation/components/lesson-plan-list"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function ParentLessonPlansPage(): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("lessonPreparation")
|
||||||
|
const ctx = await getAuthContext()
|
||||||
|
|
||||||
|
const [items, subjects] = await Promise.all([
|
||||||
|
getLessonPlans({ status: "published" }, ctx.dataScope, ctx.userId),
|
||||||
|
getSubjectOptions(),
|
||||||
|
])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">{t("parent.title")}</h1>
|
||||||
|
<p className="text-muted-foreground">{t("parent.description")}</p>
|
||||||
|
</div>
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[180px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LessonPlanList
|
||||||
|
initialItems={items}
|
||||||
|
subjects={subjects}
|
||||||
|
viewMode="parent"
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ export default function StudentAttendanceError({ reset }: { error: Error & { dig
|
|||||||
title={t("errors.unexpected")}
|
title={t("errors.unexpected")}
|
||||||
description={t("errors.unexpected")}
|
description={t("errors.unexpected")}
|
||||||
action={{
|
action={{
|
||||||
label: t("actions.save"),
|
label: t("actions.retry"),
|
||||||
onClick: () => reset(),
|
onClick: () => reset(),
|
||||||
}}
|
}}
|
||||||
className="border-none shadow-none h-auto"
|
className="border-none shadow-none h-auto"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { AlertCircle } from "lucide-react"
|
import { AlertCircle } from "lucide-react"
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
@@ -10,14 +11,15 @@ export default function StudentDiagnosticError({
|
|||||||
error: Error & { digest?: string }
|
error: Error & { digest?: string }
|
||||||
reset: () => void
|
reset: () => void
|
||||||
}) {
|
}) {
|
||||||
|
const t = useTranslations("student")
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={AlertCircle}
|
icon={AlertCircle}
|
||||||
title="学情诊断页面加载失败"
|
title={t("error.title")}
|
||||||
description="抱歉,页面加载时发生了意外错误。请稍后重试。"
|
description={t("error.description")}
|
||||||
action={{
|
action={{
|
||||||
label: "重试",
|
label: t("error.retry"),
|
||||||
onClick: () => reset(),
|
onClick: () => reset(),
|
||||||
}}
|
}}
|
||||||
className="border-none shadow-none h-auto"
|
className="border-none shadow-none h-auto"
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Stethoscope } from "lucide-react"
|
import { Stethoscope } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
import { getStudentMasterySummary } from "@/modules/diagnostic/data-access"
|
import { getStudentMasterySummary } from "@/modules/diagnostic/data-access"
|
||||||
@@ -9,6 +11,7 @@ export const dynamic = "force-dynamic"
|
|||||||
|
|
||||||
export default async function StudentDiagnosticPage() {
|
export default async function StudentDiagnosticPage() {
|
||||||
const ctx = await requirePermission(Permissions.DIAGNOSTIC_READ)
|
const ctx = await requirePermission(Permissions.DIAGNOSTIC_READ)
|
||||||
|
const t = await getTranslations("student")
|
||||||
|
|
||||||
const [summary, reportsResult] = await Promise.all([
|
const [summary, reportsResult] = await Promise.all([
|
||||||
getStudentMasterySummary(ctx.userId),
|
getStudentMasterySummary(ctx.userId),
|
||||||
@@ -25,10 +28,10 @@ export default async function StudentDiagnosticPage() {
|
|||||||
<div>
|
<div>
|
||||||
<h2 className="flex items-center gap-2 text-2xl font-bold tracking-tight">
|
<h2 className="flex items-center gap-2 text-2xl font-bold tracking-tight">
|
||||||
<Stethoscope className="h-6 w-6" />
|
<Stethoscope className="h-6 w-6" />
|
||||||
My Diagnostic
|
{t("diagnostic.title")}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
Your knowledge point mastery analysis and diagnostic reports.
|
{t("diagnostic.description")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<StudentDiagnosticView summary={summary} reports={reports} />
|
<StudentDiagnosticView summary={summary} reports={reports} />
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default function StudentElectiveError({ reset }: { error: Error & { diges
|
|||||||
title={t("errors.unexpected")}
|
title={t("errors.unexpected")}
|
||||||
description={t("errors.unexpected")}
|
description={t("errors.unexpected")}
|
||||||
action={{
|
action={{
|
||||||
label: t("actions.save"),
|
label: t("actions.retry"),
|
||||||
onClick: () => reset(),
|
onClick: () => reset(),
|
||||||
}}
|
}}
|
||||||
className="border-none shadow-none h-auto"
|
className="border-none shadow-none h-auto"
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { BookX } from "lucide-react"
|
import { BookX } from "lucide-react"
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
export default function StudentErrorBookError() {
|
export default function StudentErrorBookError() {
|
||||||
|
const t = useTranslations("student")
|
||||||
return (
|
return (
|
||||||
<div className="p-8">
|
<div className="p-8">
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BookX}
|
icon={BookX}
|
||||||
title="加载错题本失败"
|
title={t("error.title")}
|
||||||
description="发生了一些错误,请刷新页面重试。如果问题持续,请联系管理员。"
|
description={t("error.description")}
|
||||||
action={{ label: "刷新页面", onClick: () => window.location.reload() }}
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
className="border-none shadow-none"
|
className="border-none shadow-none"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
@@ -92,6 +93,7 @@ export default async function StudentErrorBookPage({
|
|||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}): Promise<JSX.Element> {
|
}): Promise<JSX.Element> {
|
||||||
const ctx = await requirePermission(Permissions.ERROR_BOOK_READ)
|
const ctx = await requirePermission(Permissions.ERROR_BOOK_READ)
|
||||||
|
const t = await getTranslations("student")
|
||||||
const stats = await getErrorBookStats(ctx.userId)
|
const stats = await getErrorBookStats(ctx.userId)
|
||||||
const aiClientService = createAiClientService()
|
const aiClientService = createAiClientService()
|
||||||
|
|
||||||
@@ -100,9 +102,9 @@ export default async function StudentErrorBookPage({
|
|||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div className="flex flex-col justify-between space-y-4 md:flex-row md:items-center md:space-y-0">
|
<div className="flex flex-col justify-between space-y-4 md:flex-row md:items-center md:space-y-0">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">错题本</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{t("errorBook.title")}</h1>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
自动收录考试与作业中的错题,科学复习,攻克薄弱点。
|
{t("errorBook.description")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
|
||||||
import { AlertTriangle } from "lucide-react"
|
import { AlertTriangle } from "lucide-react"
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
export default function StudentError({
|
export default function StudentError({
|
||||||
error,
|
error,
|
||||||
@@ -10,12 +12,13 @@ export default function StudentError({
|
|||||||
error: Error & { digest?: string }
|
error: Error & { digest?: string }
|
||||||
reset: () => void
|
reset: () => void
|
||||||
}) {
|
}) {
|
||||||
|
const t = useTranslations("student")
|
||||||
return (
|
return (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={AlertTriangle}
|
icon={AlertTriangle}
|
||||||
title="Something went wrong"
|
title={t("error.title")}
|
||||||
description={error.message || "An unexpected error occurred. Please try again."}
|
description={error.message || t("error.description")}
|
||||||
action={{ label: "Try again", onClick: reset }}
|
action={{ label: t("error.retry"), onClick: reset }}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { AlertCircle } from "lucide-react"
|
import { AlertCircle } from "lucide-react"
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
@@ -10,14 +11,15 @@ export default function StudentGradesError({
|
|||||||
error: Error & { digest?: string }
|
error: Error & { digest?: string }
|
||||||
reset: () => void
|
reset: () => void
|
||||||
}) {
|
}) {
|
||||||
|
const t = useTranslations("student")
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={AlertCircle}
|
icon={AlertCircle}
|
||||||
title="成绩查询页面加载失败"
|
title={t("error.title")}
|
||||||
description="抱歉,页面加载时发生了意外错误。请稍后重试。"
|
description={t("error.description")}
|
||||||
action={{
|
action={{
|
||||||
label: "重试",
|
label: t("error.retry"),
|
||||||
onClick: () => reset(),
|
onClick: () => reset(),
|
||||||
}}
|
}}
|
||||||
className="border-none shadow-none h-auto"
|
className="border-none shadow-none h-auto"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export default async function StudentGradesPage({
|
|||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}) {
|
}) {
|
||||||
const ctx = await requirePermission(Permissions.GRADE_RECORD_READ)
|
const ctx = await requirePermission(Permissions.GRADE_RECORD_READ)
|
||||||
|
const t = await getTranslations("grades")
|
||||||
const [sp, summary, rankingTrend, classAverageTrend, subjectOptions] = await Promise.all([
|
const [sp, summary, rankingTrend, classAverageTrend, subjectOptions] = await Promise.all([
|
||||||
searchParams,
|
searchParams,
|
||||||
getStudentGradeSummary(ctx.userId, ctx.dataScope),
|
getStudentGradeSummary(ctx.userId, ctx.dataScope),
|
||||||
@@ -32,7 +33,6 @@ export default async function StudentGradesPage({
|
|||||||
])
|
])
|
||||||
|
|
||||||
if (!summary) {
|
if (!summary) {
|
||||||
const t = await getTranslations("grades")
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div>
|
<div>
|
||||||
@@ -73,7 +73,7 @@ export default async function StudentGradesPage({
|
|||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">{summary.studentName}</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{summary.studentName}</h2>
|
||||||
<p className="text-muted-foreground">{summary.records.length} 条成绩记录</p>
|
<p className="text-muted-foreground">{t("summary.recordCount", { count: summary.records.length })}</p>
|
||||||
</div>
|
</div>
|
||||||
<GradeFilters subjects={subjectOptions.map((s) => ({ id: s.id, name: s.name }))} />
|
<GradeFilters subjects={subjectOptions.map((s) => ({ id: s.id, name: s.name }))} />
|
||||||
{filteredSummary.records.length > 0 && (
|
{filteredSummary.records.length > 0 && (
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { notFound } from "next/navigation"
|
import { notFound } from "next/navigation"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getStudentHomeworkTakeData } from "@/modules/homework/data-access"
|
import { getStudentHomeworkTakeData } from "@/modules/homework/data-access"
|
||||||
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
||||||
@@ -17,6 +18,8 @@ export default async function StudentAssignmentTakePage({
|
|||||||
const student = await getCurrentStudentUser()
|
const student = await getCurrentStudentUser()
|
||||||
if (!student) return notFound()
|
if (!student) return notFound()
|
||||||
|
|
||||||
|
const t = await getTranslations("student")
|
||||||
|
|
||||||
const data = await getStudentHomeworkTakeData(assignmentId, student.id)
|
const data = await getStudentHomeworkTakeData(assignmentId, student.id)
|
||||||
if (!data) return notFound()
|
if (!data) return notFound()
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ export default async function StudentAssignmentTakePage({
|
|||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">{data.assignment.title}</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{data.assignment.title}</h2>
|
||||||
<div className="text-sm text-muted-foreground">
|
<div className="text-sm text-muted-foreground">
|
||||||
<span>Due: {data.assignment.dueAt ? formatDate(data.assignment.dueAt) : "-"}</span>
|
<span>{t("assignment.due", { date: data.assignment.dueAt ? formatDate(data.assignment.dueAt) : "-" })}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -42,9 +45,9 @@ export default async function StudentAssignmentTakePage({
|
|||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<h2 className="text-2xl font-bold tracking-tight">{data.assignment.title}</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{data.assignment.title}</h2>
|
||||||
<div className="text-sm text-muted-foreground">
|
<div className="text-sm text-muted-foreground">
|
||||||
<span>Due: {data.assignment.dueAt ? formatDate(data.assignment.dueAt) : "-"}</span>
|
<span>{t("assignment.due", { date: data.assignment.dueAt ? formatDate(data.assignment.dueAt) : "-" })}</span>
|
||||||
<span className="mx-2" aria-hidden="true">•</span>
|
<span className="mx-2" aria-hidden="true">•</span>
|
||||||
<span>Max Attempts: {data.assignment.maxAttempts}</span>
|
<span>{t("assignment.maxAttempts", { count: data.assignment.maxAttempts })}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
School,
|
School,
|
||||||
User,
|
User,
|
||||||
} from "lucide-react"
|
} from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getStudentClassById, getStudentSchedule } from "@/modules/classes/data-access"
|
import { getStudentClassById, getStudentSchedule } from "@/modules/classes/data-access"
|
||||||
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
||||||
@@ -20,14 +21,14 @@ import { EmptyState } from "@/shared/components/ui/empty-state"
|
|||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
const WEEKDAYS: Record<number, string> = {
|
const WEEKDAY_KEYS: Record<number, string> = {
|
||||||
1: "Mon",
|
1: "mon",
|
||||||
2: "Tue",
|
2: "tue",
|
||||||
3: "Wed",
|
3: "wed",
|
||||||
4: "Thu",
|
4: "thu",
|
||||||
5: "Fri",
|
5: "fri",
|
||||||
6: "Sat",
|
6: "sat",
|
||||||
7: "Sun",
|
7: "sun",
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function StudentClassDetailPage({
|
export default async function StudentClassDetailPage({
|
||||||
@@ -39,6 +40,8 @@ export default async function StudentClassDetailPage({
|
|||||||
const student = await getCurrentStudentUser()
|
const student = await getCurrentStudentUser()
|
||||||
if (!student) return notFound()
|
if (!student) return notFound()
|
||||||
|
|
||||||
|
const t = await getTranslations("student")
|
||||||
|
|
||||||
const [classInfo, schedule] = await Promise.all([
|
const [classInfo, schedule] = await Promise.all([
|
||||||
getStudentClassById(student.id, classId),
|
getStudentClassById(student.id, classId),
|
||||||
getStudentSchedule(student.id),
|
getStudentSchedule(student.id),
|
||||||
@@ -58,14 +61,14 @@ export default async function StudentClassDetailPage({
|
|||||||
<Button asChild variant="ghost" size="sm" className="-ml-2 mb-1">
|
<Button asChild variant="ghost" size="sm" className="-ml-2 mb-1">
|
||||||
<Link href="/student/learning/courses">
|
<Link href="/student/learning/courses">
|
||||||
<ChevronLeft className="mr-1 h-4 w-4" />
|
<ChevronLeft className="mr-1 h-4 w-4" />
|
||||||
Back to Courses
|
{t("classDetail.backToCourses")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">{classInfo.name}</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{classInfo.name}</h2>
|
||||||
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
||||||
<span className="flex items-center gap-1">
|
<span className="flex items-center gap-1">
|
||||||
<BookOpen className="h-4 w-4" />
|
<BookOpen className="h-4 w-4" />
|
||||||
Grade {classInfo.grade}
|
{t("classDetail.grade", { grade: classInfo.grade })}
|
||||||
</span>
|
</span>
|
||||||
{classInfo.homeroom && (
|
{classInfo.homeroom && (
|
||||||
<>
|
<>
|
||||||
@@ -78,24 +81,24 @@ export default async function StudentClassDetailPage({
|
|||||||
<span aria-hidden="true">•</span>
|
<span aria-hidden="true">•</span>
|
||||||
<span className="flex items-center gap-1">
|
<span className="flex items-center gap-1">
|
||||||
<Building2 className="h-4 w-4" />
|
<Building2 className="h-4 w-4" />
|
||||||
Room {classInfo.room}
|
{t("classDetail.room", { room: classInfo.room })}
|
||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Badge variant="secondary">Active</Badge>
|
<Badge variant="secondary">{t("classDetail.active")}</Badge>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button asChild variant="outline" size="sm">
|
<Button asChild variant="outline" size="sm">
|
||||||
<Link href={`/student/schedule?classId=${encodeURIComponent(classInfo.id)}`}>
|
<Link href={`/student/schedule?classId=${encodeURIComponent(classInfo.id)}`}>
|
||||||
<CalendarDays className="mr-2 h-4 w-4" />
|
<CalendarDays className="mr-2 h-4 w-4" />
|
||||||
Full Schedule
|
{t("classDetail.fullSchedule")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
<Button asChild size="sm">
|
<Button asChild size="sm">
|
||||||
<Link href="/student/learning/assignments">
|
<Link href="/student/learning/assignments">
|
||||||
<PenTool className="mr-2 h-4 w-4" />
|
<PenTool className="mr-2 h-4 w-4" />
|
||||||
Assignments
|
{t("classDetail.assignments")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -107,7 +110,7 @@ export default async function StudentClassDetailPage({
|
|||||||
<CardHeader className="pb-3">
|
<CardHeader className="pb-3">
|
||||||
<CardTitle className="flex items-center gap-2 text-sm font-medium">
|
<CardTitle className="flex items-center gap-2 text-sm font-medium">
|
||||||
<User className="h-4 w-4" />
|
<User className="h-4 w-4" />
|
||||||
Teacher
|
{t("classDetail.teacher")}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-3 text-sm">
|
<CardContent className="space-y-3 text-sm">
|
||||||
@@ -117,7 +120,7 @@ export default async function StudentClassDetailPage({
|
|||||||
<span className="font-medium">{classInfo.teacherName}</span>
|
<span className="font-medium">{classInfo.teacherName}</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-muted-foreground">No teacher assigned.</p>
|
<p className="text-muted-foreground">{t("classDetail.noTeacher")}</p>
|
||||||
)}
|
)}
|
||||||
{classInfo.teacherEmail && (
|
{classInfo.teacherEmail && (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -138,7 +141,7 @@ export default async function StudentClassDetailPage({
|
|||||||
<CardHeader className="pb-3">
|
<CardHeader className="pb-3">
|
||||||
<CardTitle className="flex items-center gap-2 text-sm font-medium">
|
<CardTitle className="flex items-center gap-2 text-sm font-medium">
|
||||||
<School className="h-4 w-4" />
|
<School className="h-4 w-4" />
|
||||||
School
|
{t("classDetail.school")}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-3 text-sm">
|
<CardContent className="space-y-3 text-sm">
|
||||||
@@ -148,12 +151,12 @@ export default async function StudentClassDetailPage({
|
|||||||
<span className="font-medium">{classInfo.schoolName}</span>
|
<span className="font-medium">{classInfo.schoolName}</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-muted-foreground">School info not available.</p>
|
<p className="text-muted-foreground">{t("classDetail.schoolNotAvailable")}</p>
|
||||||
)}
|
)}
|
||||||
{classInfo.grade && (
|
{classInfo.grade && (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<BookOpen className="h-4 w-4 text-muted-foreground" />
|
<BookOpen className="h-4 w-4 text-muted-foreground" />
|
||||||
<span>Grade {classInfo.grade}</span>
|
<span>{t("classDetail.grade", { grade: classInfo.grade })}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -164,22 +167,22 @@ export default async function StudentClassDetailPage({
|
|||||||
<CardHeader className="pb-3">
|
<CardHeader className="pb-3">
|
||||||
<CardTitle className="flex items-center gap-2 text-sm font-medium">
|
<CardTitle className="flex items-center gap-2 text-sm font-medium">
|
||||||
<Building2 className="h-4 w-4" />
|
<Building2 className="h-4 w-4" />
|
||||||
Classroom
|
{t("classDetail.classroom")}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-3 text-sm">
|
<CardContent className="space-y-3 text-sm">
|
||||||
{classInfo.room ? (
|
{classInfo.room ? (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Building2 className="h-4 w-4 text-muted-foreground" />
|
<Building2 className="h-4 w-4 text-muted-foreground" />
|
||||||
<span className="font-medium">Room {classInfo.room}</span>
|
<span className="font-medium">{t("classDetail.room", { room: classInfo.room })}</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-muted-foreground">Room not assigned.</p>
|
<p className="text-muted-foreground">{t("classDetail.roomNotAssigned")}</p>
|
||||||
)}
|
)}
|
||||||
{classInfo.homeroom && (
|
{classInfo.homeroom && (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<User className="h-4 w-4 text-muted-foreground" />
|
<User className="h-4 w-4 text-muted-foreground" />
|
||||||
<span>Homeroom: {classInfo.homeroom}</span>
|
<span>{t("classDetail.homeroom", { homeroom: classInfo.homeroom })}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -191,15 +194,15 @@ export default async function StudentClassDetailPage({
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="flex items-center gap-2">
|
<CardTitle className="flex items-center gap-2">
|
||||||
<CalendarDays className="h-5 w-5" />
|
<CalendarDays className="h-5 w-5" />
|
||||||
Class Schedule
|
{t("classDetail.classSchedule")}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{classSchedule.length === 0 ? (
|
{classSchedule.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={CalendarDays}
|
icon={CalendarDays}
|
||||||
title="No schedule"
|
title={t("classDetail.noSchedule")}
|
||||||
description="No timetable entries found for this class."
|
description={t("classDetail.noScheduleDesc")}
|
||||||
className="border-none shadow-none"
|
className="border-none shadow-none"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -211,7 +214,7 @@ export default async function StudentClassDetailPage({
|
|||||||
>
|
>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Badge variant="outline" className="w-12 justify-center">
|
<Badge variant="outline" className="w-12 justify-center">
|
||||||
{WEEKDAYS[s.weekday]}
|
{t(`weekdays.${WEEKDAY_KEYS[s.weekday]}`)}
|
||||||
</Badge>
|
</Badge>
|
||||||
<div>
|
<div>
|
||||||
<p className="font-medium">{s.course}</p>
|
<p className="font-medium">{s.course}</p>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { UserX } from "lucide-react"
|
import { UserX } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getStudentClasses } from "@/modules/classes/data-access"
|
import { getStudentClasses } from "@/modules/classes/data-access"
|
||||||
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
||||||
@@ -14,17 +15,18 @@ export default async function StudentCoursesPage({
|
|||||||
}: {
|
}: {
|
||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}) {
|
}) {
|
||||||
|
const t = await getTranslations("student")
|
||||||
const student = await getCurrentStudentUser()
|
const student = await getCurrentStudentUser()
|
||||||
if (!student) {
|
if (!student) {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">Courses</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("courses.title")}</h2>
|
||||||
<p className="text-muted-foreground">Your enrolled classes.</p>
|
<p className="text-muted-foreground">{t("courses.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
title="No user found"
|
title={t("courses.noUser")}
|
||||||
description="Create a student user to see courses."
|
description={t("courses.noUserDesc")}
|
||||||
icon={UserX}
|
icon={UserX}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,8 +53,8 @@ export default async function StudentCoursesPage({
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">Courses</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("courses.title")}</h2>
|
||||||
<p className="text-muted-foreground">Your enrolled classes.</p>
|
<p className="text-muted-foreground">{t("courses.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
{classes.length > 0 && <CourseFilters />}
|
{classes.length > 0 && <CourseFilters />}
|
||||||
<StudentCoursesView classes={filteredClasses} />
|
<StudentCoursesView classes={filteredClasses} />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { BookOpen, PenTool, Library, ArrowRight } from "lucide-react"
|
import { BookOpen, PenTool, Library, ArrowRight, UserX } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getStudentClasses } from "@/modules/classes/data-access"
|
import { getStudentClasses } from "@/modules/classes/data-access"
|
||||||
import { getStudentHomeworkAssignments } from "@/modules/homework/data-access"
|
import { getStudentHomeworkAssignments } from "@/modules/homework/data-access"
|
||||||
@@ -7,16 +8,16 @@ import { getCurrentStudentUser } from "@/modules/users/data-access"
|
|||||||
import { getTextbooks } from "@/modules/textbooks/data-access"
|
import { getTextbooks } from "@/modules/textbooks/data-access"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
import { UserX } from "lucide-react"
|
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function StudentLearningPage() {
|
export default async function StudentLearningPage() {
|
||||||
|
const t = await getTranslations("student")
|
||||||
const student = await getCurrentStudentUser()
|
const student = await getCurrentStudentUser()
|
||||||
if (!student) {
|
if (!student) {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<EmptyState title="No user found" description="Create a student user to see learning." icon={UserX} />
|
<EmptyState title={t("learning.noUser")} description={t("learning.noUserDesc")} icon={UserX} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -40,33 +41,33 @@ export default async function StudentLearningPage() {
|
|||||||
|
|
||||||
const cards = [
|
const cards = [
|
||||||
{
|
{
|
||||||
title: "Courses",
|
title: t("learning.courses"),
|
||||||
description: "Your enrolled classes.",
|
description: t("learning.coursesDesc"),
|
||||||
icon: BookOpen,
|
icon: BookOpen,
|
||||||
href: "/student/learning/courses",
|
href: "/student/learning/courses",
|
||||||
stat: `${classes.length} enrolled`,
|
stat: t("learning.enrolled", { count: classes.length }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Assignments",
|
title: t("learning.assignments"),
|
||||||
description: "Homework and practice.",
|
description: t("learning.assignmentsDesc"),
|
||||||
icon: PenTool,
|
icon: PenTool,
|
||||||
href: "/student/learning/assignments",
|
href: "/student/learning/assignments",
|
||||||
stat: `${pendingCount} pending${dueSoonCount > 0 ? ` · ${dueSoonCount} due soon` : ""}`,
|
stat: t("learning.pending", { count: pendingCount }) + (dueSoonCount > 0 ? t("learning.dueSoon", { count: dueSoonCount }) : ""),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Textbooks",
|
title: t("learning.textbooks"),
|
||||||
description: "Browse course materials.",
|
description: t("learning.textbooksDesc"),
|
||||||
icon: Library,
|
icon: Library,
|
||||||
href: "/student/learning/textbooks",
|
href: "/student/learning/textbooks",
|
||||||
stat: `${textbooks.length} available`,
|
stat: t("learning.available", { count: textbooks.length }),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">My Learning</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("learning.title")}</h2>
|
||||||
<p className="text-muted-foreground">Your learning hub: courses, assignments, and textbooks.</p>
|
<p className="text-muted-foreground">{t("learning.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function StudentLessonPlanViewError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function StudentLessonPlanViewLoading() {
|
||||||
|
return (
|
||||||
|
<div className="h-[calc(100vh-4rem)]">
|
||||||
|
<div className="flex h-full items-center justify-center">
|
||||||
|
<Skeleton className="h-[80%] w-[80%]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import type { JSX } from "react"
|
||||||
|
import { Suspense } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
import { getAuthContext } from "@/shared/lib/auth-guard"
|
||||||
|
import { getLessonPlanById } from "@/modules/lesson-preparation/data-access"
|
||||||
|
import { getTextbookById, getChaptersByTextbookId } from "@/modules/textbooks/data-access"
|
||||||
|
import { LessonPlanReadonlyView } from "@/modules/lesson-preparation/components/lesson-plan-readonly-view"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function StudentLessonPlanViewPage({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ planId: string }>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
const { planId } = await params
|
||||||
|
const t = await getTranslations("lessonPreparation")
|
||||||
|
const ctx = await getAuthContext()
|
||||||
|
|
||||||
|
const plan = await getLessonPlanById(planId, ctx.userId)
|
||||||
|
if (!plan) {
|
||||||
|
return (
|
||||||
|
<div className="p-6">
|
||||||
|
<div className="rounded-md border border-outline-variant bg-surface-container-low p-4 text-on-surface-variant">
|
||||||
|
{t("readonly.notFound")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 学生只能查看已发布的课案
|
||||||
|
if (plan.status !== "published") {
|
||||||
|
return (
|
||||||
|
<div className="p-6">
|
||||||
|
<div className="rounded-md border border-outline-variant bg-surface-container-low p-4 text-on-surface-variant">
|
||||||
|
{t("readonly.notPublished")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拉取教材/章节标题
|
||||||
|
let textbookTitle: string | undefined
|
||||||
|
let chapterTitle: string | undefined
|
||||||
|
if (plan.textbookId) {
|
||||||
|
const textbook = await getTextbookById(plan.textbookId)
|
||||||
|
textbookTitle = textbook?.title
|
||||||
|
if (plan.chapterId) {
|
||||||
|
const chapters = await getChaptersByTextbookId(plan.textbookId)
|
||||||
|
const findChapter = (list: typeof chapters): typeof chapters[number] | undefined => {
|
||||||
|
for (const ch of list) {
|
||||||
|
if (ch.id === plan.chapterId) return ch
|
||||||
|
if (ch.children && ch.children.length > 0) {
|
||||||
|
const found = findChapter(ch.children as typeof chapters)
|
||||||
|
if (found) return found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const chapter = findChapter(chapters)
|
||||||
|
chapterTitle = chapter?.title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="h-[calc(100vh-4rem)]">
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="flex h-full items-center justify-center">
|
||||||
|
<Skeleton className="h-[80%] w-[80%]" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LessonPlanReadonlyView
|
||||||
|
doc={plan.content}
|
||||||
|
textbookTitle={textbookTitle}
|
||||||
|
chapterTitle={chapterTitle}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
20
src/app/(dashboard)/student/lesson-plans/error.tsx
Normal file
20
src/app/(dashboard)/student/lesson-plans/error.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function StudentLessonPlansError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
17
src/app/(dashboard)/student/lesson-plans/loading.tsx
Normal file
17
src/app/(dashboard)/student/lesson-plans/loading.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function StudentLessonPlansLoading() {
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-[180px]" />
|
||||||
|
<Skeleton className="h-4 w-[300px]" />
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[180px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
44
src/app/(dashboard)/student/lesson-plans/page.tsx
Normal file
44
src/app/(dashboard)/student/lesson-plans/page.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import type { JSX } from "react"
|
||||||
|
import { Suspense } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
import { getAuthContext } from "@/shared/lib/auth-guard"
|
||||||
|
import { getLessonPlans } from "@/modules/lesson-preparation/data-access"
|
||||||
|
import { getSubjectOptions } from "@/modules/school/data-access"
|
||||||
|
import { LessonPlanList } from "@/modules/lesson-preparation/components/lesson-plan-list"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function StudentLessonPlansPage(): Promise<JSX.Element> {
|
||||||
|
const t = await getTranslations("lessonPreparation")
|
||||||
|
const ctx = await getAuthContext()
|
||||||
|
|
||||||
|
const [items, subjects] = await Promise.all([
|
||||||
|
getLessonPlans({ status: "published" }, ctx.dataScope, ctx.userId),
|
||||||
|
getSubjectOptions(),
|
||||||
|
])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">{t("student.title")}</h1>
|
||||||
|
<p className="text-muted-foreground">{t("student.description")}</p>
|
||||||
|
</div>
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[180px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LessonPlanList
|
||||||
|
initialItems={items}
|
||||||
|
subjects={subjects}
|
||||||
|
viewMode="student"
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
32
src/app/(dashboard)/student/practice/[sessionId]/error.tsx
Normal file
32
src/app/(dashboard)/student/practice/[sessionId]/error.tsx
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useEffect } from "react"
|
||||||
|
import Link from "next/link"
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { Button } from "@/shared/components/ui/button"
|
||||||
|
|
||||||
|
export default function PracticeSessionError({
|
||||||
|
error,
|
||||||
|
reset,
|
||||||
|
}: {
|
||||||
|
error: Error & { digest?: string }
|
||||||
|
reset: () => void
|
||||||
|
}): React.ReactNode {
|
||||||
|
const t = useTranslations("student")
|
||||||
|
useEffect(() => {
|
||||||
|
console.error("Practice session error:", error)
|
||||||
|
}, [error])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||||
|
<h2 className="text-xl font-semibold">{t("error.title")}</h2>
|
||||||
|
<p className="text-sm text-muted-foreground">{error.message}</p>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button onClick={reset}>{t("error.retry")}</Button>
|
||||||
|
<Button variant="outline" asChild>
|
||||||
|
<Link href="/student/practice">{t("classDetail.backToCourses")}</Link>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
14
src/app/(dashboard)/student/practice/[sessionId]/loading.tsx
Normal file
14
src/app/(dashboard)/student/practice/[sessionId]/loading.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function PracticeSessionLoading(): React.ReactNode {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-6 p-8">
|
||||||
|
<Skeleton className="h-20 w-full rounded-md" />
|
||||||
|
<Skeleton className="h-96 w-full rounded-md" />
|
||||||
|
<div className="flex justify-between">
|
||||||
|
<Skeleton className="h-10 w-24 rounded-md" />
|
||||||
|
<Skeleton className="h-10 w-24 rounded-md" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
31
src/app/(dashboard)/student/practice/[sessionId]/page.tsx
Normal file
31
src/app/(dashboard)/student/practice/[sessionId]/page.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import type { JSX } from "react"
|
||||||
|
import { notFound } from "next/navigation"
|
||||||
|
|
||||||
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
|
|
||||||
|
import { getPracticeSessionById } from "@/modules/adaptive-practice/data-access"
|
||||||
|
import { PracticeSessionView } from "@/modules/adaptive-practice/components/practice-session-view"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function PracticeSessionPage({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ sessionId: string }>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
const ctx = await requirePermission(Permissions.ADAPTIVE_PRACTICE_READ)
|
||||||
|
const { sessionId } = await params
|
||||||
|
|
||||||
|
const session = await getPracticeSessionById(sessionId, ctx.userId)
|
||||||
|
|
||||||
|
if (!session) {
|
||||||
|
notFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-6 p-8">
|
||||||
|
<PracticeSessionView session={session} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
26
src/app/(dashboard)/student/practice/error.tsx
Normal file
26
src/app/(dashboard)/student/practice/error.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useEffect } from "react"
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { Button } from "@/shared/components/ui/button"
|
||||||
|
|
||||||
|
export default function PracticeError({
|
||||||
|
error,
|
||||||
|
reset,
|
||||||
|
}: {
|
||||||
|
error: Error & { digest?: string }
|
||||||
|
reset: () => void
|
||||||
|
}): React.ReactNode {
|
||||||
|
const t = useTranslations("student")
|
||||||
|
useEffect(() => {
|
||||||
|
console.error("Practice page error:", error)
|
||||||
|
}, [error])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||||
|
<h2 className="text-xl font-semibold">{t("error.title")}</h2>
|
||||||
|
<p className="text-sm text-muted-foreground">{error.message}</p>
|
||||||
|
<Button onClick={reset}>{t("error.retry")}</Button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
25
src/app/(dashboard)/student/practice/loading.tsx
Normal file
25
src/app/(dashboard)/student/practice/loading.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function PracticeLoading(): React.ReactNode {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-48" />
|
||||||
|
<Skeleton className="h-4 w-72" />
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-4 md:grid-cols-4">
|
||||||
|
{Array.from({ length: 4 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-24 w-full rounded-md" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-6 lg:grid-cols-3">
|
||||||
|
<Skeleton className="h-96 w-full rounded-md" />
|
||||||
|
<div className="space-y-3 lg:col-span-2">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-20 w-full rounded-md" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
45
src/app/(dashboard)/student/practice/page.tsx
Normal file
45
src/app/(dashboard)/student/practice/page.tsx
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import type { JSX } from "react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
|
|
||||||
|
import { getPracticeSessions, getPracticeStats } from "@/modules/adaptive-practice/data-access"
|
||||||
|
import { PracticeStarter } from "@/modules/adaptive-practice/components/practice-starter"
|
||||||
|
import { PracticeHistory } from "@/modules/adaptive-practice/components/practice-history"
|
||||||
|
import { PracticeStatsCards } from "@/modules/adaptive-practice/components/practice-stats-cards"
|
||||||
|
import { getKnowledgePointOptions } from "@/modules/questions/data-access"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function StudentPracticePage(): Promise<JSX.Element> {
|
||||||
|
const ctx = await requirePermission(Permissions.ADAPTIVE_PRACTICE_READ)
|
||||||
|
const t = await getTranslations("practice")
|
||||||
|
|
||||||
|
const [stats, sessionsResult, knowledgePoints] = await Promise.all([
|
||||||
|
getPracticeStats(ctx.userId),
|
||||||
|
getPracticeSessions(ctx.userId, { pageSize: 20 }),
|
||||||
|
getKnowledgePointOptions(),
|
||||||
|
])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">{t("page.title")}</h1>
|
||||||
|
<p className="text-muted-foreground">{t("page.description")}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<PracticeStatsCards stats={stats} />
|
||||||
|
|
||||||
|
<div className="grid gap-6 lg:grid-cols-3">
|
||||||
|
<div className="lg:col-span-1">
|
||||||
|
<PracticeStarter knowledgePoints={knowledgePoints} />
|
||||||
|
</div>
|
||||||
|
<div className="lg:col-span-2 space-y-4">
|
||||||
|
<h2 className="text-lg font-semibold">{t("history.title")}</h2>
|
||||||
|
<PracticeHistory sessions={sessionsResult.data} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { UserX } from "lucide-react"
|
import { UserX } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
import { getStudentClasses, getStudentSchedule } from "@/modules/classes/data-access"
|
import { getStudentClasses, getStudentSchedule } from "@/modules/classes/data-access"
|
||||||
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
import { getCurrentStudentUser } from "@/modules/users/data-access"
|
||||||
@@ -14,15 +15,20 @@ export default async function StudentSchedulePage({
|
|||||||
}: {
|
}: {
|
||||||
searchParams: Promise<SearchParams>
|
searchParams: Promise<SearchParams>
|
||||||
}) {
|
}) {
|
||||||
|
const t = await getTranslations("student")
|
||||||
const student = await getCurrentStudentUser()
|
const student = await getCurrentStudentUser()
|
||||||
if (!student) {
|
if (!student) {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">Schedule</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("schedule.title")}</h2>
|
||||||
<p className="text-muted-foreground">Your weekly timetable.</p>
|
<p className="text-muted-foreground">{t("schedule.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState title="No user found" description="Create a student user to see schedule." icon={UserX} />
|
<EmptyState
|
||||||
|
title={t("schedule.noUser")}
|
||||||
|
description={t("schedule.noUserDesc")}
|
||||||
|
icon={UserX}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -41,8 +47,8 @@ export default async function StudentSchedulePage({
|
|||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div className="flex flex-col justify-between gap-4 md:flex-row md:items-center">
|
<div className="flex flex-col justify-between gap-4 md:flex-row md:items-center">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold tracking-tight">Schedule</h2>
|
<h2 className="text-2xl font-bold tracking-tight">{t("schedule.title")}</h2>
|
||||||
<p className="text-muted-foreground">Your weekly timetable.</p>
|
<p className="text-muted-foreground">{t("schedule.description")}</p>
|
||||||
</div>
|
</div>
|
||||||
<StudentScheduleFilters classes={classes} />
|
<StudentScheduleFilters classes={classes} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,36 +1,52 @@
|
|||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
|
import { Suspense } from "react"
|
||||||
import { BarChart3 } from "lucide-react"
|
import { BarChart3 } from "lucide-react"
|
||||||
|
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||||
import { getStudentIdsByClassIds, getClassIdsByGradeIds } from "@/modules/classes/data-access"
|
import { getStudentIdsByClassIds, getClassIdsByGradeIds } from "@/modules/classes/data-access"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getStudentErrorBookSummaries,
|
getStudentErrorBookSummaries,
|
||||||
getTopWrongQuestionsByStudentIds,
|
getTopWrongQuestionsByStudentIds,
|
||||||
getKnowledgePointWeakness,
|
getKnowledgePointWeakness,
|
||||||
getSubjectErrorDistribution,
|
|
||||||
getStudentNameMap,
|
getStudentNameMap,
|
||||||
|
getSubjectErrorOverviews,
|
||||||
|
getClassErrorOverviews,
|
||||||
|
getChapterWeakness,
|
||||||
} from "@/modules/error-book/data-access"
|
} from "@/modules/error-book/data-access"
|
||||||
import { ClassErrorBookOverview, StudentErrorTable } from "@/modules/error-book/components/class-error-overview"
|
|
||||||
import { TopWrongQuestions } from "@/modules/error-book/components/top-wrong-questions"
|
import { TopWrongQuestions } from "@/modules/error-book/components/top-wrong-questions"
|
||||||
|
import { SubjectTabs } from "@/modules/error-book/components/subject-tabs"
|
||||||
|
import { ClassFilter } from "@/modules/error-book/components/class-filter"
|
||||||
|
import { AnalyticsStatsCards } from "@/modules/error-book/components/analytics-stats-cards"
|
||||||
|
import { ClassErrorBarChart } from "@/modules/error-book/components/class-error-bar-chart"
|
||||||
|
import { KnowledgePointWeaknessChart } from "@/modules/error-book/components/knowledge-point-weakness-chart"
|
||||||
|
import { ChapterWeaknessChart } from "@/modules/error-book/components/chapter-weakness-chart"
|
||||||
|
import { GroupedStudentErrorTable } from "@/modules/error-book/components/grouped-student-error-table"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
export default async function TeacherErrorBookPage(): Promise<JSX.Element> {
|
async function TeacherErrorBookContent({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<SearchParams>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
const ctx = await requirePermission(Permissions.ERROR_BOOK_ANALYTICS_READ)
|
const ctx = await requirePermission(Permissions.ERROR_BOOK_ANALYTICS_READ)
|
||||||
|
|
||||||
// 教师的 dataScope 为 class_taught,年级主任/教研组长为 grade_managed,管理员为 all
|
const params = await searchParams
|
||||||
const classIds = ctx.dataScope.type === "class_taught" ? ctx.dataScope.classIds : []
|
const classIds = ctx.dataScope.type === "class_taught" ? ctx.dataScope.classIds : []
|
||||||
const gradeIds = ctx.dataScope.type === "grade_managed" ? ctx.dataScope.gradeIds : []
|
const gradeIds = ctx.dataScope.type === "grade_managed" ? ctx.dataScope.gradeIds : []
|
||||||
|
const teacherSubjectIds = ctx.dataScope.type === "class_taught" ? (ctx.dataScope.subjectIds ?? []) : []
|
||||||
|
|
||||||
if (classIds.length === 0 && gradeIds.length === 0 && ctx.dataScope.type !== "all") {
|
if (classIds.length === 0 && gradeIds.length === 0 && ctx.dataScope.type !== "all") {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">错题分析</h1>
|
<h1 className="text-2xl font-bold tracking-tight">错题分析</h1>
|
||||||
<p className="text-muted-foreground">查看班级学生的错题统计与薄弱知识点。</p>
|
<p className="text-muted-foreground">按学科、班级查看学生的错题统计与薄弱知识点。</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
@@ -42,21 +58,22 @@ export default async function TeacherErrorBookPage(): Promise<JSX.Element> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 年级主任/教研组长:先根据 gradeIds 查询班级,再查询学生
|
// 年级主任/教研组长:展开年级为班级
|
||||||
let targetClassIds = classIds
|
let targetClassIds = classIds
|
||||||
if (gradeIds.length > 0) {
|
if (gradeIds.length > 0) {
|
||||||
const gradeClassIds = await getClassIdsByGradeIds(gradeIds)
|
const gradeClassIds = await getClassIdsByGradeIds(gradeIds)
|
||||||
targetClassIds = [...new Set([...classIds, ...gradeClassIds])]
|
targetClassIds = [...new Set([...classIds, ...gradeClassIds])]
|
||||||
}
|
}
|
||||||
|
|
||||||
const studentIds = await getStudentIdsByClassIds(targetClassIds)
|
// 获取所有学生 ID(用于学科概览查询)
|
||||||
|
const allStudentIds = await getStudentIdsByClassIds(targetClassIds)
|
||||||
|
|
||||||
if (studentIds.length === 0) {
|
if (allStudentIds.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">错题分析</h1>
|
<h1 className="text-2xl font-bold tracking-tight">错题分析</h1>
|
||||||
<p className="text-muted-foreground">查看班级学生的错题统计与薄弱知识点。</p>
|
<p className="text-muted-foreground">按学科、班级查看学生的错题统计与薄弱知识点。</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={BarChart3}
|
icon={BarChart3}
|
||||||
@@ -68,52 +85,168 @@ export default async function TeacherErrorBookPage(): Promise<JSX.Element> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 并行查询所有统计数据
|
// 解析 URL 参数:学科筛选 + 班级筛选
|
||||||
const [summaries, topWrongQuestions, weakKps, subjectDist, nameMap] = await Promise.all([
|
const subjectParam = getParam(params, "subject")
|
||||||
getStudentErrorBookSummaries(studentIds),
|
const classParam = getParam(params, "classId")
|
||||||
getTopWrongQuestionsByStudentIds(studentIds, 10),
|
|
||||||
getKnowledgePointWeakness(studentIds, 10),
|
// 学科概览(用于 Tab 显示,不受学科筛选影响)
|
||||||
getSubjectErrorDistribution(studentIds),
|
const subjectOverviews = await getSubjectErrorOverviews(allStudentIds)
|
||||||
getStudentNameMap(studentIds),
|
|
||||||
|
// 班级概览(用于班级筛选器显示,受学科筛选影响)
|
||||||
|
const classOverviews = await getClassErrorOverviews(targetClassIds, subjectParam)
|
||||||
|
|
||||||
|
// 确定实际查询的学科和班级
|
||||||
|
// 如果教师有所教学科,默认只显示所教学科;否则显示全部
|
||||||
|
const effectiveSubjectId =
|
||||||
|
subjectParam ?? (teacherSubjectIds.length === 1 ? teacherSubjectIds[0] : null)
|
||||||
|
const effectiveClassId = classParam ?? "all"
|
||||||
|
|
||||||
|
// 确定查询的学生范围(按班级筛选)
|
||||||
|
const queryClassIds = effectiveClassId === "all" ? targetClassIds : [effectiveClassId]
|
||||||
|
const queryStudentIds = await getStudentIdsByClassIds(queryClassIds)
|
||||||
|
|
||||||
|
// 并行查询所有统计数据(按学科+班级过滤)
|
||||||
|
const [summaries, topWrongQuestions, weakKps, chapterWeakness, nameMap] = await Promise.all([
|
||||||
|
getStudentErrorBookSummaries(queryStudentIds, effectiveSubjectId),
|
||||||
|
getTopWrongQuestionsByStudentIds(queryStudentIds, 10, effectiveSubjectId),
|
||||||
|
getKnowledgePointWeakness(queryStudentIds, 10, effectiveSubjectId),
|
||||||
|
getChapterWeakness(queryStudentIds, 10, effectiveSubjectId),
|
||||||
|
getStudentNameMap(queryStudentIds),
|
||||||
])
|
])
|
||||||
|
|
||||||
const studentsWithErrorBook = summaries.filter((s) => s.totalCount > 0)
|
const studentsWithErrorBook = summaries.filter((s) => s.totalCount > 0)
|
||||||
const totalErrorItems = summaries.reduce((sum, s) => sum + s.totalCount, 0)
|
const totalErrorItems = summaries.reduce((sum, s) => sum + s.totalCount, 0)
|
||||||
|
const totalDueReview = summaries.reduce((sum, s) => sum + s.dueReviewCount, 0)
|
||||||
const averageMasteryRate = studentsWithErrorBook.length > 0
|
const averageMasteryRate = studentsWithErrorBook.length > 0
|
||||||
? studentsWithErrorBook.reduce((sum, s) => sum + s.masteredRate, 0) / studentsWithErrorBook.length
|
? studentsWithErrorBook.reduce((sum, s) => sum + s.masteredRate, 0) / studentsWithErrorBook.length
|
||||||
: 0
|
: 0
|
||||||
|
const knowledgePointCount = weakKps.length
|
||||||
|
|
||||||
// 按错题数降序排列
|
// 按错题数降序排列
|
||||||
const sortedSummaries = [...summaries].sort((a, b) => b.totalCount - a.totalCount)
|
const sortedSummaries = [...summaries].sort((a, b) => b.totalCount - a.totalCount)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full flex-col space-y-8 p-8">
|
<div className="flex h-full flex-col space-y-6 p-8">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">错题分析</h1>
|
<h1 className="text-2xl font-bold tracking-tight">错题分析</h1>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
查看班级学生的错题统计与薄弱知识点,辅助精准教学。
|
按学科、班级查看学生的错题统计与薄弱知识点,辅助精准教学。
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ClassErrorBookOverview
|
{/* 学科 Tab */}
|
||||||
totalStudents={studentIds.length}
|
{subjectOverviews.length > 0 ? (
|
||||||
|
<Suspense fallback={<Skeleton className="h-10 w-full" />}>
|
||||||
|
<SubjectTabs
|
||||||
|
subjects={subjectOverviews}
|
||||||
|
currentSubjectId={effectiveSubjectId}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 班级筛选器 */}
|
||||||
|
{classOverviews.length > 0 ? (
|
||||||
|
<Suspense fallback={<Skeleton className="h-10 w-full" />}>
|
||||||
|
<ClassFilter
|
||||||
|
classes={classOverviews}
|
||||||
|
currentClassId={effectiveClassId}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 统计卡片 */}
|
||||||
|
<AnalyticsStatsCards
|
||||||
|
totalStudents={queryStudentIds.length}
|
||||||
studentsWithErrorBook={studentsWithErrorBook.length}
|
studentsWithErrorBook={studentsWithErrorBook.length}
|
||||||
totalErrorItems={totalErrorItems}
|
totalErrorItems={totalErrorItems}
|
||||||
averageMasteryRate={averageMasteryRate}
|
averageMasteryRate={averageMasteryRate}
|
||||||
topWeakKnowledgePoints={weakKps}
|
dueReviewCount={totalDueReview}
|
||||||
subjectDistribution={subjectDist}
|
knowledgePointCount={knowledgePointCount}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="space-y-4">
|
{/* 班级错题对比图(仅在"全部班级"视图下显示) */}
|
||||||
<h2 className="text-lg font-semibold">学生错题详情</h2>
|
{effectiveClassId === "all" && classOverviews.length > 1 ? (
|
||||||
<StudentErrorTable
|
<ClassErrorBarChart data={classOverviews} />
|
||||||
students={sortedSummaries}
|
) : null}
|
||||||
studentNames={nameMap}
|
|
||||||
basePath="/teacher/error-book"
|
{/* 章节错题分布 + 知识点薄弱度(并排) */}
|
||||||
/>
|
<div className="grid gap-4 lg:grid-cols-2">
|
||||||
|
{chapterWeakness.length > 0 ? (
|
||||||
|
<ChapterWeaknessChart data={chapterWeakness} />
|
||||||
|
) : (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title="暂无章节错题数据"
|
||||||
|
description="尚未关联知识点到章节,无法显示章节维度统计。"
|
||||||
|
className="h-[300px] bg-card"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{weakKps.length > 0 ? (
|
||||||
|
<KnowledgePointWeaknessChart data={weakKps} />
|
||||||
|
) : (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title="暂无知识点数据"
|
||||||
|
description="错题尚未关联知识点,无法显示薄弱知识点统计。"
|
||||||
|
className="h-[300px] bg-card"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TopWrongQuestions questions={topWrongQuestions} />
|
{/* 学生错题详情(按班级分组) */}
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<h2 className="text-lg font-semibold">学生错题详情</h2>
|
||||||
|
<span className="text-sm text-muted-foreground">
|
||||||
|
共 {queryStudentIds.length} 名学生,{studentsWithErrorBook.length} 名有错题
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{sortedSummaries.length > 0 ? (
|
||||||
|
<GroupedStudentErrorTable
|
||||||
|
students={sortedSummaries}
|
||||||
|
studentNames={nameMap}
|
||||||
|
basePath="/teacher/error-book"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title="暂无学生错题"
|
||||||
|
description="所选范围内没有学生错题数据。"
|
||||||
|
className="h-[200px] bg-card"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 高频错题 Top 10 */}
|
||||||
|
{topWrongQuestions.length > 0 ? (
|
||||||
|
<TopWrongQuestions questions={topWrongQuestions} />
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default async function TeacherErrorBookPage({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<SearchParams>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
return (
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<Skeleton className="h-10 w-48" />
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-5">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[100px]" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-[300px] w-full" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<TeacherErrorBookContent searchParams={searchParams} />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import type { JSX } from "react"
|
import type { JSX } from "react"
|
||||||
import { getTeacherClasses } from "@/modules/classes/data-access"
|
import { getTeacherClasses, getClassGradeIdsByClassIds } from "@/modules/classes/data-access"
|
||||||
import { getClassStudentsForEntry } from "@/modules/grades/data-access"
|
import { getClassStudentsForEntry } from "@/modules/grades/data-access"
|
||||||
import { getSubjectOptions } from "@/modules/school/data-access"
|
import { getExamsForGradeEntry, getExamForGradeEntry } from "@/modules/exams/data-access"
|
||||||
import { BatchGradeEntry } from "@/modules/grades/components/batch-grade-entry"
|
import { BatchGradeEntryByExam } from "@/modules/grades/components/batch-grade-entry"
|
||||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
import { Permissions } from "@/shared/types/permissions"
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||||
@@ -19,63 +19,73 @@ export default async function BatchEntryPage({
|
|||||||
const ctx = await requirePermission(Permissions.GRADE_RECORD_MANAGE)
|
const ctx = await requirePermission(Permissions.GRADE_RECORD_MANAGE)
|
||||||
const sp = await searchParams
|
const sp = await searchParams
|
||||||
|
|
||||||
const defaultClassId = getParam(sp, "classId")
|
const examId = getParam(sp, "examId")
|
||||||
const defaultSubjectId = getParam(sp, "subjectId")
|
const classId = getParam(sp, "classId")
|
||||||
|
|
||||||
// P3 修复:添加 scope 校验,对 class_taught scope 限制可录入的班级
|
// 获取试卷列表 + 班级列表
|
||||||
const [classes, allSubjects, students] = await Promise.all([
|
const [exams, teacherClasses] = await Promise.all([
|
||||||
|
getExamsForGradeEntry(ctx.dataScope),
|
||||||
getTeacherClasses(),
|
getTeacherClasses(),
|
||||||
getSubjectOptions(),
|
|
||||||
defaultClassId
|
|
||||||
? getClassStudentsForEntry(defaultClassId, ctx.dataScope)
|
|
||||||
: Promise.resolve([] as Awaited<ReturnType<typeof getClassStudentsForEntry>>),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
// 对 class_taught scope,过滤掉不在 scope 中的班级
|
// scope 过滤班级
|
||||||
const allowedClassIds =
|
const allowedClassIds =
|
||||||
ctx.dataScope.type === "class_taught" ? ctx.dataScope.classIds : null
|
ctx.dataScope.type === "class_taught" ? ctx.dataScope.classIds : null
|
||||||
const scopedClasses = allowedClassIds
|
const scopedClasses = allowedClassIds
|
||||||
? classes.filter((c) => allowedClassIds.includes(c.id))
|
? teacherClasses.filter((c) => allowedClassIds.includes(c.id))
|
||||||
: classes
|
: teacherClasses
|
||||||
|
|
||||||
const classOptions = scopedClasses.map((c) => ({ id: c.id, name: c.name }))
|
const classOptions = scopedClasses.map((c) => ({ id: c.id, name: c.name }))
|
||||||
const subjectOptions = allSubjects.map((s) => ({ id: s.id, name: s.name }))
|
|
||||||
|
|
||||||
// 如果指定了 classId 但 scope 不允许,显示提示
|
// 获取 classId → gradeId 映射(用于客户端按试卷年级过滤班级)
|
||||||
if (defaultClassId && students.length === 0 && scopedClasses.length > 0) {
|
const classGradeMap: Record<string, string> = {}
|
||||||
const classExists = scopedClasses.some((c) => c.id === defaultClassId)
|
if (scopedClasses.length > 0) {
|
||||||
if (!classExists) {
|
const gradeMap = await getClassGradeIdsByClassIds(
|
||||||
return (
|
scopedClasses.map((c) => c.id)
|
||||||
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
|
)
|
||||||
<div>
|
for (const [cid, gid] of gradeMap.entries()) {
|
||||||
<h1 className="text-2xl font-bold tracking-tight">Batch Grade Entry</h1>
|
classGradeMap[cid] = gid
|
||||||
<p className="text-muted-foreground">Enter grades for all students in a class at once.</p>
|
|
||||||
</div>
|
|
||||||
<EmptyState
|
|
||||||
title="无权访问该班级"
|
|
||||||
description="您没有权限为该班级录入成绩。"
|
|
||||||
icon={ClipboardList}
|
|
||||||
className="border-none shadow-none"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果有 examId,获取试卷详情(含题目列表)
|
||||||
|
const exam = examId
|
||||||
|
? await getExamForGradeEntry(examId, ctx.dataScope)
|
||||||
|
: null
|
||||||
|
|
||||||
|
// 如果有 examId + classId,获取学生列表
|
||||||
|
const students =
|
||||||
|
examId && classId
|
||||||
|
? await getClassStudentsForEntry(classId, ctx.dataScope)
|
||||||
|
: []
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
|
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">Batch Grade Entry</h1>
|
<h1 className="text-2xl font-bold tracking-tight">批量录入成绩</h1>
|
||||||
<p className="text-muted-foreground">Enter grades for all students in a class at once.</p>
|
<p className="text-muted-foreground">
|
||||||
|
从试卷库选择试卷,按每题得分录入,像填 Excel 表格一样。
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<BatchGradeEntry
|
{exams.length === 0 ? (
|
||||||
classes={classOptions}
|
<EmptyState
|
||||||
subjects={subjectOptions}
|
title="没有可用的试卷"
|
||||||
students={students}
|
description="请先在试卷管理中创建试卷并添加题目,才能录入成绩。"
|
||||||
defaultClassId={defaultClassId}
|
icon={ClipboardList}
|
||||||
defaultSubjectId={defaultSubjectId}
|
className="border-none shadow-none"
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<BatchGradeEntryByExam
|
||||||
|
exams={exams}
|
||||||
|
classes={classOptions}
|
||||||
|
classGradeMap={classGradeMap}
|
||||||
|
exam={exam}
|
||||||
|
students={students}
|
||||||
|
defaultExamId={examId}
|
||||||
|
defaultClassId={classId}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function EditLessonPlanError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function TeacherEditLessonPlanLoading() {
|
||||||
|
return (
|
||||||
|
<div className="h-[calc(100vh-4rem)]">
|
||||||
|
<div className="flex h-full items-center justify-center">
|
||||||
|
<Skeleton className="h-[80%] w-[80%]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { Suspense } from "react"
|
|||||||
import { notFound } from "next/navigation"
|
import { notFound } from "next/navigation"
|
||||||
import { getLessonPlanById } from "@/modules/lesson-preparation/data-access"
|
import { getLessonPlanById } from "@/modules/lesson-preparation/data-access"
|
||||||
import { LessonPlanEditor } from "@/modules/lesson-preparation/components/lesson-plan-editor"
|
import { LessonPlanEditor } from "@/modules/lesson-preparation/components/lesson-plan-editor"
|
||||||
|
import { LessonPlanProviderSetup } from "@/modules/lesson-preparation/providers/lesson-plan-provider-setup"
|
||||||
import { getTeacherClasses } from "@/modules/classes/data-access"
|
import { getTeacherClasses } from "@/modules/classes/data-access"
|
||||||
import { getTextbookById, getChaptersByTextbookId } from "@/modules/textbooks/data-access"
|
import { getTextbookById, getChaptersByTextbookId } from "@/modules/textbooks/data-access"
|
||||||
import { getAuthContext } from "@/shared/lib/auth-guard"
|
import { getAuthContext } from "@/shared/lib/auth-guard"
|
||||||
@@ -82,26 +83,29 @@ export default async function EditLessonPlanPage({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AiClientProvider service={aiClientService}>
|
<AiClientProvider service={aiClientService}>
|
||||||
<div className="h-[calc(100vh-4rem)]">
|
<LessonPlanProviderSetup>
|
||||||
<Suspense
|
<div className="h-[calc(100vh-4rem)]">
|
||||||
fallback={
|
<Suspense
|
||||||
<div className="flex h-full items-center justify-center">
|
fallback={
|
||||||
<Skeleton className="h-[80%] w-[80%]" />
|
<div className="flex h-full items-center justify-center">
|
||||||
</div>
|
<Skeleton className="h-[80%] w-[80%]" />
|
||||||
}
|
</div>
|
||||||
>
|
}
|
||||||
<LessonPlanEditor
|
>
|
||||||
planId={plan.id}
|
<LessonPlanEditor
|
||||||
initialTitle={plan.title}
|
planId={plan.id}
|
||||||
initialDoc={plan.content}
|
initialTitle={plan.title}
|
||||||
textbookId={plan.textbookId ?? undefined}
|
initialDoc={plan.content}
|
||||||
chapterId={plan.chapterId ?? undefined}
|
initialStatus={plan.status}
|
||||||
textbookTitle={textbookTitle}
|
textbookId={plan.textbookId ?? undefined}
|
||||||
chapterTitle={chapterTitle}
|
chapterId={plan.chapterId ?? undefined}
|
||||||
classes={classes}
|
textbookTitle={textbookTitle}
|
||||||
/>
|
chapterTitle={chapterTitle}
|
||||||
</Suspense>
|
classes={classes}
|
||||||
</div>
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
</LessonPlanProviderSetup>
|
||||||
</AiClientProvider>
|
</AiClientProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/app/(dashboard)/teacher/lesson-plans/error.tsx
Normal file
20
src/app/(dashboard)/teacher/lesson-plans/error.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function LessonPlansError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
25
src/app/(dashboard)/teacher/lesson-plans/loading.tsx
Normal file
25
src/app/(dashboard)/teacher/lesson-plans/loading.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function TeacherLessonPlansLoading() {
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<div className="flex justify-between items-center">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-8 w-[180px]" />
|
||||||
|
<Skeleton className="h-4 w-[300px]" />
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-9 w-[120px]" />
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-2 flex-wrap items-center">
|
||||||
|
<Skeleton className="h-9 w-[240px]" />
|
||||||
|
<Skeleton className="h-9 w-[160px]" />
|
||||||
|
<Skeleton className="h-9 w-[160px]" />
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[180px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
20
src/app/(dashboard)/teacher/lesson-plans/new/error.tsx
Normal file
20
src/app/(dashboard)/teacher/lesson-plans/new/error.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl"
|
||||||
|
import { BookOpen } from "lucide-react"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function NewLessonPlanError() {
|
||||||
|
const t = useTranslations("lessonPreparation")
|
||||||
|
return (
|
||||||
|
<div className="p-8">
|
||||||
|
<EmptyState
|
||||||
|
icon={BookOpen}
|
||||||
|
title={t("error.loadFailed")}
|
||||||
|
description={t("error.loadFailedDesc")}
|
||||||
|
action={{ label: t("error.retry"), onClick: () => window.location.reload() }}
|
||||||
|
className="border-none shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
20
src/app/(dashboard)/teacher/lesson-plans/new/loading.tsx
Normal file
20
src/app/(dashboard)/teacher/lesson-plans/new/loading.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function TeacherNewLessonPlanLoading() {
|
||||||
|
return (
|
||||||
|
<div className="p-6">
|
||||||
|
<div className="mb-6 flex items-center gap-4">
|
||||||
|
<Skeleton className="h-9 w-[120px]" />
|
||||||
|
<Skeleton className="h-8 w-[180px]" />
|
||||||
|
</div>
|
||||||
|
<div className="max-w-3xl mx-auto p-6 space-y-6">
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||||
|
{Array.from({ length: 4 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[100px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import { getTranslations } from "next-intl/server"
|
|||||||
import { Button } from "@/shared/components/ui/button"
|
import { Button } from "@/shared/components/ui/button"
|
||||||
import { Skeleton } from "@/shared/components/ui/skeleton"
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
import { TemplatePicker } from "@/modules/lesson-preparation/components/template-picker"
|
import { TemplatePicker } from "@/modules/lesson-preparation/components/template-picker"
|
||||||
|
import { LessonPlanProviderSetup } from "@/modules/lesson-preparation/providers/lesson-plan-provider-setup"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
@@ -22,20 +23,22 @@ export default async function NewLessonPlanPage(): Promise<JSX.Element> {
|
|||||||
</Button>
|
</Button>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">{t("title.new")}</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{t("title.new")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<Suspense
|
<LessonPlanProviderSetup>
|
||||||
fallback={
|
<Suspense
|
||||||
<div className="max-w-3xl mx-auto p-6 space-y-6">
|
fallback={
|
||||||
<Skeleton className="h-10 w-full" />
|
<div className="max-w-3xl mx-auto p-6 space-y-6">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
<Skeleton className="h-10 w-full" />
|
||||||
{Array.from({ length: 4 }).map((_, i) => (
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||||
<Skeleton key={i} className="h-[100px] w-full" />
|
{Array.from({ length: 4 }).map((_, i) => (
|
||||||
))}
|
<Skeleton key={i} className="h-[100px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
}
|
||||||
}
|
>
|
||||||
>
|
<TemplatePicker />
|
||||||
<TemplatePicker />
|
</Suspense>
|
||||||
</Suspense>
|
</LessonPlanProviderSetup>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { getAuthContext } from "@/shared/lib/auth-guard"
|
|||||||
import { getLessonPlans } from "@/modules/lesson-preparation/data-access"
|
import { getLessonPlans } from "@/modules/lesson-preparation/data-access"
|
||||||
import { getSubjectOptions } from "@/modules/school/data-access"
|
import { getSubjectOptions } from "@/modules/school/data-access"
|
||||||
import { LessonPlanList } from "@/modules/lesson-preparation/components/lesson-plan-list"
|
import { LessonPlanList } from "@/modules/lesson-preparation/components/lesson-plan-list"
|
||||||
|
import { LessonPlanProviderSetup } from "@/modules/lesson-preparation/providers/lesson-plan-provider-setup"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
@@ -37,24 +38,26 @@ export default async function LessonPlansPage(): Promise<JSX.Element> {
|
|||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<Suspense
|
<LessonPlanProviderSetup>
|
||||||
fallback={
|
<Suspense
|
||||||
<div className="space-y-4">
|
fallback={
|
||||||
<div className="flex gap-2 flex-wrap items-center">
|
<div className="space-y-4">
|
||||||
<Skeleton className="h-9 w-[240px]" />
|
<div className="flex gap-2 flex-wrap items-center">
|
||||||
<Skeleton className="h-9 w-[160px]" />
|
<Skeleton className="h-9 w-[240px]" />
|
||||||
<Skeleton className="h-9 w-[160px]" />
|
<Skeleton className="h-9 w-[160px]" />
|
||||||
|
<Skeleton className="h-9 w-[160px]" />
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[180px] w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
}
|
||||||
{Array.from({ length: 6 }).map((_, i) => (
|
>
|
||||||
<Skeleton key={i} className="h-[180px] w-full" />
|
<LessonPlanList initialItems={items} subjects={subjects} />
|
||||||
))}
|
</Suspense>
|
||||||
</div>
|
</LessonPlanProviderSetup>
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<LessonPlanList initialItems={items} subjects={subjects} />
|
|
||||||
</Suspense>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/app/(dashboard)/teacher/practice/error.tsx
Normal file
27
src/app/(dashboard)/teacher/practice/error.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { useEffect } from "react"
|
||||||
|
import { BarChart3 } from "lucide-react"
|
||||||
|
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
|
||||||
|
export default function Error() {
|
||||||
|
useEffect(() => {
|
||||||
|
console.error("Practice analytics page error")
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">专项练习分析</h1>
|
||||||
|
<p className="text-muted-foreground">加载练习分析数据时发生错误</p>
|
||||||
|
</div>
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title="加载失败"
|
||||||
|
description="请刷新页面重试,或联系管理员检查数据访问权限。"
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
17
src/app/(dashboard)/teacher/practice/loading.tsx
Normal file
17
src/app/(dashboard)/teacher/practice/loading.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
|
||||||
|
export default function Loading() {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<Skeleton className="h-10 w-48" />
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-5">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[100px]" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-[300px] w-full" />
|
||||||
|
<Skeleton className="h-[280px] w-full" />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
273
src/app/(dashboard)/teacher/practice/page.tsx
Normal file
273
src/app/(dashboard)/teacher/practice/page.tsx
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
import type { Metadata } from "next"
|
||||||
|
import type { JSX } from "react"
|
||||||
|
import { Suspense } from "react"
|
||||||
|
import { BarChart3 } from "lucide-react"
|
||||||
|
import { getTranslations } from "next-intl/server"
|
||||||
|
|
||||||
|
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||||
|
import { Permissions } from "@/shared/types/permissions"
|
||||||
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||||
|
import { Skeleton } from "@/shared/components/ui/skeleton"
|
||||||
|
import { getParam, type SearchParams } from "@/shared/lib/search-params"
|
||||||
|
import {
|
||||||
|
getClassIdsByGradeIds,
|
||||||
|
getStudentIdsByClassIds,
|
||||||
|
} from "@/modules/classes/data-access"
|
||||||
|
|
||||||
|
import {
|
||||||
|
getTeacherClassPracticeOverviews,
|
||||||
|
getClassStudentPracticeSummaries,
|
||||||
|
getPracticeTypeBreakdown,
|
||||||
|
getClassKnowledgePointWeakness,
|
||||||
|
getStudentsWithoutPractice,
|
||||||
|
getStudentNameMap,
|
||||||
|
} from "@/modules/adaptive-practice/data-access-analytics"
|
||||||
|
import { PracticeOverviewStatsCards } from "@/modules/adaptive-practice/components/practice-overview-stats-cards"
|
||||||
|
import { ClassPracticeComparisonTable } from "@/modules/adaptive-practice/components/class-practice-comparison-table"
|
||||||
|
import { PracticeTypeBreakdownChart } from "@/modules/adaptive-practice/components/practice-type-breakdown-chart"
|
||||||
|
import { ClassKnowledgePointWeaknessChart } from "@/modules/adaptive-practice/components/class-knowledge-point-weakness-chart"
|
||||||
|
import { StudentPracticeRankingTable } from "@/modules/adaptive-practice/components/student-practice-ranking-table"
|
||||||
|
import { InactiveStudentsAlert } from "@/modules/adaptive-practice/components/inactive-students-alert"
|
||||||
|
import { ClassFilter } from "@/modules/error-book/components/class-filter"
|
||||||
|
import type { ClassErrorOverview } from "@/modules/error-book/types"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
|
const t = await getTranslations("practice")
|
||||||
|
return {
|
||||||
|
title: `${t("teacher.title")} - Next_Edu`,
|
||||||
|
description: t("teacher.description"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function TeacherPracticeContent({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<SearchParams>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
const ctx = await requirePermission(Permissions.ADAPTIVE_PRACTICE_READ)
|
||||||
|
const t = await getTranslations("practice")
|
||||||
|
|
||||||
|
const params = await searchParams
|
||||||
|
const classIds = ctx.dataScope.type === "class_taught" ? ctx.dataScope.classIds : []
|
||||||
|
const gradeIds = ctx.dataScope.type === "grade_managed" ? ctx.dataScope.gradeIds : []
|
||||||
|
|
||||||
|
if (classIds.length === 0 && gradeIds.length === 0 && ctx.dataScope.type !== "all") {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">{t("teacher.title")}</h1>
|
||||||
|
<p className="text-muted-foreground">{t("teacher.description")}</p>
|
||||||
|
</div>
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("teacher.noClass")}
|
||||||
|
description={t("teacher.noClassDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 年级主任/教研组长:展开年级为班级
|
||||||
|
let targetClassIds = classIds
|
||||||
|
if (gradeIds.length > 0) {
|
||||||
|
const gradeClassIds = await getClassIdsByGradeIds(gradeIds)
|
||||||
|
targetClassIds = [...new Set([...classIds, ...gradeClassIds])]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有学生 ID
|
||||||
|
const allStudentIds = await getStudentIdsByClassIds(targetClassIds)
|
||||||
|
|
||||||
|
if (allStudentIds.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">{t("teacher.title")}</h1>
|
||||||
|
<p className="text-muted-foreground">{t("teacher.description")}</p>
|
||||||
|
</div>
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("teacher.noStudent")}
|
||||||
|
description={t("teacher.noStudentDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析 URL 参数:班级筛选
|
||||||
|
const classParam = getParam(params, "classId")
|
||||||
|
const effectiveClassId = classParam ?? "all"
|
||||||
|
|
||||||
|
// 班级概览(用于班级筛选器显示)
|
||||||
|
const classOverviews = await getTeacherClassPracticeOverviews(targetClassIds)
|
||||||
|
|
||||||
|
// 构造 ClassFilter 所需的数据格式
|
||||||
|
const classFilterData: ClassErrorOverview[] = classOverviews.map((c) => ({
|
||||||
|
classId: c.classId,
|
||||||
|
className: c.className,
|
||||||
|
studentCount: c.totalStudents,
|
||||||
|
totalErrorItems: c.totalSessions,
|
||||||
|
dueReviewCount: 0,
|
||||||
|
averageErrorPerStudent: c.totalStudents > 0 ? c.totalSessions / c.totalStudents : 0,
|
||||||
|
averageMasteryRate: c.averageAccuracy,
|
||||||
|
}))
|
||||||
|
|
||||||
|
// 确定查询的班级范围
|
||||||
|
const queryClassIds = effectiveClassId === "all" ? targetClassIds : [effectiveClassId]
|
||||||
|
const queryStudentIds = await getStudentIdsByClassIds(queryClassIds)
|
||||||
|
|
||||||
|
// 并行查询所有统计数据
|
||||||
|
const [typeBreakdown, studentSummaries, nameMap, inactiveIds] = await Promise.all([
|
||||||
|
getPracticeTypeBreakdown(queryStudentIds),
|
||||||
|
// 按班级查询学生摘要(如果是单班级视图,直接查询;如果是全部视图,按班级逐个查询后合并)
|
||||||
|
effectiveClassId === "all"
|
||||||
|
? getClassStudentPracticeSummariesForClasses(queryClassIds)
|
||||||
|
: getClassStudentPracticeSummaries(effectiveClassId),
|
||||||
|
getStudentNameMap(queryStudentIds),
|
||||||
|
effectiveClassId === "all"
|
||||||
|
? getInactiveStudentsForClasses(queryClassIds)
|
||||||
|
: getStudentsWithoutPractice(effectiveClassId),
|
||||||
|
])
|
||||||
|
|
||||||
|
// 聚合统计
|
||||||
|
const totalSessions = classOverviews.reduce((sum, c) => sum + c.totalSessions, 0)
|
||||||
|
const totalAnswered = classOverviews.reduce((sum, c) => sum + c.totalQuestionsAnswered, 0)
|
||||||
|
const totalCorrect = classOverviews.reduce((sum, c) => sum + c.totalCorrect, 0)
|
||||||
|
const totalActiveStudents = classOverviews.reduce((sum, c) => sum + c.activeStudents, 0)
|
||||||
|
const totalStudents = classOverviews.reduce((sum, c) => sum + c.totalStudents, 0)
|
||||||
|
const averageAccuracy = totalAnswered > 0 ? totalCorrect / totalAnswered : 0
|
||||||
|
const participationRate = totalStudents > 0 ? totalActiveStudents / totalStudents : 0
|
||||||
|
|
||||||
|
// 单班级视图:查询知识点薄弱度
|
||||||
|
const weakKps = effectiveClassId !== "all"
|
||||||
|
? await getClassKnowledgePointWeakness(effectiveClassId, 10)
|
||||||
|
: []
|
||||||
|
|
||||||
|
const hasData = totalSessions > 0
|
||||||
|
|
||||||
|
if (!hasData) {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">{t("teacher.title")}</h1>
|
||||||
|
<p className="text-muted-foreground">{t("teacher.description")}</p>
|
||||||
|
</div>
|
||||||
|
<EmptyState
|
||||||
|
icon={BarChart3}
|
||||||
|
title={t("teacher.noData")}
|
||||||
|
description={t("teacher.noDataDescription")}
|
||||||
|
className="h-[360px] bg-card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex h-full flex-col space-y-6 p-8">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold tracking-tight">{t("teacher.title")}</h1>
|
||||||
|
<p className="text-muted-foreground">{t("teacher.description")}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 班级筛选器 */}
|
||||||
|
{classFilterData.length > 0 ? (
|
||||||
|
<Suspense fallback={<Skeleton className="h-10 w-full" />}>
|
||||||
|
<ClassFilter
|
||||||
|
classes={classFilterData}
|
||||||
|
currentClassId={effectiveClassId}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 统计卡片 */}
|
||||||
|
<PracticeOverviewStatsCards
|
||||||
|
totalClasses={classOverviews.length}
|
||||||
|
totalSessions={totalSessions}
|
||||||
|
totalAnswered={totalAnswered}
|
||||||
|
averageAccuracy={averageAccuracy}
|
||||||
|
participationRate={participationRate}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 班级对比表(仅在"全部班级"视图下显示) */}
|
||||||
|
{effectiveClassId === "all" && classOverviews.length > 1 ? (
|
||||||
|
<ClassPracticeComparisonTable data={classOverviews} />
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 练习类型分布图 */}
|
||||||
|
{typeBreakdown.length > 0 ? (
|
||||||
|
<PracticeTypeBreakdownChart data={typeBreakdown} />
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 知识点薄弱度(仅在单班级视图下显示) */}
|
||||||
|
{effectiveClassId !== "all" ? (
|
||||||
|
<ClassKnowledgePointWeaknessChart data={weakKps} />
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 学生练习排名 */}
|
||||||
|
{studentSummaries.length > 0 ? (
|
||||||
|
<StudentPracticeRankingTable data={studentSummaries} studentNames={nameMap} />
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{/* 未参与练习学生提醒 */}
|
||||||
|
<InactiveStudentsAlert
|
||||||
|
inactiveStudentIds={inactiveIds}
|
||||||
|
studentNames={nameMap}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多个班级的学生练习摘要(合并结果)。
|
||||||
|
*
|
||||||
|
* 用于"全部班级"视图,按班级逐个查询后合并。
|
||||||
|
*/
|
||||||
|
async function getClassStudentPracticeSummariesForClasses(
|
||||||
|
classIds: string[],
|
||||||
|
) {
|
||||||
|
const results = await Promise.all(
|
||||||
|
classIds.map((classId) => getClassStudentPracticeSummaries(classId)),
|
||||||
|
)
|
||||||
|
// 合并并按练习数降序排列
|
||||||
|
return results.flat().sort((a, b) => b.totalSessions - a.totalSessions)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多个班级中未参与练习的学生 ID 列表(合并结果)。
|
||||||
|
*/
|
||||||
|
async function getInactiveStudentsForClasses(
|
||||||
|
classIds: string[],
|
||||||
|
): Promise<string[]> {
|
||||||
|
const results = await Promise.all(
|
||||||
|
classIds.map((classId) => getStudentsWithoutPractice(classId)),
|
||||||
|
)
|
||||||
|
return results.flat()
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function TeacherPracticePage({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<SearchParams>
|
||||||
|
}): Promise<JSX.Element> {
|
||||||
|
return (
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<div className="flex h-full flex-col space-y-8 p-8">
|
||||||
|
<Skeleton className="h-10 w-48" />
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-5">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-[100px]" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-[300px] w-full" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<TeacherPracticeContent searchParams={searchParams} />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -149,6 +149,21 @@
|
|||||||
--color-sidebar-border: hsl(var(--sidebar-border));
|
--color-sidebar-border: hsl(var(--sidebar-border));
|
||||||
--color-sidebar-ring: hsl(var(--sidebar-ring));
|
--color-sidebar-ring: hsl(var(--sidebar-ring));
|
||||||
|
|
||||||
|
/* Material Design 3 Surface 令牌映射(备课模块使用)*/
|
||||||
|
--color-surface: hsl(var(--card));
|
||||||
|
--color-on-surface: hsl(var(--foreground));
|
||||||
|
--color-on-surface-variant: hsl(var(--muted-foreground));
|
||||||
|
--color-surface-container-lowest: hsl(var(--background));
|
||||||
|
--color-surface-container-low: hsl(var(--muted));
|
||||||
|
--color-surface-container: hsl(var(--secondary));
|
||||||
|
--color-surface-container-high: hsl(var(--accent));
|
||||||
|
--color-surface-container-highest: hsl(var(--muted-foreground));
|
||||||
|
--color-outline-variant: hsl(var(--border));
|
||||||
|
--color-outline: hsl(var(--border));
|
||||||
|
--color-error: hsl(var(--destructive));
|
||||||
|
--color-tertiary: hsl(var(--chart-3));
|
||||||
|
--color-tertiary-container: hsl(var(--chart-3));
|
||||||
|
|
||||||
--radius-lg: var(--radius);
|
--radius-lg: var(--radius);
|
||||||
--radius-md: calc(var(--radius) - 2px);
|
--radius-md: calc(var(--radius) - 2px);
|
||||||
--radius-sm: calc(var(--radius) - 4px);
|
--radius-sm: calc(var(--radius) - 4px);
|
||||||
@@ -241,3 +256,9 @@
|
|||||||
.anchor-edge.active {
|
.anchor-edge.active {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 正文节点光标指示器闪烁 */
|
||||||
|
@keyframes cursor-blink {
|
||||||
|
0%, 50% { opacity: 1; }
|
||||||
|
51%, 100% { opacity: 0; }
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user