feat(lesson-preparation): add AI evaluation, analytics, attachments, calendar, comments, review, substitutes, formative, and version diff

- Add actions-ai-evaluation, actions-analytics, actions-attachments, actions-calendar, actions-comments, actions-formative, actions-questions, actions-review, actions-substitutes

- Add corresponding data-access layers for each new action module

- Add calendar-view, curriculum-map-view, version-diff-viewer components

- Add editor-slice, selection-slice, version-slice hooks for state management

- Add document-diff and scope-check lib utilities

- Add default-question-service and external-questions-bridge services
This commit is contained in:
SpecialX
2026-07-03 10:25:21 +08:00
parent a16f09d3c3
commit 20023e13fd
75 changed files with 5131 additions and 1186 deletions

View File

@@ -0,0 +1,49 @@
/**
* M9 日历视图 - Server Actions
*/
"use server";
import { z } from "zod";
import { getCalendarEvents, groupEventsByDate } from "./data-access-calendar";
import type { LessonPlanCalendarEvent } from "./data-access-calendar";
import type { ActionState } from "@/shared/types/action-state";
import { getAuthContext, requirePermission } from "@/shared/lib/auth-guard";
import { handleActionError } from "@/shared/lib/action-utils";
import { Permissions } from "@/shared/types/permissions";
const getCalendarEventsSchema = z.object({
startDate: z.string().refine((v) => !Number.isNaN(new Date(v).getTime()), "Invalid date"),
endDate: z.string().refine((v) => !Number.isNaN(new Date(v).getTime()), "Invalid date"),
});
/**
* 查询当前教师的备课日历事件
*/
export async function getCalendarEventsAction(
input: Record<string, unknown>,
): Promise<ActionState<{ events: LessonPlanCalendarEvent[]; grouped: Record<string, LessonPlanCalendarEvent[]> }>> {
try {
await requirePermission(Permissions.LESSON_PLAN_READ);
const parseResult = getCalendarEventsSchema.safeParse(input);
if (!parseResult.success) {
return { success: false, message: "Invalid input" };
}
const auth = await getAuthContext();
if (!auth.userId) {
return { success: false, message: "Unauthorized" };
}
const events = await getCalendarEvents(
auth.userId,
new Date(parseResult.data.startDate),
new Date(parseResult.data.endDate),
);
const groupedMap = groupEventsByDate(events);
const grouped: Record<string, LessonPlanCalendarEvent[]> = {};
for (const [key, value] of groupedMap.entries()) {
grouped[key] = value;
}
return { success: true, data: { events, grouped } };
} catch (e) {
return handleActionError(e);
}
}