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(() => {