diff --git a/frontend/src/views/exam/practice.vue b/frontend/src/views/exam/practice.vue index c984ae5..cb39519 100644 --- a/frontend/src/views/exam/practice.vue +++ b/frontend/src/views/exam/practice.vue @@ -1182,9 +1182,12 @@ const renderMarkdown = (content: string): string => { */ const formatCorrectAnswer = (question: any) => { if (question.type === 'single' || question.type === 'multiple') { - // 如果有correctAnswer字段(来自Dify的原始correct),直接使用 + // 如果有correctAnswer字段(来自Dify的原始correct) if (question.correctAnswer) { - return question.correctAnswer + // 多选题格式优化:将 "A:xxx,B:xxx" 改为换行显示 + // 匹配 ",A:" 或 ",B:" 等格式,在逗号后的选项字母前换行 + const formatted = question.correctAnswer.replace(/,([A-Za-z][::])/g, '\n$1') + return formatted } // 否则从options中提取 return question.options