更新内容: - 后端 AI 服务优化(能力分析、知识点解析等) - 前端考试和陪练界面更新 - 修复多个 prompt 和 JSON 解析问题 - 更新 Coze 语音客户端
This commit is contained in:
@@ -341,8 +341,28 @@ const transformDifyQuestions = (difyQuestions: any[]): any[] => {
|
||||
const options = q.topic?.options || {}
|
||||
// 解析正确答案:支持 "A"、"A,B"、"A、B"、"A:xxx" 等多种格式
|
||||
const correctAnswerStr = String(q.correct || '')
|
||||
// 提取正确答案中的选项字母(A、B、C、D等)
|
||||
const correctLetters = correctAnswerStr.match(/[A-Da-d]/g)?.map(l => l.toUpperCase()) || []
|
||||
|
||||
// 更精确地提取正确答案字母(避免误提取选项内容中的字母)
|
||||
let correctLetters: string[] = []
|
||||
|
||||
// 情况1:纯选项字母格式(如 "A", "B", "A,B", "A、B", "A,B,C")
|
||||
const pureLetterMatch = correctAnswerStr.trim().match(/^[A-Da-d]([,、\s]+[A-Da-d])*$/)
|
||||
if (pureLetterMatch) {
|
||||
correctLetters = correctAnswerStr.match(/[A-Da-d]/g)?.map(l => l.toUpperCase()) || []
|
||||
} else {
|
||||
// 情况2:选项字母+内容格式(如 "A:xxx" 或 "A: xxx")
|
||||
// 只提取开头的选项字母(可能有多个,如 "A,C:xxx")
|
||||
const prefixMatch = correctAnswerStr.match(/^([A-Da-d](?:[,、\s]*[A-Da-d])*)[:::\s]/)
|
||||
if (prefixMatch) {
|
||||
correctLetters = prefixMatch[1].match(/[A-Da-d]/g)?.map(l => l.toUpperCase()) || []
|
||||
} else {
|
||||
// 情况3:只有开头字母(如 "A" 后面直接跟内容)
|
||||
const firstLetterMatch = correctAnswerStr.match(/^([A-Da-d])/)
|
||||
if (firstLetterMatch) {
|
||||
correctLetters = [firstLetterMatch[1].toUpperCase()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`🔍 解析题目[${index + 1}] - correct: "${q.correct}", correctLetters: [${correctLetters.join(', ')}]`)
|
||||
|
||||
@@ -481,10 +501,11 @@ const loadQuestions = async () => {
|
||||
// 第一轮考试不传mistake_records参数
|
||||
// 第二、三轮考试传入上一轮的错题记录
|
||||
if (currentRound.value > 1) {
|
||||
// 用同一个exam_id获取错题
|
||||
console.log(`📋 获取第${currentRound.value - 1}轮错题记录 - exam_id: ${currentExamId.value}`)
|
||||
// 用同一个exam_id获取上一轮的错题(传入round参数只获取上一轮的错题)
|
||||
const previousRound = currentRound.value - 1
|
||||
console.log(`📋 获取第${previousRound}轮错题记录 - exam_id: ${currentExamId.value}, round: ${previousRound}`)
|
||||
|
||||
const mistakesRes: any = await getMistakes(currentExamId.value)
|
||||
const mistakesRes: any = await getMistakes(currentExamId.value, previousRound)
|
||||
|
||||
console.log('getMistakes原始响应:', mistakesRes)
|
||||
console.log('getMistakes响应结构:', {
|
||||
@@ -785,6 +806,7 @@ const recordWrongAnswer = async () => {
|
||||
try {
|
||||
await recordMistake({
|
||||
exam_id: currentExamId.value,
|
||||
round: currentRound.value, // 记录当前轮次
|
||||
question_id: null, // AI生成的题目没有question_id
|
||||
knowledge_point_id: q.knowledge_point_id || null,
|
||||
question_content: q.title,
|
||||
|
||||
Reference in New Issue
Block a user