Merge Yuxi teacher support with classroom discussions
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user