fix(admin): 复核页选择题选项渲染修复 + 阅卷导出 Word + 评分两位小数(R28)
针对测试人员反馈的四项: 1) 复核明细「选择题大量空白」:options 为 text 列存 JSON 字符串,原先被原样透传, 前端 v-for 对字符串逐字符迭代(op.key/op.text 皆 undefined)⇒ 每字符渲染一行。 新增 parseOptions()(仅 string 才 JSON.parse,失败降级 null)。 2) 选项与答案不随机:仅题目用 RAND() 抽题,normalizeQuestion 无 shuffle,字母无歧义。 3) 评分精度:DECIMAL(6,1) -> DECIMAL(6,2),migration 026 覆盖 17 列(与 025 同范围), lib/decimal_score.js 与 11 个 model 注释同步;汇总收敛 round2(×100/100)。 4) 阅卷导出:GET /api/admin/big-answers/:group/export?ids= 单选考生 -> 直接 .docx;多位/全部 -> 每位考生单独 .docx 打包 .zip。 路由为 3 段,注册在 :group 通配段之前。 验证:verify_big_question 51 PASS/1 FAIL(唯一 FAIL=测试人员新数据,非本次改动)、 verify_score_leak_all_channels 24/24、verify_question_no_answer_leak 4/3/0/1。
This commit is contained in:
@@ -2083,6 +2083,21 @@ class AdminService extends Service {
|
||||
|
||||
// ---- 4) 拼装逐题明细 ----
|
||||
const norm = v => String(v == null ? '' : v).trim().toLowerCase();
|
||||
// 【R28 修复】options 在 DB 里是 text 列、存的是 JSON 字符串。
|
||||
// 若原样透传给前端,`v-for="op in row.options"` 会按**字符**迭代 ⇒ 每个字符渲染成一行
|
||||
// 空内容(op.key / op.text 皆 undefined),表现即「选择题大量换行导致空白」。
|
||||
// 写法与 admin.js:1370 既有口径同源:仅在 typeof === 'string' 时 parse,失败降级 null。
|
||||
const parseOptions = raw => {
|
||||
if (raw == null) return null;
|
||||
if (Array.isArray(raw)) return raw;
|
||||
if (typeof raw !== 'string') return null;
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
return Array.isArray(parsed) ? parsed : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
const objective = subs.map(s => {
|
||||
const t = s.question_type;
|
||||
const n = Number(s.question_uid);
|
||||
@@ -2097,7 +2112,7 @@ class AdminService extends Service {
|
||||
questionType: t,
|
||||
questionUid: n,
|
||||
question: q ? q.question : null,
|
||||
options: q ? (q.options || null) : null,
|
||||
options: q ? parseOptions(q.options) : null,
|
||||
// 原始值:选择 'A'/'AB';判断 'true'/'false'(由前端做「正确/错误」展示映射,后端不丢事实)
|
||||
correctAnswer: correct,
|
||||
maxScore: q && q.score != null ? Number(q.score) : null,
|
||||
@@ -2121,9 +2136,9 @@ class AdminService extends Service {
|
||||
return a.questionUid - b.questionUid;
|
||||
});
|
||||
|
||||
// 小数按 1 位收敛(与 DECIMAL(6,1) 及全站评分口径一致,避免 0.30000000000000004)
|
||||
const round1 = v => Math.round(v * 10) / 10;
|
||||
const autoScore = round1(objective.reduce((sum, o) => sum + (o.score || 0), 0));
|
||||
// 小数按 2 位收敛(与 DECIMAL(6,2) 及全站评分口径一致,避免 0.30000000000000004)
|
||||
const round2 = v => Math.round(v * 100) / 100;
|
||||
const autoScore = round2(objective.reduce((sum, o) => sum + (o.score || 0), 0));
|
||||
|
||||
// ---- 5) 综合大题(题干取抽题快照,保证考生当时所见可举证) ----
|
||||
let bigQuestion = null;
|
||||
@@ -2171,7 +2186,7 @@ class AdminService extends Service {
|
||||
correctCount: objective.filter(o => o.isCorrect === true).length,
|
||||
autoScore,
|
||||
wordScore: contestant.word_score == null ? 0 : Number(contestant.word_score),
|
||||
totalScore: round1(autoScore + (contestant.word_score == null ? 0 : Number(contestant.word_score))),
|
||||
totalScore: round2(autoScore + (contestant.word_score == null ? 0 : Number(contestant.word_score))),
|
||||
},
|
||||
// 固化题序存在与否决定上图顺序的可解释性,一并上报(便于核对与排障)
|
||||
questionOrderFixed: rank.size > 0,
|
||||
|
||||
Reference in New Issue
Block a user