const d = require('../questions.json'); let total = 0, bad = []; for (const set of d.sets) { for (const q of set.questions) { total++; if (!q.q || !Array.isArray(q.opts) || q.opts.length < 2) { bad.push(`[${set.name} #${q.id}] 选项不足`); continue; } if (!Number.isInteger(q.ans) || q.ans < 0 || q.ans >= q.opts.length) { bad.push(`[${set.name} #${q.id}] ans 越界`); continue; } if (!q.exp) { bad.push(`[${set.name} #${q.id}] 缺解析`); continue; } if (!Number.isInteger(q.lv) || q.lv < 1 || q.lv > 6) { bad.push(`[${set.name} #${q.id}] lv 非法`); continue; } const dup = q.opts.findIndex((o, i) => q.opts.indexOf(o) !== i); if (dup !== -1) { bad.push(`[${set.name} #${q.id}] 选项重复: "${q.opts[dup]}"`); } } } console.log('总题数:', total); if (bad.length) { console.log('问题:'); bad.forEach(b => console.log(' -', b)); } else console.log('结构校验全部通过'); // 抽查逻辑已移除,因为选项顺序已被随机打乱