- | 题型 | 题库题目数量 | 选题数量 | 每题分值 | 小计 |
+ | 题型 | 题库题目数量 | 选题数量 | 小计 |
| {{ item.label }} |
{{ questionCount(item.value) }} |
{{ selectedByType(item.value) }} |
-
-
- |
{{ scoreByType(item.value) }} |
@@ -130,10 +118,6 @@
{{ idx + 1 }}
{{ typeOptions.find(t => t.value === question.type)?.label || question.type }}
-
-
- 分
-
{{ question.stem }}
@@ -240,12 +224,11 @@ function isSelected(questionId) { return form.questions.some((item) => item.ques
function selectedScore(questionId) { return form.questions.find((item) => item.questionId === questionId)?.score || 1; }
function toggleQuestion(question, checked) { if (checked) form.questions.push({ questionId: question.id, score: typeScores[question.type] || 1 }); else form.questions = form.questions.filter((item) => item.questionId !== question.id); }
function removeQuestionFromPreview(question) { toggleQuestion(question, false); }
-function setScore(questionId, score) { const item = form.questions.find((row) => row.questionId === questionId); if (item) item.score = Number(score); }
+
function selectedByType(type) { const ids = new Set(bank.value.filter((item) => item.type === type).map((item) => item.id)); return form.questions.filter((item) => ids.has(item.questionId)).length; }
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 setTypeScore(type, score) { const value = Number(score); if (!Number.isFinite(value) || value < 0.5) return; typeScores[type] = value; const ids = new Set(bank.value.filter((item) => item.type === type).map((item) => item.id)); for (const item of form.questions) if (ids.has(item.questionId)) item.score = value; }
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"); }
@@ -397,8 +380,6 @@ function toBoolean(value, fallback) { if (value === undefined || value === null
tbody tr:hover td { background: #fafcff; }
}
- .type-score-input { width: 112px; }
-
.fixed-step-actions {
display: flex;
align-items: center;
@@ -690,32 +671,6 @@ function toBoolean(value, fallback) { if (value === undefined || value === null
font-weight: 500;
}
- .q-score-chip {
- display: inline-flex;
- align-items: center;
- gap: var(--sp-1);
- margin-left: auto;
- padding: 2px var(--sp-3);
- border-radius: var(--r-control);
- background: #ffffff;
- border: 1px solid var(--edu-primary);
- font-size: var(--fs-tag);
- color: var(--edu-primary-deep);
-
- span { color: var(--edu-primary-deep); font-weight: 500; }
-
- :deep(.el-input-number) { width: 88px; }
- :deep(.el-input-number .el-input__wrapper) {
- padding: 2px 6px;
- box-shadow: none !important;
- background: transparent;
- }
- :deep(.el-input-number__decrease),
- :deep(.el-input-number__increase) {
- display: none;
- }
- }
-
.q-card-stem {
margin: 0 0 var(--sp-2);
color: var(--text-strong);