任务说明:实验页"任务"面板、布置作业时可改写;先写项目 3 任务 2、项目 6 任务 2 两份
- 每个实验一份 task.md(任务目标、控件名表格、实现步骤、和书上不一样的地方、在平台上怎么试) - 工具栏"评价项"改成"任务":上面是任务说明,下面是评价项和自己检查;不遮挡页面,第一次打开实验时自动打开 - 自己写的 Markdown 子集渲染,先转义全部 HTML(老师可以改写说明) - 作业保存任务说明(新列 task),以前布置的作业用实验现在的说明 - 测试:任务说明表格里的控件名都在示例的 Designer.cs 里 - 修改作业时实验下拉框显示标题而不是编号 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3b9f635c35
commit
90b739a2c7
17 files changed
+759
-219
No files matched your search
+25
-6
@@ -25,7 +25,7 @@ import { getReview, gradebook, manualScore, saveReview, studentDetail, submissio
|
||||
import type { GradingQueue } from './grading/queue'
|
||||
import { config } from './config'
|
||||
import { deleteUserDatabases, restoreExperimentDatabases, userDatabaseDir } from './databases'
|
||||
import { listSamples, loadChecks, loadSample } from './samples'
|
||||
import { listSamples, loadChecks, loadSample, loadTask } from './samples'
|
||||
import { SqlError, sqlService } from './sql-service'
|
||||
import { serveStatic } from './static'
|
||||
import { deleteWork, getWork, saveWork, validFiles, validScreenshots } from './works'
|
||||
@@ -112,6 +112,9 @@ export function createApp(db: Database, gradingQueue: GradingQueue, aiQueue: AiQ
|
||||
return c.json(parseChecks(checks).map((check) => check.title))
|
||||
})
|
||||
|
||||
/** 实验的任务说明(Markdown);没有时 task 为 null */
|
||||
app.get('/api/samples/:id/task', async (c) => c.json({ task: await loadTask(c.req.param('id')) }))
|
||||
|
||||
app.post('/api/samples/:id/selfcheck', async (c) => {
|
||||
const sampleId = c.req.param('id')
|
||||
const yaml = (await listSamples()).some((s) => s.id === sampleId) ? await loadChecks(sampleId) : null
|
||||
@@ -202,11 +205,18 @@ export function createApp(db: Database, gradingQueue: GradingQueue, aiQueue: AiQ
|
||||
)
|
||||
})
|
||||
|
||||
app.get('/api/assignments/:id', (c) => {
|
||||
app.get('/api/assignments/:id', async (c) => {
|
||||
const assignment = visibleAssignment(c)
|
||||
if (!assignment) return c.json({ message: '作业不存在' }, 404)
|
||||
const userId = c.get('user').id
|
||||
return c.json({ assignment, template: assignmentTemplate(db, assignment.id), latest: latestSubmission(db, assignment.id, userId), review: getReview(db, assignment.id, userId) })
|
||||
// 以前布置的作业没有保存任务说明,用实验现在的说明
|
||||
const task = assignment.task ?? (await loadTask(assignment.sampleId))
|
||||
return c.json({
|
||||
assignment: { ...assignment, task },
|
||||
template: assignmentTemplate(db, assignment.id),
|
||||
latest: latestSubmission(db, assignment.id, userId),
|
||||
review: getReview(db, assignment.id, userId),
|
||||
})
|
||||
})
|
||||
|
||||
app.post('/api/assignments/:id/submit', async (c) => {
|
||||
@@ -298,7 +308,7 @@ export function createApp(db: Database, gradingQueue: GradingQueue, aiQueue: AiQ
|
||||
)
|
||||
|
||||
app.post('/api/teacher/assignments', async (c) => {
|
||||
const a = await body<{ classId: number; sampleId: string; title: string; startMode: StartMode; template: unknown; scoring: Scoring; deadline: number | null }>(c)
|
||||
const a = await body<{ classId: number; sampleId: string; title: string; startMode: StartMode; template: unknown; scoring: Scoring; deadline: number | null; task: string | null }>(c)
|
||||
if (!listClasses(db).some((cls) => cls.id === a.classId)) return c.json({ message: '班级不存在' }, 404)
|
||||
const checks = typeof a.sampleId === 'string' ? await loadChecks(a.sampleId) : null
|
||||
if (!checks) return c.json({ message: '这个实验还没有评分规则' }, 400)
|
||||
@@ -313,13 +323,22 @@ export function createApp(db: Database, gradingQueue: GradingQueue, aiQueue: AiQ
|
||||
checks,
|
||||
scoring: a.scoring as Scoring,
|
||||
deadline: typeof a.deadline === 'number' ? a.deadline : null,
|
||||
task: typeof a.task === 'string' ? a.task : null,
|
||||
})
|
||||
return 'error' in result ? c.json({ message: result.error }, 400) : c.json(result)
|
||||
})
|
||||
|
||||
app.patch('/api/teacher/assignments/:id', async (c) => {
|
||||
const a = await body<{ title: string; deadline: number | null; scoring: Scoring }>(c)
|
||||
return reply(c, updateAssignment(db, id(c), { title: String(a.title ?? ''), deadline: typeof a.deadline === 'number' ? a.deadline : null, scoring: a.scoring as Scoring }))
|
||||
const a = await body<{ title: string; deadline: number | null; scoring: Scoring; task: string | null }>(c)
|
||||
return reply(
|
||||
c,
|
||||
updateAssignment(db, id(c), {
|
||||
title: String(a.title ?? ''),
|
||||
deadline: typeof a.deadline === 'number' ? a.deadline : null,
|
||||
scoring: a.scoring as Scoring,
|
||||
task: typeof a.task === 'string' ? a.task : null,
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
app.delete('/api/teacher/assignments/:id', (c) => {
|
||||
|
||||
Reference in new issue
Block a user