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])/)