Merge Yuxi teacher support with classroom discussions
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
鲨鱼辣椒
2026-09-24 10:27:36 +08:00
34 changed files with 2333 additions and 105 deletions

View File

@@ -29,10 +29,11 @@ export async function handleCodingTeacherRoutes(
const checkIn = url.pathname.match(/^\/api\/coding\/projects\/([^/]+)\/teacher-check-in$/);
const role = projectTopics?.[2] === 'friend' || url.pathname === '/api/coding/friend/config' ? 'friend' : 'teacher';
const config = url.pathname === '/api/coding/teacher/config' || url.pathname === '/api/coding/friend/config';
const catalog = url.pathname === '/api/coding/teacher/teachers';
const draft = url.pathname === '/api/coding/teacher-preview';
const pending = url.pathname === '/api/coding/teacher-preview/pending-link';
if (!source && !preview && !projectTopics && !checkIn && !config && !draft && !pending) return false;
if ((config || draft || pending) && req.method !== 'GET') {
if (!source && !preview && !projectTopics && !checkIn && !config && !catalog && !draft && !pending) return false;
if ((config || catalog || draft || pending) && req.method !== 'GET') {
sendJson(res, 405, { error: '不支持此操作。' });
return true;
}
@@ -54,6 +55,10 @@ export async function handleCodingTeacherRoutes(
));
return true;
}
if (catalog) {
sendJson(res, 200, await service.catalog());
return true;
}
if (config && req.method === 'GET') {
sendJson(res, 200, await service.definition(role));
return true;
@@ -78,8 +83,8 @@ export async function handleCodingTeacherRoutes(
return true;
}
if (!id && req.method === 'POST') {
const body = await parseJsonBody<{ draftRevision?: number; sampleContext?: string }>(req);
sendJson(res, 201, await service.create(scope, body.draftRevision, body.sampleContext));
const body = await parseJsonBody<{ draftRevision?: number; sampleContext?: string; teacherVersion?: number }>(req);
sendJson(res, 201, await service.create(scope, body.draftRevision, body.sampleContext, body.teacherVersion));
return true;
}
if (id && !action && req.method === 'GET') {