diff --git a/src/views/teacherEnd/exam/editor.vue b/src/views/teacherEnd/exam/editor.vue index 577e50d..d409a3f 100644 --- a/src/views/teacherEnd/exam/editor.vue +++ b/src/views/teacherEnd/exam/editor.vue @@ -26,12 +26,13 @@
- + + @@ -229,6 +230,7 @@ function selectedByType(type) { const ids = new Set(bank.value.filter((item) => function questionCount(type) { return bank.value.filter((item) => item.type === type).length; } function scoreByType(type) { return selectedQuestions(type).reduce((sum, item) => sum + Number(selectedScore(item.id)), 0); } function scorePerQuestion(type) { return Number(typeScores[type] || 1); } +function onTypeScoreChange(type) { const score = Number(typeScores[type] || 0); for (const item of form.questions) { const bankItem = bank.value.find((q) => q.id === item.questionId); if (bankItem && bankItem.type === type) item.score = score; } } function selectedQuestions(type) { const selected = new Set(form.questions.map((item) => item.questionId)); return bank.value.filter((item) => item.type === type && selected.has(item.id)); } async function nextStep() { if (activeStep.value === 0) { try { await formRef.value.validate(); const start = new Date(form.startTime.replace(" ", "T")); const end = new Date(form.endTime.replace(" ", "T")); if (end <= start) return ElMessage.warning("结束时间必须晚于开始时间"); duration.value = Math.round((end - start) / 60000); } catch { return; } } if (activeStep.value === 1 && !form.questions.length) return ElMessage.warning("至少选择一道试题"); activeStep.value++; } async function save(publish) { if (inProgress.value) { await examApi.updateExam(id.value, form); ElMessage.success("结束时间已更新"); return router.push("/exam/index"); } try { await formRef.value?.validate(); } catch { activeStep.value = 0; return; } if (!form.questions.length) { activeStep.value = 1; return ElMessage.warning("至少选择一道试题"); } const result = isNew.value ? await examApi.createExam(form) : await examApi.updateExam(id.value, form); const examId = result.data.id; if (publish) await examApi.publishExam(examId); ElMessage.success(publish ? "考试已保存并发布" : "考试已保存"); router.push("/exam/index"); } @@ -351,7 +353,7 @@ function toBoolean(value, fallback) { if (value === undefined || value === null .score-table { width: 100%; - min-width: 720px; + min-width: 860px; border-collapse: collapse; table-layout: fixed; background: #ffffff; @@ -378,6 +380,9 @@ function toBoolean(value, fallback) { if (value === undefined || value === null td:last-child { border-right: 0; } tbody tr:last-child td { border-bottom: 0; } tbody tr:hover td { background: #fafcff; } + + :deep(.el-input-number) { width: 100px; } + :deep(.el-input-number .el-input__wrapper) { padding: 0 8px; } } .fixed-step-actions {
题型题库题目数量选题数量小计
题型题库题目数量选题数量每题分值小计
{{ item.label }} {{ questionCount(item.value) }} {{ selectedByType(item.value) }} {{ scoreByType(item.value) }}