feat: productionize learning engine and classroom

This commit is contained in:
inman committed 2026-08-16 21:44:52 +08:00
1 parent 2d04197f3f
commit ba35adfbfa
124 files changed
+9071 -796

No files matched your search

@@ -17,6 +17,11 @@ import {
CourseMutationInProgressError,
isCoursePublishing,
} from '@/lib/course-framework/publish-state';
import { proxyLargeCourseControlToEngine } from '@/lib/makelore-runtime/ops-engine-control';
import {
assertLearningCourseMutable,
FrozenLearningCourseMutationError,
} from '@/lib/makelore-course/immutability';
const log = createLogger('Module Regenerate API');
@@ -24,7 +29,7 @@ export async function POST(
req: NextRequest,
{ params }: { params: Promise<{ courseId: string; index: string }> },
) {
const denied = requireOpsAccess(req);
const denied = await requireOpsAccess(req);
if (denied) return denied;
try {
@@ -37,6 +42,14 @@ export async function POST(
if (!record) {
return apiError(API_ERROR_CODES.INVALID_REQUEST, 404, `Course not found: ${courseId}`);
}
const proxied = await proxyLargeCourseControlToEngine({
request: req,
course: record,
action: 'module-regenerate',
moduleIndex: index,
});
if (proxied) return proxied;
await assertLearningCourseMutable(courseId, record);
if (!record.framework) {
return apiError(
API_ERROR_CODES.INVALID_REQUEST,
@@ -68,6 +81,9 @@ export async function POST(
detailUrl: `${baseUrl}/api/courses/${courseId}`,
});
} catch (error) {
if (error instanceof FrozenLearningCourseMutationError) {
return apiError(API_ERROR_CODES.INVALID_REQUEST, 409, error.message);
}
if (error instanceof CourseMutationInProgressError) {
return apiError(API_ERROR_CODES.INVALID_REQUEST, 409, error.message);
}