|
@@ -13,8 +13,8 @@
|
|
|
<div slot="title" class="box-justify">
|
|
|
<div>
|
|
|
<h2>{{ isEdit ? "编辑试题" : "创建试题" }}</h2>
|
|
|
- <span>课程代码:{{ question.courseCode }}</span>
|
|
|
- <span>课程名称:{{ question.courseName }}</span>
|
|
|
+ <span>课程代码:{{ questionModel.courseCode }}</span>
|
|
|
+ <span>课程名称:{{ questionModel.courseName }}</span>
|
|
|
</div>
|
|
|
<div>
|
|
|
<el-button
|
|
@@ -90,8 +90,12 @@ import SelectQuestion from "./edit/SelectQuestion.vue";
|
|
|
import TextAnswerQuestion from "./edit/TextAnswerQuestion.vue";
|
|
|
import NestedQuestion from "./edit/NestedQuestion.vue";
|
|
|
import BankedClozeQuestion from "./edit/BankedClozeQuestion.vue";
|
|
|
-import { deepCopy, randomCode } from "@/plugins/utils";
|
|
|
-import { updateQuestionApi, sourceDetailPageListApi } from "../api";
|
|
|
+import { randomCode } from "@/plugins/utils";
|
|
|
+import {
|
|
|
+ updateQuestionApi,
|
|
|
+ sourceDetailPageListApi,
|
|
|
+ questionDetailApi,
|
|
|
+} from "../api";
|
|
|
import ModifySourceDetail from "./ModifySourceDetail.vue";
|
|
|
|
|
|
const initQuestionModel = {
|
|
@@ -117,9 +121,13 @@ export default {
|
|
|
question: {
|
|
|
type: Object,
|
|
|
default() {
|
|
|
- return {};
|
|
|
+ return { id: "" };
|
|
|
},
|
|
|
},
|
|
|
+ editMode: {
|
|
|
+ type: String,
|
|
|
+ default: "question",
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -152,25 +160,52 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
async visibleChange() {
|
|
|
- if (!this.question.id) await this.getSourceDetailList();
|
|
|
+ if (this.question.id) {
|
|
|
+ const res = await questionDetailApi(this.question.id);
|
|
|
+
|
|
|
+ const courseInfo = {
|
|
|
+ courseId: res.data.course.id,
|
|
|
+ courseCode: res.data.course.code,
|
|
|
+ courseName: res.data.course.name,
|
|
|
+ };
|
|
|
+ let questionModel = {
|
|
|
+ ...res.data,
|
|
|
+ ...courseInfo,
|
|
|
+ score: this.question.score,
|
|
|
+ editMode: this.editMode,
|
|
|
+ };
|
|
|
+ if (questionModel.subQuestions && questionModel.subQuestions.length) {
|
|
|
+ questionModel.subQuestions = questionModel.subQuestions.map(
|
|
|
+ (q, qindex) => {
|
|
|
+ let nq = { ...q, ...courseInfo, editMode: this.editMode };
|
|
|
+ if (this.editMode === "paper")
|
|
|
+ nq.score = this.question.subScoreList[qindex];
|
|
|
+ return nq;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ this.questionModel = questionModel;
|
|
|
+ } else {
|
|
|
+ await this.getSourceDetailList();
|
|
|
+
|
|
|
+ this.questionModel = Object.assign(
|
|
|
+ {},
|
|
|
+ initQuestionModel,
|
|
|
+ this.question
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
this.initData();
|
|
|
},
|
|
|
initData() {
|
|
|
this.loading = false;
|
|
|
this.hasModifyQuestion = false;
|
|
|
-
|
|
|
- let questionModel = Object.assign(
|
|
|
- {},
|
|
|
- initQuestionModel,
|
|
|
- deepCopy(this.question)
|
|
|
- );
|
|
|
-
|
|
|
if (this.isEdit) {
|
|
|
this.sourceDetailList = this.sourceDetailAllList;
|
|
|
|
|
|
this.curSourceDetail = {
|
|
|
- id: this.question.sourceDetailId,
|
|
|
- questionType: this.question.questionType,
|
|
|
+ id: this.questionModel.sourceDetailId,
|
|
|
+ questionType: this.questionModel.questionType,
|
|
|
};
|
|
|
} else {
|
|
|
if (this.sourceDetailAllList.length > this.limitShowCount) {
|
|
@@ -181,13 +216,12 @@ export default {
|
|
|
} else {
|
|
|
this.sourceDetailList = this.sourceDetailAllList;
|
|
|
}
|
|
|
- if (!this.question.sourceDetailId && !this.curSourceDetail.id) {
|
|
|
+ if (!this.questionModel.sourceDetailId && !this.curSourceDetail.id) {
|
|
|
this.curSourceDetail = this.sourceDetailList[0];
|
|
|
}
|
|
|
- questionModel.questionType = this.curSourceDetail.questionType;
|
|
|
- questionModel.sourceDetailId = this.curSourceDetail.id;
|
|
|
+ this.questionModel.questionType = this.curSourceDetail.questionType;
|
|
|
+ this.questionModel.sourceDetailId = this.curSourceDetail.id;
|
|
|
}
|
|
|
- this.questionModel = questionModel;
|
|
|
this.questionKey = randomCode();
|
|
|
},
|
|
|
close() {
|