fix(题目): 修掉代码审查查出的几处问题——流程图拿到的徽章不弹、点评弹窗读失败时关不掉等

- 流程图画到 A / S 拿到的题单徽章、成就原来不弹:流程图那条 WebSocket 只认评分完成 / 失败,
  成就消息被丢掉了,要等下次换路由拉 pending 才出来
- 强制点评弹窗读不出点评、或者一直交不上时,「下一题 / 继续」按钮也给出来:原来弹窗关不掉,
  只能按浏览器后退;拦下换题时就记上「继续」,按钮文字不会写错
- 「放回编辑器」走正常的换语言路子(画流程图时切回代码编辑器、读那门语言的草稿);
  这道题已经不收的语言(0020 摘掉的 Java / JS / Go)置灰,只能复制
- 举着手时刚交对、1.5 秒内点下一题:原来「确定要换题吗」要问两遍(点评完再问一次),
  现在同意过的那个地址不再问
- 课堂看板上评分中、评失败的流程图不再算「尝试过」,和学生的课堂条一个口径;
  新加的流程图查询和其他查询并行,不再多等一轮数据库
- 课堂条的数据只认最后发出的那次请求:进页面那次后到的话会把刚做完的那道盖回「没做」
- 「A / S 算做完」收进契约,前后端只留一份;协作中老师的判断统一用 useTeacherCollab;
  几处放错位置、说法过时的注释

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-09-28 19:35:07 +08:00
1 parent 10169f5792
commit 83b6b7a81a
16 files changed
+162 -99

No files matched your search

+13 -5
View File
@@ -1,7 +1,7 @@
import { createDiscreteApi } from "naive-ui"
import { defineStore } from "pinia"
import { errorCode } from "utils/api"
import type { FlowchartScores, FlowchartSubmission } from "@oj2/contract"
import { isFlowchartPass, type FlowchartScores, type FlowchartSubmission } from "@oj2/contract"
import type { Edge, Node } from "@vue-flow/core"
import { getFlowchartScores, getFlowchartSubmission, submitFlowchart } from "oj/api"
import { useProblemStore } from "oj/store/problem"
@@ -9,6 +9,8 @@ import { useSubmissionStore } from "oj/store/submission"
import { useFlowchartWebSocket, type FlowchartEvaluationUpdate } from "shared/composables/websocket"
import { useMyFlowchartStore } from "shared/store/myFlowchart"
import { useUserStore } from "shared/store/user"
import { useAchievementStore } from "shared/store/achievement"
import type { QueuedAchievement } from "utils/types"
// store 里没有组件上下文,useMessage() 拿不到,和 utils/api.ts 一样用独立的一份
const { message } = createDiscreteApi(["message"])
@@ -26,10 +28,8 @@ export interface FlowchartEditorInstance {
setFlowchartData: (data: { nodes: Node[]; edges: Edge[] }) => void
}
/** 画到这两档算这道题做完(后端 flowchart/grade.ts 的 FLOWCHART_PASS_GRADES) */
export function isFlowchartPass(grade: string | null | undefined) {
return grade === "S" || grade === "A"
}
// 「A / S 算做完」的规则在契约里,前后端一份;这里转出去,组件照旧从 flowchart store 引
export { isFlowchartPass }
/**
* 这一页上最近一次交的图走到哪了。idle = 这一页还没交过(历史分数照样有)
@@ -175,6 +175,14 @@ export const useFlowchartStore = defineStore("flowchart", () => {
}
const handleWebSocketMessage = (data: FlowchartEvaluationUpdate) => {
// 流程图画到 A/S 算完成之后,后端会在同一条用户通道上推题单徽章、成就(flowchart/run.ts 的
// recordSolvedAndNotify)。原来这里只认评分那两种,交代码的监视器又不一定开着,要等下次
// 换路由拉 pending 才弹。队列按 id 去重,两条连接各收一遍也只弹一次
const frame = data as unknown as { type: string; achievements?: QueuedAchievement[] }
if (frame.type === "achievement_unlocked") {
useAchievementStore().enqueue(frame.achievements ?? [])
return
}
if (data.type === "flowchart_evaluation_completed") {
settle(data.submissionId, {
ok: true,
+9 -1
View File
@@ -16,19 +16,27 @@ export const useLessonStore = defineStore("lesson", () => {
const activity = ref<ClassActivity | null>(null)
let loadedAt = 0
let loading: Promise<void> | null = null
/**
* 只认最后发出去的那次。进页面那次还在路上时学生就交对了:先就地标成做完、再强制重拉 ——
* 先发的那次要是后到,会把「做完」盖回去,「下一题」又指回刚做完的这道
*/
let sequence = 0
/** 没拉过或者旧了才拉;force 用在刚通过一道题之后 */
function load(force = false) {
if (!force && activity.value && Date.now() - loadedAt < STALE_MS) return loading
if (!force && loading) return loading
const mine = ++sequence
loading = getClassActivity()
.then((res) => {
if (mine !== sequence) return
activity.value = res
loadedAt = Date.now()
})
// 拉不到就没有课堂条,不影响做题
.catch(() => {})
.finally(() => {
loading = null
if (mine === sequence) loading = null
})
return loading
}