feat: enhance textbook reader with anchor text support and improve knowledge point management
This commit is contained in:
@@ -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" };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user