feat: enhance textbook reader with anchor text support and improve knowledge point management

This commit is contained in:
SpecialX
2026-01-16 10:22:16 +08:00
parent 9bfc621d3f
commit bb4555f611
44 changed files with 6284 additions and 2090 deletions

View File

@@ -8,6 +8,7 @@ import {
deleteChapter,
createKnowledgePoint,
deleteKnowledgePoint,
updateKnowledgePoint,
updateTextbook,
deleteTextbook,
reorderChapters
@@ -185,11 +186,12 @@ export async function createKnowledgePointAction(
): Promise<ActionState> {
const name = formData.get("name") as string;
const description = formData.get("description") as string;
const anchorText = formData.get("anchorText") as string;
if (!name) return { success: false, message: "Name is required" };
try {
await createKnowledgePoint({ name, description, chapterId });
await createKnowledgePoint({ name, description, anchorText, chapterId });
revalidatePath(`/teacher/textbooks/${textbookId}`);
return { success: true, message: "Knowledge point created successfully" };
} catch {
@@ -209,3 +211,24 @@ export async function deleteKnowledgePointAction(
return { success: false, message: "Failed to delete knowledge point" };
}
}
export async function updateKnowledgePointAction(
kpId: string,
textbookId: string,
prevState: ActionState | null,
formData: FormData
): Promise<ActionState> {
const name = formData.get("name") as string;
const description = formData.get("description") as string;
const anchorText = formData.get("anchorText") as string;
if (!name) return { success: false, message: "Name is required" };
try {
await updateKnowledgePoint({ id: kpId, name, description, anchorText });
revalidatePath(`/teacher/textbooks/${textbookId}`);
return { success: true, message: "Knowledge point updated successfully" };
} catch {
return { success: false, message: "Failed to update knowledge point" };
}
}