fix(流程图): 评分明细的顺序是乱的,40 分的那项排在最后
Some checks failed
Deploy / deploy (push) Has been cancelled

AI 是按分值从高到低返回的:`逻辑正确性(40) → 完整性(30) → 规范性(20) → 清晰度(10)`。
但 `ai_criteria_details` 存在 jsonb 列里,而 Postgres 的 jsonb **不保留键序** ——
它按「键长度 + 字节序」重排,读出来变成 `完整性 → 清晰度 → 规范性 → 逻辑正确性`,
权重最高的那项被排到了最后。

评分弹框和教师端的评分详情都是直接 `v-for` 遍历这个对象,所以两处都乱。
统计面板因为用的是写死的 `CRITERIA_ORDER`,一直是对的 —— 于是同一份数据在两个
地方的顺序还不一致。

把顺序抽到 `utils/constants` 共享,三处统一走 `sortFlowchartCriteria()`;
表里没有的键排到后面,AI 万一返回别的评分项也不会丢。

顺带把限流的提示改得能看懂:撞上 429 时原来只显示「流程图提交失败」,学生会以为
是自己的图有问题然后反复点,越点等得越久。现在按错误码分支,提示「提交太频繁了,
缓一会儿再交」。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 10:53:29 -06:00
parent e921506f40
commit 8861393529
4 changed files with 52 additions and 8 deletions

View File

@@ -70,12 +70,12 @@
<!-- 详细评分 -->
<n-card
v-if="Object.keys(criteriaDetails).length > 0"
v-if="sortedCriteria.length > 0"
size="small"
title="详细评分"
>
<div
v-for="(detail, key) in criteriaDetails"
v-for="[key, detail] in sortedCriteria"
:key="key"
style="margin-bottom: 12px"
>
@@ -109,6 +109,7 @@
import { Icon } from "@iconify/vue"
import type { FlowchartSubmission } from "utils/types"
import { useMermaid } from "shared/composables/useMermaid"
import { sortFlowchartCriteria } from "utils/constants"
interface Props {
submissionId: string
@@ -146,6 +147,9 @@ const criteriaDetails = computed<
}),
)
})
// jsonb 不保留键序,直接遍历会把 40 分的「逻辑正确性」排到最后
const sortedCriteria = computed(() => sortFlowchartCriteria(criteriaDetails.value))
const loading = ref(false)
const rendering = ref(false)
const showLargeImage = ref(false)