fix
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled

This commit is contained in:
2026-04-23 02:31:57 -06:00
parent 6331391792
commit 67a23c51c8
6 changed files with 115 additions and 52 deletions

View File

@@ -21,8 +21,7 @@ const mcqQuestion = ref("")
const mcqOptions = ref(["", ""])
const mcqAnswer = ref(0)
const sortQuestion = ref("")
const sortLines = ref(["", ""])
const sortCode = ref("")
async function load() {
exercises.value = await getAdminExercises(props.tutorialId)
@@ -37,8 +36,7 @@ function openCreate() {
mcqQuestion.value = ""
mcqOptions.value = ["", ""]
mcqAnswer.value = 0
sortQuestion.value = ""
sortLines.value = ["", ""]
sortCode.value = ""
showForm.value = true
}
@@ -53,8 +51,7 @@ function openEdit(ex: Exercise) {
mcqAnswer.value = d.answer
} else {
const d = ex.data as ExerciseSortData
sortQuestion.value = d.question
sortLines.value = [...d.lines]
sortCode.value = d.lines.join("\n")
}
showForm.value = true
}
@@ -63,7 +60,10 @@ async function save() {
const data =
formType.value === "mcq"
? { question: mcqQuestion.value, options: mcqOptions.value, answer: mcqAnswer.value }
: { question: sortQuestion.value, lines: sortLines.value }
: {
question: "将下列代码行排列为正确顺序",
lines: sortCode.value.split("\n").filter((l) => l.trim() !== ""),
}
try {
if (editingId.value) {
@@ -169,7 +169,7 @@ function typeName(type: string) {
<n-radio
:value="i"
:checked="mcqAnswer === i"
@update:checked="if ($event) mcqAnswer = i"
@update:checked="$event && (mcqAnswer = i)"
/>
<n-input
v-model:value="mcqOptions[i]"
@@ -190,27 +190,14 @@ function typeName(type: string) {
</template>
<template v-else>
<n-form-item label="题目">
<n-input v-model:value="sortQuestion" type="textarea" :rows="2" />
</n-form-item>
<n-form-item label="代码行(按正确顺序输入)">
<n-space vertical style="width: 100%">
<n-flex v-for="(line, i) in sortLines" :key="i" align="center" :size="8">
<n-input
v-model:value="sortLines[i]"
:placeholder="`第 ${i + 1} 行`"
style="flex: 1; font-family: monospace"
/>
<n-button
size="small"
:disabled="sortLines.length <= 2"
@click="sortLines.splice(i, 1)"
>
</n-button>
</n-flex>
<n-button size="small" @click="sortLines.push('')">+ 添加行</n-button>
</n-space>
<n-form-item label="正确代码(每行将自动成为一道排序项)">
<n-input
v-model:value="sortCode"
type="textarea"
:rows="10"
placeholder="在此粘贴正确的代码,保存后将自动按行拆分并乱序"
style="font-family: monospace"
/>
</n-form-item>
</template>
</n-form>