fix(课堂看板): 作业里有 SQL 题就布置不上去(报「不能用 C 交」),也没法布置一节 SQL 课

- 布置作业的语言加上 SQL,数据库课整节选 SQL
- C / Python 的作业里可以夹 SQL 题:SQL 题只收 SQL,不受作业语言限制,交对 SQL 就算做完
  (学生首页课堂条、看板格子、班里做了几个人三处一起改)
- 看板点 SQL 题的格子,提交列表按 SQL 筛,不再是一片空白;提交列表「这节课」遇到夹了
  SQL 题的作业不再按 C 筛

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-09 18:18:10 +08:00
1 parent 98dfcc1e7e
commit fcf63c2ecb
7 files changed
+71 -42

No files matched your search

+2 -2
View File
@@ -42,7 +42,7 @@ import {
type FlowchartStatistics,
type SubmissionStatistics,
type SubmissionLessons,
type RunnableLanguage,
type LessonLanguage,
type SubmissionStatisticsGrid,
type TodaySubmissionStatistics,
} from "@oj2/contract"
@@ -261,7 +261,7 @@ export function getClassLesson(className?: string) {
export function setClassLesson(
className: string,
problemDisplayIds: string[],
language: RunnableLanguage | null,
language: LessonLanguage | null,
) {
return api.put<null>("classroom/lesson", { className, problemDisplayIds, language })
}
+14 -19
View File
@@ -3,11 +3,11 @@ import { getClassBoard, setClassLesson } from "oj/api"
import { useLeaveStudents } from "shared/composables/leaveStudents"
import { useCollabStore } from "shared/store/collab"
import { useConfigStore } from "shared/store/config"
import type { RunnableLanguage } from "@oj2/contract"
import type { LessonLanguage } from "@oj2/contract"
import { errorMessage } from "utils/api"
import { LANGUAGE_SHOW_VALUE } from "utils/constants"
import { parseTime } from "utils/functions"
import type { ClassBoard, ClassBoardCell, ClassBoardStudent } from "utils/types"
import type { ClassBoard, ClassBoardCell, ClassBoardProblem, ClassBoardStudent } from "utils/types"
/**
* 课堂看板(老师):这个班、今天、这节课的几道题 × 全班学生。
@@ -40,8 +40,8 @@ const lessonInput = ref("")
* 这份作业用什么语言做,跟着这一次布置走(用户定的:不是给班级定死的设置)。默认是这个班
* 上一次布置时选的;选了之后看板和学生那边的「做完」都只认这个语言交对的
*/
const lessonLanguage = ref<RunnableLanguage>("Python")
const LESSON_LANGUAGES: RunnableLanguage[] = ["Python", "C", "C++"]
const lessonLanguage = ref<LessonLanguage>("Python")
const LESSON_LANGUAGES: LessonLanguage[] = ["Python", "C", "C++", "SQL"]
const languageOptions = LESSON_LANGUAGES.map((value) => ({
label: LANGUAGE_SHOW_VALUE[value],
value,
@@ -291,9 +291,11 @@ const router = useRouter()
*/
function submissionsHref(
student: ClassBoardStudent,
problemDisplayId: string | undefined,
problem: ClassBoardProblem | undefined,
flowchart: boolean,
) {
// SQL 题不受布置的语言限制,格子数的是 SQL 交的
const language = problem?.isSql ? "SQL" : board.value?.language
return router.resolve({
name: "submissions",
query: {
@@ -301,12 +303,8 @@ function submissionsHref(
exactUsername: "1",
today: "1",
// 布置时选了语言的,代码那边只看这个语言交的(和格子里数的一致)
...(flowchart
? { language: "Flowchart" }
: board.value?.language
? { language: board.value.language }
: {}),
...(problemDisplayId ? { problem: problemDisplayId } : {}),
...(flowchart ? { language: "Flowchart" } : language ? { language } : {}),
...(problem ? { problem: problem.problemDisplayId } : {}),
},
}).href
}
@@ -388,7 +386,10 @@ function submissionsHref(
<n-text depth="3" class="meta">
<template v-if="board.source === 'teacher'">
学生首页的「班里在做」显示的就是这几道<template v-if="board.language"
>,用 {{ LANGUAGE_SHOW_VALUE[board.language] }} 交对才算做完</template
>,用 {{ LANGUAGE_SHOW_VALUE[board.language] }} 交对才算做完<template
v-if="board.language !== 'SQL' && board.problems.some((p) => p.isSql)"
>(SQL 题交对 SQL 就算)</template
></template
>。清空再点布置就改回自动推断。
</template>
<template v-else-if="board.source === 'inferred'">
@@ -515,13 +516,7 @@ function submissionsHref(
<a
v-if="cell.attempts"
class="cell-link"
:href="
submissionsHref(
student,
board.problems[i]!.problemDisplayId,
!cell.codeAttempts,
)
"
:href="submissionsHref(student, board.problems[i], !cell.codeAttempts)"
target="_blank"
:title="
cell.codeAttempts
+7 -1
View File
@@ -300,7 +300,13 @@ export type { ClassComparison, ClassRankItem, ClassUserRank } from "@oj2/contrac
export type { ClassActivity, ClassActivityProblem, LastVisit } from "@oj2/contract"
/** 课堂看板:一个班今天这节课的题 × 全班学生 */
export type { ClassBoard, ClassBoardStudent, ClassBoardCell, ClassLesson } from "@oj2/contract"
export type {
ClassBoard,
ClassBoardProblem,
ClassBoardStudent,
ClassBoardCell,
ClassLesson,
} from "@oj2/contract"
/** 知识点地图:每个知识点做对几道、在第几档,只给自己看 */
export type { KnowledgeLevel, KnowledgeMap } from "@oj2/contract"