第一步选择题编辑按钮挪至第一个步骤行旁(白名单任务):配置行移除,从题库选题入口收进编辑弹窗;查看模式步骤1旁显示已配置题数

fix/exam-question-access-material-excel-delete-draft
陈沅 2 months ago
parent b26bf7a429
commit 68f0a69cb7

@ -12,9 +12,14 @@
<span>STEP 01 · KNOWLEDGE CHECK</span>
<p>每次新增一题;填写题干、至少两个选项,并标记正确答案。</p>
</div>
<el-button type="primary" @click="addQuestion">新增题目</el-button>
<div class="choice-editor-actions">
<el-button v-if="loadQuestions" @click="bankPickerVisible = true">从题库选题</el-button>
<el-button type="primary" @click="addQuestion">新增题目</el-button>
</div>
</div>
<StepOneQuestionBankPicker v-if="loadQuestions" v-model:visible="bankPickerVisible" :load-questions="loadQuestions" :existing="draft" @confirm="mergeFromBank" />
<el-empty v-if="!draft.length" description="暂未设置选择题,可点击“新增题目”开始配置。" />
<div v-else class="choice-question-list">
<article v-for="(question, questionIndex) in draft" :key="question.id" class="choice-question-card">
@ -49,15 +54,19 @@
import { ref, watch } from "vue";
import { ElMessage } from "element-plus";
import { QUESTION_OPTION_KEYS, createStepOneChoiceQuestion, parseStepOneChoiceQuestions } from "@/utils/stepOneChoiceQuestions";
import StepOneQuestionBankPicker from "@/views/components/StepOneQuestionBankPicker.vue";
const props = defineProps({
visible: { type: Boolean, default: false },
modelValue: { type: Array, default: () => [] },
taskName: { type: String, default: "" },
// 传入则在弹窗内提供"从题库选题"入口(教师端/平台端各自注入接口)
loadQuestions: { type: Function, default: null },
});
const emit = defineEmits(["update:visible", "update:modelValue"]);
const draft = ref([]);
const optionKeys = QUESTION_OPTION_KEYS;
const bankPickerVisible = ref(false);
watch(() => props.visible, (opened) => {
if (opened) draft.value = structuredClone(parseStepOneChoiceQuestions(props.modelValue));
@ -67,6 +76,13 @@ function addQuestion() {
draft.value.push(createStepOneChoiceQuestion(draft.value.length));
}
function mergeFromBank(questions) {
const existingTitles = new Set(draft.value.map((question) => String(question.title || "").trim()));
const added = questions.filter((question) => !existingTitles.has(question.title));
draft.value.push(...added);
if (added.length) ElMessage.success(`已从题库添加 ${added.length} 道题`);
}
function addOption(question) {
const key = optionKeys[question.options.length];
if (key) question.options.push({ key, content: "" });
@ -121,6 +137,7 @@ function close(value = false) {
.el-dialog__footer { padding: 16px 24px; border-top: 1px solid #cfe2f5; }
}
.choice-editor-intro { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-bottom:18px; padding:15px 17px; border-left:3px solid #1e88e5; background:linear-gradient(90deg,rgba(187, 222, 251, 0.5),transparent); }
.choice-editor-actions { display:flex; flex-shrink:0; gap:10px; }
.choice-editor-intro span { color:#1e88e5; font-size:12px; font-weight:800; letter-spacing:.12em; }.choice-editor-intro p { margin:5px 0 0; color:#5a7a9a; line-height:1.6; }
.choice-question-list { display:grid; gap:16px; }.choice-question-card { padding:16px; border:1px solid #cfe2f5; border-radius:10px; background:#f0f6fd; }.choice-question-card header { display:flex; align-items:center; gap:9px; margin-bottom:13px; color:#2c4a6a; }.choice-question-number { display:grid; place-items:center; width:28px; height:28px; border-radius:50%; color:#ffffff; background:#1e88e5; font-size:12px; font-weight:900; }.choice-question-remove { margin-left:auto; color:#ff92a5; cursor:pointer; border:0; background:transparent; }.choice-options { display:grid; gap:9px; margin:13px 0 7px; }.choice-option-row { display:grid; grid-template-columns:94px 28px minmax(0,1fr) 52px; align-items:center; gap:8px; }.choice-option-row .el-radio { margin-right:0; color:#2c4a6a; }.choice-option-key { display:grid; place-items:center; width:25px; height:25px; color:#1e88e5; font-weight:900; border:1px solid #cfe2f5; border-radius:5px; }
@media (max-width:640px) { .choice-editor-intro { align-items:flex-start; flex-direction:column; }.choice-option-row { grid-template-columns:78px 25px minmax(0,1fr); }.choice-option-row > .el-button { grid-column:3; justify-self:end; } }

@ -394,30 +394,9 @@
</div>
</div>
<!-- 第一步选择题:仅三个白名单任务可配置,复用统一编辑器 -->
<div v-if="supportsStepOneChoice(taskForm.taskKey)" class="material-row">
<div class="material-info">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 11l3 3L22 4"/>
<path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/>
</svg>
<div class="material-text">
<span class="material-label">第一步选择题</span>
<span v-if="stepOneQuestionCount" class="material-link">已配置 {{ stepOneQuestionCount }} 道题</span>
<span v-else class="material-placeholder">暂未配置,学生端第一步将不显示选择题</span>
</div>
</div>
<div class="material-ops">
<el-button v-if="!isReadonly" class="upload-btn" @click="bankPickerVisible = true">
从题库选题
</el-button>
<el-button v-if="!isReadonly" type="primary" class="upload-btn" @click="choiceEditorVisible = true">
设置选择题
</el-button>
</div>
</div>
<!-- 第一步选择题:编辑入口固定在第一个步骤行旁,仅三个白名单任务显示 -->
<StepOneQuestionBankPicker v-model:visible="bankPickerVisible" :load-questions="loadBankQuestions" :existing="taskForm.stepOneQuestions" @confirm="handleBankConfirm" />
<StepOneChoiceQuestionEditor v-model:visible="choiceEditorVisible" v-model="taskForm.stepOneQuestions" :task-name="taskForm.title" />
<StepOneChoiceQuestionEditor v-model:visible="choiceEditorVisible" v-model="taskForm.stepOneQuestions" :task-name="taskForm.title" :load-questions="loadBankQuestions" />
<el-form-item label="步骤名称:">
<div class="step-list">
@ -430,6 +409,12 @@
<div class="step-content">
<span class="step-number">{{ index + 1 }}</span>
<el-input v-model="step.name" placeholder="步骤名称" />
<template v-if="index === 0 && supportsStepOneChoice(taskForm.taskKey)">
<el-button v-if="!isReadonly" class="step-question-btn" @click="choiceEditorVisible = true">
编辑题目{{ stepOneQuestionCount ? `(${stepOneQuestionCount}题)` : "" }}
</el-button>
<span v-else class="step-question-tag">已配置 {{ stepOneQuestionCount }} 道题</span>
</template>
<button
v-if="!isReadonly && taskForm.steps.length > 1"
type="button"
@ -1826,6 +1811,19 @@ function buildPayload() {
border-radius: 8px;
}
.step-question-btn {
flex-shrink: 0;
height: 32px;
font-weight: 600;
}
.step-question-tag {
flex-shrink: 0;
color: rgba(200, 230, 255, 0.6);
font-size: 12px;
white-space: nowrap;
}
.el-input {
flex: 1;

@ -344,31 +344,9 @@
</div>
</div>
<!-- 第一步选择题:仅三个白名单任务可配置,复用统一编辑器 -->
<div v-if="supportsStepOneChoice(taskForm.taskKey)" class="material-row">
<div class="material-info">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M9 11l3 3L22 4" />
<path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11" />
</svg>
<div class="material-text">
<span class="material-label">第一步选择题</span>
<span v-if="stepOneQuestionCount" class="material-link">已配置 {{ stepOneQuestionCount }} 道题</span>
<span v-else class="material-placeholder">暂未配置,学生端第一步将不显示选择题</span>
</div>
</div>
<div class="material-ops">
<el-button v-if="!isReadonly" class="upload-btn" @click="bankPickerVisible = true">
从题库选题
</el-button>
<el-button v-if="!isReadonly" type="primary" class="upload-btn" @click="choiceEditorVisible = true">
设置选择题
</el-button>
</div>
</div>
<!-- 第一步选择题:编辑入口固定在第一个步骤行旁,仅三个白名单任务显示 -->
<StepOneQuestionBankPicker v-model:visible="bankPickerVisible" :load-questions="loadBankQuestions" :existing="taskForm.stepOneQuestions" @confirm="handleBankConfirm" />
<StepOneChoiceQuestionEditor v-model:visible="choiceEditorVisible" v-model="taskForm.stepOneQuestions" :task-name="taskForm.title" />
<StepOneChoiceQuestionEditor v-model:visible="choiceEditorVisible" v-model="taskForm.stepOneQuestions" :task-name="taskForm.title" :load-questions="loadBankQuestions" />
<!-- 步骤数量与顺序固定,仅允许修改名称 -->
<el-form-item label="步骤名称:">
@ -383,6 +361,13 @@
<div class="step-content">
<span class="step-number">{{ index + 1 }}</span>
<el-input v-model="step.name" placeholder="步骤名称" />
<template v-if="index === 0 && supportsStepOneChoice(taskForm.taskKey)">
<el-button v-if="!isReadonly" class="step-question-btn"
@click="choiceEditorVisible = true">
编辑题目{{ stepOneQuestionCount ? `(${stepOneQuestionCount}题)` : "" }}
</el-button>
<span v-else class="step-question-tag">已配置 {{ stepOneQuestionCount }} 道题</span>
</template>
</div>
</div>
</div>
@ -1632,6 +1617,20 @@ function buildPayload() {
.el-input {
flex: 1;
}
.step-question-btn {
flex-shrink: 0;
height: 32px;
font-size: var(--fs-body);
font-weight: 600;
}
.step-question-tag {
flex-shrink: 0;
color: var(--text-muted);
font-size: var(--fs-tag);
white-space: nowrap;
}
}
.drawer-footer {

Loading…
Cancel
Save