|
@@ -100,6 +100,7 @@
|
|
|
:upload-data="uploadData"
|
|
|
:upload-url="uploadUrl"
|
|
|
:format="importFileTypes"
|
|
|
+ :accept="accept"
|
|
|
@valid-error="validError"
|
|
|
@upload-success="uploaded"
|
|
|
:auto-upload="false"
|
|
@@ -195,7 +196,7 @@
|
|
|
<div class="qe-part-head-menu">
|
|
|
<el-tabs
|
|
|
v-model="filterQuestionType"
|
|
|
- @tab-click="filterQuestionTypeChange"
|
|
|
+ :before-leave="(val) => filterQuestionTypeChange(val, true)"
|
|
|
>
|
|
|
<el-tab-pane
|
|
|
:label="`全部(${
|
|
@@ -360,6 +361,9 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ accept() {
|
|
|
+ return this.importFileTypes.map((item) => `.${item}`).join(",");
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -428,7 +432,7 @@ export default {
|
|
|
paperData: {
|
|
|
handler() {
|
|
|
this.parseQuestionStatData();
|
|
|
- this.filterQuestionTypeChange({ name: this.filterQuestionType });
|
|
|
+ this.filterQuestionTypeChange(this.filterQuestionType);
|
|
|
this.questionKey = randomCode();
|
|
|
},
|
|
|
},
|
|
@@ -450,6 +454,17 @@ export default {
|
|
|
this.getCourseProperty();
|
|
|
this.uploadData = { courseId: this.modalForm.courseId };
|
|
|
},
|
|
|
+ checkQuestionNormal(question) {
|
|
|
+ if (question.subQuestions?.length) {
|
|
|
+ return (
|
|
|
+ question.subQuestions.filter((sub) => {
|
|
|
+ return sub.questionExceptions.length;
|
|
|
+ }).length === 0
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return !question.questionExceptions.length;
|
|
|
+ }
|
|
|
+ },
|
|
|
parseQuestionStatData() {
|
|
|
const total = calcSum(
|
|
|
this.paperData.map((item) => item.questions.length)
|
|
@@ -457,20 +472,26 @@ export default {
|
|
|
const successCount = calcSum(
|
|
|
this.paperData.map(
|
|
|
(item) =>
|
|
|
- item.questions.filter((v) => !v.questionExceptions.length).length
|
|
|
+ item.questions.filter((v) => {
|
|
|
+ return this.checkQuestionNormal(v);
|
|
|
+ }).length
|
|
|
)
|
|
|
);
|
|
|
const errorCount = calcSum(
|
|
|
this.paperData.map(
|
|
|
(item) =>
|
|
|
- item.questions.filter((v) => v.questionExceptions.length).length
|
|
|
+ item.questions.filter((v) => {
|
|
|
+ return !this.checkQuestionNormal(v);
|
|
|
+ }).length
|
|
|
)
|
|
|
);
|
|
|
const questionTypeStat = {};
|
|
|
this.paperData.forEach((detail) => {
|
|
|
let questions = detail.questions;
|
|
|
if (this.onlyErrorQuestion) {
|
|
|
- questions = questions.filter((v) => v.questionExceptions.length);
|
|
|
+ questions = questions.filter((v) => {
|
|
|
+ return !this.checkQuestionNormal(v);
|
|
|
+ });
|
|
|
}
|
|
|
questions.forEach((question) => {
|
|
|
const { questionType } = question;
|
|
@@ -500,7 +521,8 @@ export default {
|
|
|
},
|
|
|
onlyErrorQuestionChange() {
|
|
|
this.parseQuestionStatData();
|
|
|
- this.filterQuestionTypeChange({ name: this.filterQuestionType });
|
|
|
+ this.filterQuestionTypeChange(this.filterQuestionType, true);
|
|
|
+
|
|
|
this.questionKey = randomCode();
|
|
|
},
|
|
|
inHasIgnore(indexes) {
|
|
@@ -587,12 +609,14 @@ export default {
|
|
|
this.getRichTextIndexList();
|
|
|
});
|
|
|
},
|
|
|
- filterQuestionTypeChange(val) {
|
|
|
- this.filterQuestionType = val.name;
|
|
|
+ filterQuestionTypeChange(val, updateModify = false) {
|
|
|
+ if (updateModify) this.updateCurTagPaperData();
|
|
|
+
|
|
|
+ this.filterQuestionType = val;
|
|
|
|
|
|
const onlyErrorValidater = (question) => {
|
|
|
if (this.onlyErrorQuestion) {
|
|
|
- return Boolean(question.questionExceptions.length);
|
|
|
+ return !this.checkQuestionNormal(question);
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
@@ -966,9 +990,29 @@ export default {
|
|
|
});
|
|
|
return data;
|
|
|
},
|
|
|
+ updateCurTagPaperData() {
|
|
|
+ let tagPaperData = this.$refs.QuestionImportPaperEdit?.getData();
|
|
|
+ const tagPaperMap = {};
|
|
|
+ tagPaperData.forEach((detail) => {
|
|
|
+ detail.questions.forEach((question) => {
|
|
|
+ const id = `${detail.number}-${question.number}`;
|
|
|
+ tagPaperMap[id] = question;
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ this.paperData.forEach((detail) => {
|
|
|
+ detail.questions.forEach((question) => {
|
|
|
+ const id = `${detail.number}-${question.number}`;
|
|
|
+ if (tagPaperMap[id]) {
|
|
|
+ Object.assign(question, tagPaperMap[id]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
getImportPaperData() {
|
|
|
if (!this.$refs.QuestionImportPaperEdit) return [];
|
|
|
- let paperData = deepCopy(this.$refs.QuestionImportPaperEdit.getData());
|
|
|
+ this.updateCurTagPaperData();
|
|
|
+ let paperData = deepCopy(this.paperData);
|
|
|
const transformFieldMap = { body: "quesBody", options: "quesOptions" };
|
|
|
const fields = Object.keys(transformFieldMap);
|
|
|
const course = {
|