From 55438b85c6ee82d8fcb8352d1a12102246c8fe26 Mon Sep 17 00:00:00 2001 From: yuliang_guo Date: Wed, 28 Jan 2026 14:04:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(exam):=20=E4=BF=AE=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E9=A2=98=E5=B8=A6=E5=86=85=E5=AE=B9=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E7=AD=94=E6=A1=88=E8=A7=A3=E6=9E=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加对 'A:内容,B:内容,C:内容' 格式的支持 - 使用正则 /[A-Da-d](?=[::])/g 提取所有选项字母 --- frontend/src/views/exam/practice.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/exam/practice.vue b/frontend/src/views/exam/practice.vue index 1eed353..d3e7f61 100644 --- a/frontend/src/views/exam/practice.vue +++ b/frontend/src/views/exam/practice.vue @@ -355,12 +355,12 @@ const transformDifyQuestions = (difyQuestions: any[]): any[] => { correctLetters = correctAnswerStr.match(/[A-Da-d]/g)?.map(l => l.toUpperCase()) || [] console.log(` ✓ 匹配情况1(纯字母): correctLetters=[${correctLetters.join(',')}]`) } else { - // 情况2:选项字母+内容格式(如 "A:xxx" 或 "A: xxx" 或 "A:xxx") - // 支持多种冒号格式:中文全角冒号、英文冒号 - const prefixMatch = correctAnswerStr.match(/^([A-Da-d](?:[,、\s]*[A-Da-d])*)\s*[::]\s*/) - if (prefixMatch) { - correctLetters = prefixMatch[1].match(/[A-Da-d]/g)?.map(l => l.toUpperCase()) || [] - console.log(` ✓ 匹配情况2(字母+冒号): prefixMatch="${prefixMatch[0]}", correctLetters=[${correctLetters.join(',')}]`) + // 情况2:多选项带内容格式(如 "A:分组列,B:聚合函数,C:常量") + // 匹配所有 "X:" 或 "X:" 格式,提取字母 + const multiOptionMatch = correctAnswerStr.match(/[A-Da-d](?=[::])/g) + if (multiOptionMatch && multiOptionMatch.length > 0) { + correctLetters = multiOptionMatch.map(l => l.toUpperCase()) + console.log(` ✓ 匹配情况2(多选项带内容): correctLetters=[${correctLetters.join(',')}]`) } else { // 情况3:只有开头字母(如 "A" 后面直接跟非字母内容) const firstLetterMatch = correctAnswerStr.match(/^([A-Da-d])(?![A-Za-z])/)