From e1b32c2c3c6ca401b1172fdd22843472a8d0e25c Mon Sep 17 00:00:00 2001 From: QDKF Date: Sat, 6 Sep 2025 01:20:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E7=9A=84=20TypeScript=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/teacher/ExamPages/AddQuestion.vue | 45 +----- .../teacher/ExamPages/QuestionManagement.vue | 150 +++++++----------- 2 files changed, 59 insertions(+), 136 deletions(-) diff --git a/src/views/teacher/ExamPages/AddQuestion.vue b/src/views/teacher/ExamPages/AddQuestion.vue index a7115fd..ce34cf8 100644 --- a/src/views/teacher/ExamPages/AddQuestion.vue +++ b/src/views/teacher/ExamPages/AddQuestion.vue @@ -500,7 +500,7 @@ const createNewQuestion = async (bankId: string) => { try { // 只调用一次API创建题目 const questionData = { - parentId: null, // 父题目ID,普通题目为null + parentId: undefined, // 父题目ID,普通题目为undefined type: getQuestionTypeNumber(questionForm.type), content: questionForm.title, analysis: questionForm.explanation || '', @@ -547,43 +547,6 @@ const createNewQuestion = async (bankId: string) => { } }; -// 处理单选题的选项和答案 -const handleSingleChoiceQuestion = async (questionId: string) => { - try { - // 添加选项 - const optionPromises = questionForm.options.map((option, index) => { - const isCorrect = questionForm.correctAnswer === index ? 1 : 0; - return ExamApi.createQuestionOption({ - questionId, - content: option.content, - izCorrent: isCorrect, - orderNo: index + 1 - }); - }); - - console.log('🚀 第二步:添加选项,选项数量:', questionForm.options.length); - await Promise.all(optionPromises); - console.log('✅ 选项添加成功'); - - // 添加正确答案 - if (questionForm.correctAnswer !== null) { - const correctOption = questionForm.options[questionForm.correctAnswer]; - const answerData = { - questionId, - answerText: correctOption.content, - orderNo: 1 - }; - - console.log('🚀 第三步:添加答案:', answerData); - await ExamApi.createQuestionAnswer(answerData); - console.log('✅ 答案添加成功'); - } - - } catch (error: any) { - console.error('处理单选题失败:', error); - throw error; - } -}; // 验证答案设置 const validateAnswers = (): boolean => { @@ -600,7 +563,7 @@ const validateAnswers = (): boolean => { message.error('单选题至少需要2个选项'); return false; } - if (questionForm.options.some(option => !option.content.trim())) { + if (questionForm.options.some((option: any) => !option.content.trim())) { message.error('请填写所有选项的内容'); return false; } @@ -615,7 +578,7 @@ const validateAnswers = (): boolean => { message.error('多选题至少需要2个选项'); return false; } - if (questionForm.options.some(option => !option.content.trim())) { + if (questionForm.options.some((option: any) => !option.content.trim())) { message.error('请填写所有选项的内容'); return false; } @@ -631,7 +594,7 @@ const validateAnswers = (): boolean => { } break; case 'fill_blank': - if (questionForm.fillBlankAnswers.length === 0 || questionForm.fillBlankAnswers.every(answer => !answer.content.trim())) { + if (questionForm.fillBlankAnswers.length === 0 || questionForm.fillBlankAnswers.every((answer: any) => !answer.content.trim())) { message.error('请设置填空题的参考答案'); return false; } diff --git a/src/views/teacher/ExamPages/QuestionManagement.vue b/src/views/teacher/ExamPages/QuestionManagement.vue index 98a460e..3014517 100644 --- a/src/views/teacher/ExamPages/QuestionManagement.vue +++ b/src/views/teacher/ExamPages/QuestionManagement.vue @@ -3,94 +3,61 @@ - +

{{ currentBankTitle }}

添加试题 导入 导出 - 删除 + 删除 分类设置 - - + + 搜索
- + - + - +
已选择 {{ selectedRowKeys.length }} 个试题
- +
- +
- +
- + 添加 @@ -98,7 +65,7 @@
- +