diff --git a/web/src/components/QuestionDrawer.tsx b/web/src/components/QuestionDrawer.tsx index f2a605a..8c5ecbc 100644 --- a/web/src/components/QuestionDrawer.tsx +++ b/web/src/components/QuestionDrawer.tsx @@ -40,6 +40,36 @@ const QuestionDrawer: React.FC = ({ return { icon: , color: '#ff4d4f', text: '错误' } } + // 渲染填空题内容:将 **** 替换为下划线 + const renderQuestionContent = (question: Question) => { + if (question.type === 'fill-in-blank') { + const parts = question.content.split('****') + return ( + + {parts.map((part, index) => ( + + {part} + {index < parts.length - 1 && ( + +      + + )} + + ))} + + ) + } + return question.content + } + return ( = ({ {/* 题目内容 */}
- {question.content} + {renderQuestionContent(question)}
diff --git a/web/src/pages/QuestionManagement.tsx b/web/src/pages/QuestionManagement.tsx index 4149fc5..9b9c1ab 100644 --- a/web/src/pages/QuestionManagement.tsx +++ b/web/src/pages/QuestionManagement.tsx @@ -211,6 +211,40 @@ const QuestionManagement: React.FC = () => { } } + // 渲染填空题题目内容:将 **** 替换为带下划线的正确答案 + const renderFillInBlankContent = (content: string, answer: string[] | any): React.ReactNode => { + // 确保答案是数组 + const answers: string[] = Array.isArray(answer) ? answer : [] + + if (answers.length === 0) { + return content + } + + // 找到所有的 **** 并替换为对应的答案 + let answerIndex = 0 + const parts = content.split('****') + + return ( + + {parts.map((part, index) => ( + + {part} + {index < parts.length - 1 && ( + + {answers[answerIndex++] || '____'} + + )} + + ))} + + ) + } + // 表格列定义 const columns = [ { @@ -243,6 +277,13 @@ const QuestionManagement: React.FC = () => { dataIndex: 'content', key: 'content', ellipsis: true, + render: (content: string, record: Question) => { + // 如果是填空题,使用特殊渲染 + if (record.type === 'fill-in-blank') { + return renderFillInBlankContent(content, record.answer) + } + return content + }, }, { title: '操作',