From 773d15b033939ab11fe3e62c9190e58d26ab919c Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Wed, 30 Sep 2026 09:54:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AF=BE=E5=A0=82=E7=9C=8B=E6=9D=BF):=20?= =?UTF-8?q?=E3=80=8C=E8=BF=99=E8=8A=82=E8=AF=BE=E7=9A=84=E9=A2=98=E3=80=8D?= =?UTF-8?q?=E6=97=81=E8=BE=B9=E5=A4=9A=E4=B8=80=E4=B8=AA=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=EF=BC=8C=E5=B8=83=E7=BD=AE=20C=20=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=AD=A6=E7=94=9F=E6=89=93=E5=BC=80=E9=A2=98?= =?UTF-8?q?=E7=9B=AE=E7=BC=96=E8=BE=91=E5=99=A8=E5=B0=B1=E6=98=AF=20C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 默认是这个班上一次布置选的语言。学生那边首页、题号下拉、题目页课堂条都写上「C语言」; 打开这节课的题时编辑器自动切过去,每道题只切一次,学生自己再换就按他的。提交列表的 「这节课」连语言一起筛。 Co-Authored-By: Claude Opus 5.5 --- apps/web/src/oj/api.ts | 9 +++- apps/web/src/oj/classroom/board.vue | 42 ++++++++++++++++--- apps/web/src/oj/home/dashboard.vue | 7 +++- .../src/oj/problem/components/ContextBar.vue | 5 ++- .../oj/problem/components/ProblemEditor.vue | 25 +++++++++++ apps/web/src/oj/store/lesson.ts | 15 +++++-- apps/web/src/oj/submission/list.vue | 4 ++ 7 files changed, 93 insertions(+), 14 deletions(-) diff --git a/apps/web/src/oj/api.ts b/apps/web/src/oj/api.ts index 7e94f07..c169948 100644 --- a/apps/web/src/oj/api.ts +++ b/apps/web/src/oj/api.ts @@ -41,6 +41,7 @@ import { type FlowchartStatistics, type SubmissionStatistics, type SubmissionLessons, + type RunnableLanguage, type SubmissionStatisticsGrid, type TodaySubmissionStatistics, } from "@oj2/contract" @@ -242,8 +243,12 @@ export function getClassLesson(className?: string) { } /** 给这个班布置今天的题,空数组 = 清掉 */ -export function setClassLesson(className: string, problemDisplayIds: string[]) { - return api.put("classroom/lesson", { className, problemDisplayIds }) +export function setClassLesson( + className: string, + problemDisplayIds: string[], + language: RunnableLanguage | null, +) { + return api.put("classroom/lesson", { className, problemDisplayIds, language }) } /** 我的知识点地图(只有自己的,不能查别人) */ diff --git a/apps/web/src/oj/classroom/board.vue b/apps/web/src/oj/classroom/board.vue index bda6fe9..2181afb 100644 --- a/apps/web/src/oj/classroom/board.vue +++ b/apps/web/src/oj/classroom/board.vue @@ -3,7 +3,9 @@ import { getClassBoard, setClassLesson } from "oj/api" import { useHiddenStudents } from "shared/composables/hiddenStudents" import { useCollabStore } from "shared/store/collab" import { useConfigStore } from "shared/store/config" +import type { RunnableLanguage } 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" @@ -34,6 +36,16 @@ const updatedAt = ref(null) const projector = ref(false) const lessonInput = ref("") +/** + * 这份作业用什么语言做,跟着这一次布置走(用户定的:不是给班级定死的设置)。默认是这个班 + * 上一次布置时选的;选了之后看板和学生那边的「做完」都只认这个语言交对的 + */ +const lessonLanguage = ref("Python") +const LESSON_LANGUAGES: RunnableLanguage[] = ["Python", "C", "C++"] +const languageOptions = LESSON_LANGUAGES.map((value) => ({ + label: LANGUAGE_SHOW_VALUE[value], + value, +})) const saving = ref(false) function classLabel(name: string) { @@ -65,7 +77,7 @@ async function load() { } } -// 换了班要把输入框换成那个班今天布置的题 +// 换了班要把输入框换成那个班今天布置的题、布置时选的语言(15 秒一次的刷新不动它们) watch( () => [board.value?.className, board.value?.source] as const, () => { @@ -73,6 +85,7 @@ watch( board.value?.source === "teacher" ? board.value.problems.map((problem) => problem.problemDisplayId).join(" ") : "" + lessonLanguage.value = board.value?.language ?? board.value?.lastLanguage ?? "Python" }, ) @@ -86,8 +99,12 @@ async function saveLesson() { const ids = lessonInput.value.split(/[\s,,、;;]+/).filter(Boolean) saving.value = true try { - await setClassLesson(className.value, ids) - message.success(ids.length ? "已布置,学生首页会显示这几道题" : "已清掉,学生那边改回自动推断") + await setClassLesson(className.value, ids, ids.length ? lessonLanguage.value : null) + message.success( + ids.length + ? `已布置(${LANGUAGE_SHOW_VALUE[lessonLanguage.value]}),学生首页会显示这几道题` + : "已清掉,学生那边改回自动推断", + ) await load() } catch (error) { message.error(errorMessage(error)) @@ -241,7 +258,12 @@ function submissionsHref( username: student.username, exactUsername: "1", today: "1", - ...(flowchart ? { language: "Flowchart" } : {}), + // 布置时选了语言的,代码那边只看这个语言交的(和格子里数的一致) + ...(flowchart + ? { language: "Flowchart" } + : board.value?.language + ? { language: board.value.language } + : {}), ...(problemDisplayId ? { problem: problemDisplayId } : {}), }, }).href @@ -293,6 +315,12 @@ function submissionsHref( 这节课的题 + diff --git a/apps/web/src/oj/home/dashboard.vue b/apps/web/src/oj/home/dashboard.vue index d3be22c..08fed85 100644 --- a/apps/web/src/oj/home/dashboard.vue +++ b/apps/web/src/oj/home/dashboard.vue @@ -17,7 +17,7 @@ import { useBreakpoints } from "shared/composables/breakpoints" import { useProblemJump } from "shared/composables/problemJump" import { pickHeadline, type Headline } from "oj/user/knowledge" import { useUserStore } from "shared/store/user" -import { ContestStatus, CONTEST_STATUS, JUDGE_STATUS } from "utils/constants" +import { ContestStatus, CONTEST_STATUS, JUDGE_STATUS, LANGUAGE_SHOW_VALUE } from "utils/constants" import { duration, parseTime, zonedParts, zonedYear } from "utils/functions" import type { AnnouncementListItem, @@ -227,7 +227,10 @@ const classActivityTitle = computed(() => { const day = classActivity.value?.day if (!day) return "" // 老师在课堂看板布置的,说成「老师布置的」,比「班里在做」更让人知道该做这几道 - if (classActivity.value?.source === "teacher") return "今天老师布置的题" + if (classActivity.value?.source === "teacher") { + const language = classActivity.value.language + return `今天老师布置的题${language ? ` · 用${LANGUAGE_SHOW_VALUE[language]}做` : ""}` + } if (classToday.value) return "今天班里在做" const [, month, date] = day.split("-").map(Number) return `${month}月${date}日班里做了` diff --git a/apps/web/src/oj/problem/components/ContextBar.vue b/apps/web/src/oj/problem/components/ContextBar.vue index fdf989f..e4ec07a 100644 --- a/apps/web/src/oj/problem/components/ContextBar.vue +++ b/apps/web/src/oj/problem/components/ContextBar.vue @@ -232,7 +232,10 @@ onSolvedHere(() => {