|
|
|
|
@ -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; } }
|
|
|
|
|
|