实验页"评价项"和自测:提交前自己检查,不计分

- 工具栏"评价项"打开侧栏,列出自动检查的功能项(作业显示布置时的规则和各项分值)
- "自己检查"在服务器上按评分规则运行学生现在的程序,逐项显示通过与否和原因;不计分、不留记录,
  自由练习和作业都能用;每人同时一次,结果保留到下一次,之后改过代码提示结果可能过时;
  和提交评分共用全站并发上限
- 实验的评价项接口学生也能用(老师布置作业的对话框改用它)
- 修正:运行区的窗体和"放大"按钮会盖住网页的抽屉和对话框

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-25 18:35:25 +08:00
1 parent aadb2c9e93
commit f256b313f7
11 files changed
+345 -15

No files matched your search

+27 -1
View File
@@ -279,7 +279,7 @@ describe('作业', () => {
})
expect(result.status).toBe(400)
expect(result.body.message).toBe('自动评分项应有 2 项')
expect((await t.get(`/api/teacher/samples/${encodeURIComponent(SAMPLE)}/checks`)).body).toEqual(['能正确打开报警灯', '能正确关闭报警灯'])
expect((await t.get(`/api/samples/${encodeURIComponent(SAMPLE)}/checks`)).body).toEqual(['能正确打开报警灯', '能正确关闭报警灯'])
})
test('学生能看到自己班的作业和起点工程,别的班看不到', async () => {
@@ -332,6 +332,32 @@ describe('作业', () => {
expect((await student.get(`/api/assignments/${assignmentId}/submission`)).body.autoScore).toBe(30)
}, 60000)
test('自测:提交前自己检查,告诉哪项不通过;不计分、不留记录,同时只能一次', async () => {
const { student, assignmentId, files } = await setup()
const finished = async () => {
for (let i = 0; i < 300; i++) {
const { body } = await student.get('/api/selfcheck')
if (body.status !== 'running') return body
await Bun.sleep(200)
}
}
const broken = files.map((f) => (f.path === 'Form1.cs' ? { ...f, content: f.content.replace('AlarmOnOff("Alarm", false);', '') } : f))
const started = await student.post(`/api/assignments/${assignmentId}/selfcheck`, { files: broken })
expect(started.body).toMatchObject({ status: 'running', target: `assignment:${assignmentId}` })
expect((await student.post(`/api/assignments/${assignmentId}/selfcheck`, { files })).status).toBe(409)
const result = await finished()
expect(result.result.results.map((r: any) => r.passed)).toEqual([true, false])
expect(result.result.results[1].message).toBeString()
// 自测不算提交
expect((await student.get(`/api/assignments/${assignmentId}/submission`)).body).toBeNull()
// 自由练习:按实验的评分规则检查
const sample = await student.post(`/api/samples/${encodeURIComponent(SAMPLE)}/selfcheck`, { files })
expect(sample.body.target).toBe(`sample:${SAMPLE}`)
expect((await finished()).result.results.map((r: any) => r.passed)).toEqual([true, true])
expect((await student.post('/api/samples/no-such/selfcheck', { files })).status).toBe(404)
}, 60000)
test('过了截止时间不能提交', async () => {
const { student, assignmentId, files } = await setup(Date.now() - 1000)
const result = await student.post(`/api/assignments/${assignmentId}/submit`, { files })