|
@@ -42,8 +42,9 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="答案解析">
|
|
|
<v-editor
|
|
|
- v-model="modalForm.answerAnalysis"
|
|
|
+ v-model="answerAnalysis"
|
|
|
:enable-audio="false"
|
|
|
+ @change="answerAnalysisChange"
|
|
|
></v-editor>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
@@ -67,6 +68,7 @@ import QuestionInfoView from "./QuestionInfoView.vue";
|
|
|
import { getInitQuestionModel } from "./model";
|
|
|
import { mapState, mapMutations } from "vuex";
|
|
|
import { objTypeOf } from "@/plugins/utils";
|
|
|
+import { isAnEmptyRichText } from "@/utils/utils";
|
|
|
|
|
|
export default {
|
|
|
name: "MatchQuestion",
|
|
@@ -105,6 +107,7 @@ export default {
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
+ answerAnalysis: null,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -125,7 +128,11 @@ export default {
|
|
|
this.modalForm = this.$objAssign(getInitQuestionModel(), this.question);
|
|
|
this.modalForm.courseId = this.parentQuestion.courseId;
|
|
|
this.initAnswer(this.question.quesAnswer);
|
|
|
+ this.initAnswerAnalysis(this.question.answerAnalysis);
|
|
|
this.quesAnswer = this.modalForm.quesAnswer[0] || null;
|
|
|
+ this.answerAnalysis = this.modalForm.answerAnalysis[0] || {
|
|
|
+ sections: [],
|
|
|
+ };
|
|
|
},
|
|
|
initAnswer(answer) {
|
|
|
let quesAnswer = [];
|
|
@@ -142,6 +149,23 @@ export default {
|
|
|
this.modalForm.quesAnswer = [];
|
|
|
}
|
|
|
},
|
|
|
+ initAnswerAnalysis(answer) {
|
|
|
+ let answerAnalysis = [];
|
|
|
+ if (answer) {
|
|
|
+ try {
|
|
|
+ answerAnalysis = JSON.parse(answer);
|
|
|
+ } catch (err) {
|
|
|
+ console.log(`answer error:${answer}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.modalForm.answerAnalysis = answerAnalysis.map((item) =>
|
|
|
+ isAnEmptyRichText(item)
|
|
|
+ ? {
|
|
|
+ sections: [],
|
|
|
+ }
|
|
|
+ : item
|
|
|
+ );
|
|
|
+ },
|
|
|
checkAnswerFormatValid(answer) {
|
|
|
if (objTypeOf(answer) !== "array") return;
|
|
|
|
|
@@ -152,6 +176,13 @@ export default {
|
|
|
this.quesAnswer || this.quesAnswer === 0 ? [this.quesAnswer] : [];
|
|
|
this.$refs.modalFormComp.validateField(`quesAnswer`, () => {});
|
|
|
},
|
|
|
+ answerAnalysisChange() {
|
|
|
+ this.modalForm.answerAnalysis = [
|
|
|
+ {
|
|
|
+ ...this.answerAnalysis,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ },
|
|
|
questionInfoChange(questionInfo) {
|
|
|
this.modalForm = Object.assign({}, this.modalForm, questionInfo);
|
|
|
},
|
|
@@ -161,6 +192,10 @@ export default {
|
|
|
getData() {
|
|
|
let data = Object.assign({}, this.question, this.modalForm);
|
|
|
data.quesAnswer = JSON.stringify(this.modalForm.quesAnswer);
|
|
|
+ data.answerAnalysis =
|
|
|
+ data.answerAnalysis && data.answerAnalysis?.length
|
|
|
+ ? data.answerAnalysis[0]
|
|
|
+ : { sections: [] };
|
|
|
return data;
|
|
|
},
|
|
|
activeQuestion() {
|