@@ -2566,15 +2566,103 @@ function buildExplain(q, selected) {
25662566 <span class="result-title ${ isCorrect ? 'ok' : 'err' } ">${ isCorrect ? '回答正确!' : ( isMulti ? '答案不完整或有误' : '回答错误' ) } </span>` ;
25672567 inner . appendChild ( resultRow ) ;
25682568
2569- if ( ! isCorrect || _zenMode ) {
2570- const corrRow = document . createElement ( 'div' ) ;
2571- corrRow . className = 'explain-correct-row' ;
2572- if ( isMulti ) {
2573- corrRow . innerHTML = `正确答案:<span class="multi-ans">${ q . answer . split ( '' ) . join ( ' ' ) } </span>` ;
2574- } else {
2575- corrRow . innerHTML = `正确答案:<span>${ q . answer } </span>` ;
2569+ // ── 答案对比行 ────────────────────────────────────────────────────
2570+ // 多选题:始终显示(帮助识别少选/多选);单选题:答错时显示
2571+ {
2572+ const selSet = isMulti
2573+ ? ( selected instanceof Set ? selected : new Set ( ) )
2574+ : new Set ( selected ? [ selected ] : [ ] ) ;
2575+
2576+ const showCmp = isMulti || ! isCorrect || _zenMode ;
2577+ if ( showCmp ) {
2578+ const cmpWrap = document . createElement ( 'div' ) ;
2579+ cmpWrap . className = 'explain-ans-cmp' ;
2580+
2581+ if ( isMulti ) {
2582+ // 多选:两行对比 + 字母徽章着色
2583+ // 收集所有出现过的字母(用户选 + 正确),按字母序排列
2584+ const allLetters = [ ...new Set ( [ ...correctSet , ...selSet ] ) ] . sort ( ) ;
2585+
2586+ // — 你的答案行 —
2587+ const yourRow = document . createElement ( 'div' ) ;
2588+ yourRow . className = 'explain-ans-row' ;
2589+ const yourLabel = document . createElement ( 'span' ) ;
2590+ yourLabel . className = 'ans-row-label' ;
2591+ yourLabel . textContent = '你的答案' ;
2592+ yourRow . appendChild ( yourLabel ) ;
2593+ const yourBadges = document . createElement ( 'span' ) ;
2594+ yourBadges . className = 'ans-badges' ;
2595+ if ( selSet . size === 0 ) {
2596+ const dash = document . createElement ( 'span' ) ;
2597+ dash . className = 'ans-badge ans-badge-miss' ;
2598+ dash . textContent = '未作答' ;
2599+ yourBadges . appendChild ( dash ) ;
2600+ } else {
2601+ // 只展示用户选的字母
2602+ [ ...selSet ] . sort ( ) . forEach ( l => {
2603+ const b = document . createElement ( 'span' ) ;
2604+ b . className = 'ans-badge ' + ( correctSet . has ( l ) ? 'ans-badge-ok' : 'ans-badge-bad' ) ;
2605+ b . textContent = l ;
2606+ yourBadges . appendChild ( b ) ;
2607+ } ) ;
2608+ // 漏选的字母补一个 miss 提示
2609+ [ ...correctSet ] . filter ( l => ! selSet . has ( l ) ) . sort ( ) . forEach ( l => {
2610+ const b = document . createElement ( 'span' ) ;
2611+ b . className = 'ans-badge ans-badge-miss' ;
2612+ b . textContent = l + ' 漏' ;
2613+ yourBadges . appendChild ( b ) ;
2614+ } ) ;
2615+ }
2616+ yourRow . appendChild ( yourBadges ) ;
2617+ cmpWrap . appendChild ( yourRow ) ;
2618+
2619+ // — 正确答案行 —
2620+ const corrRow2 = document . createElement ( 'div' ) ;
2621+ corrRow2 . className = 'explain-ans-row' ;
2622+ const corrLabel = document . createElement ( 'span' ) ;
2623+ corrLabel . className = 'ans-row-label' ;
2624+ corrLabel . textContent = '正确答案' ;
2625+ corrRow2 . appendChild ( corrLabel ) ;
2626+ const corrBadges = document . createElement ( 'span' ) ;
2627+ corrBadges . className = 'ans-badges' ;
2628+ [ ...correctSet ] . sort ( ) . forEach ( l => {
2629+ const b = document . createElement ( 'span' ) ;
2630+ b . className = 'ans-badge ans-badge-ok' ;
2631+ b . textContent = l ;
2632+ corrBadges . appendChild ( b ) ;
2633+ } ) ;
2634+ corrRow2 . appendChild ( corrBadges ) ;
2635+ cmpWrap . appendChild ( corrRow2 ) ;
2636+
2637+ } else {
2638+ // 单选:单行对比
2639+ const row = document . createElement ( 'div' ) ;
2640+ row . className = 'explain-ans-row' ;
2641+ const lbl1 = document . createElement ( 'span' ) ;
2642+ lbl1 . className = 'ans-row-label' ;
2643+ lbl1 . textContent = '你的答案' ;
2644+ row . appendChild ( lbl1 ) ;
2645+ const yourB = document . createElement ( 'span' ) ;
2646+ yourB . className = 'ans-badge ' + ( ! selected ? 'ans-badge-miss' : ( ! isCorrect ? 'ans-badge-bad' : 'ans-badge-ok' ) ) ;
2647+ yourB . textContent = selected || '—' ;
2648+ row . appendChild ( yourB ) ;
2649+ const arrow = document . createElement ( 'span' ) ;
2650+ arrow . className = 'ans-arrow' ;
2651+ arrow . textContent = '→' ;
2652+ row . appendChild ( arrow ) ;
2653+ const lbl2 = document . createElement ( 'span' ) ;
2654+ lbl2 . className = 'ans-row-label' ;
2655+ lbl2 . textContent = '正确答案' ;
2656+ row . appendChild ( lbl2 ) ;
2657+ const corrB = document . createElement ( 'span' ) ;
2658+ corrB . className = 'ans-badge ans-badge-ok' ;
2659+ corrB . textContent = q . answer ;
2660+ row . appendChild ( corrB ) ;
2661+ cmpWrap . appendChild ( row ) ;
2662+ }
2663+
2664+ inner . appendChild ( cmpWrap ) ;
25762665 }
2577- inner . appendChild ( corrRow ) ;
25782666 }
25792667
25802668 // B型题:在解析前展示共享选项,高亮正确答案
0 commit comments