-
@@ -616,11 +809,11 @@ export default {
methods: {
// v1.5
//上传截图
- openStem(obj, index, indexs, type) {
+ openStem(obj, type, index, indexs) {
this.iframeLoading = true;
+ this.stem.type = type;
this.stem.index = index;
this.stem.indexs = indexs;
- this.stem.type = type;
if (type == 1) {
if (!obj.screenshot || obj.screenshot == "") {
this.iframeLoading = false;
@@ -643,14 +836,24 @@ export default {
if (res && res.status == 0) {
if (this.stem.type == 1) {
this.stem.screenshot = res.data.url;
- this.form.questionList[this.stem.index].subQuestions[
- this.stem.indexs
- ].screenshot = this.stem.screenshot;
+ if (this.form.questionList[0]?.subQuestions) {
+ this.form.questionList[this.stem.index].subQuestions[
+ this.stem.indexs
+ ].screenshot = this.stem.screenshot;
+ } else {
+ this.form.questionList[this.stem.index].screenshot =
+ this.stem.screenshot;
+ }
} else {
this.stem.answerScreenshot = res.data.url;
- this.form.questionList[this.stem.index].subQuestions[
- this.stem.indexs
- ].answerScreenshot = this.stem.answerScreenshot;
+ if (this.form.questionList[0]?.subQuestions) {
+ this.form.questionList[this.stem.index].subQuestions[
+ this.stem.indexs
+ ].answerScreenshot = this.stem.answerScreenshot;
+ } else {
+ this.form.questionList[this.stem.index].answerScreenshot =
+ this.stem.answerScreenshot;
+ }
}
this.$message.success("上传成功");
} else {
@@ -662,7 +865,7 @@ export default {
this.$message.error("上传失败");
},
// 知识点
- openKnowledge(obj, index) {
+ openKnowledge(obj, index, indexs) {
this.stem.index = index;
this.stem.indexs = indexs;
this.stem.knowledge = (obj.knowledge && obj.knowledge.split("#")) || [];
@@ -742,10 +945,67 @@ export default {
//整理问题
formateQuestion() {
this.formatQuestionList();
- this.form.questionList?.map((item) => {
+ if (this.form.questionList[0]?.subQuestions) {
+ this.form.questionList?.map((item) => {
+ let types = [{}];
+ let addndex = 0;
+ item.subQuestions?.map((sub, index) => {
+ if (!!sub.questionType) {
+ if (
+ sub.questionType == types[addndex].qusType &&
+ sub.questionType != 5
+ ) {
+ //同类型批量答案+1
+ types[addndex].subNum += 1;
+ if (
+ types[addndex].answerOptions.length < sub.answerOptions.length
+ ) {
+ types[addndex].answerOptions = sub.answerOptions;
+ }
+
+ // types[addndex].answerList += this.setAnswer(
+ // sub.questionType,
+ // sub.correctAnswer
+ // );
+ types[addndex].answerList = "";
+ if (index == item.subQuestions.length - 1) {
+ //循环最后类型数量大于等于5,保存批量答案
+ if (types[addndex].subNum && types[addndex].subNum >= 5) {
+ types[addndex].endIndex = sub.questionIndex;
+ types[addndex].index = index;
+ }
+ }
+ } else {
+ if (types[addndex].subNum && types[addndex].subNum >= 5) {
+ //不同类型时如果原有类型数量大于等于5,保存批量答案
+ types[addndex].endIndex =
+ item.subQuestions[index - 1].questionIndex;
+ types[addndex].index = index - 1;
+ addndex += 1;
+ types[addndex] = {};
+ }
+ //不同类型初始化批量答案
+ types[addndex].qusType = sub.questionType;
+ types[addndex].subNum = 1;
+ types[addndex].answerOptions = sub.answerOptions;
+ types[addndex].answerList = "";
+ }
+ }
+ });
+ for (let i = 0; i < types.length; i++) {
+ if (types[i].subNum >= 5) {
+ item.subQuestions?.splice(
+ types[i].index + i + 1,
+ 0,
+ deepClone(types[i])
+ );
+ }
+ }
+ });
+ } else {
let types = [{}];
let addndex = 0;
- item.subQuestions?.map((sub, index) => {
+ this.form.questionList = this.form.questionList.map((sub, index) => {
if (!!sub.questionType) {
if (
sub.questionType == types[addndex].qusType &&
@@ -758,13 +1018,12 @@ export default {
) {
types[addndex].answerOptions = sub.answerOptions;
}
-
// types[addndex].answerList += this.setAnswer(
// sub.questionType,
// sub.correctAnswer
// );
types[addndex].answerList = "";
- if (index == item.subQuestions.length - 1) {
+ if (index == this.form.questionList.length - 1) {
//循环最后类型数量大于等于5,保存批量答案
if (types[addndex].subNum && types[addndex].subNum >= 5) {
types[addndex].endIndex = sub.questionIndex;
@@ -775,7 +1034,7 @@ export default {
if (types[addndex].subNum && types[addndex].subNum >= 5) {
//不同类型时如果原有类型数量大于等于5,保存批量答案
types[addndex].endIndex =
- item.subQuestions[index - 1].questionIndex;
+ this.form.questionList[index - 1].questionIndex;
types[addndex].index = index - 1;
addndex += 1;
types[addndex] = {};
@@ -787,35 +1046,56 @@ export default {
types[addndex].answerList = "";
}
}
+ return sub;
});
for (let i = 0; i < types.length; i++) {
+ if (types[i].qusType == 3) {
+ types[i].answerList = types[i].answerList.slice(0, -1);
+ }
if (types[i].subNum >= 5) {
- item.subQuestions?.splice(
+ this.form.questionList.splice(
types[i].index + i + 1,
0,
deepClone(types[i])
);
}
}
- });
+ }
},
//初始化要修改的答案
- setFormAns(indexs, index) {
- this.formAns = { ...this.form.questionList[index].subQuestions[indexs] };
- this.formAns.listIndex = index;
+ setFormAns(index, indexs) {
let answerList = "";
- let startIndex = indexs - this.formAns.subNum; //批量设置大难开始位置
- this.form.questionList[index].subQuestions.map((item, subIdx) => {
- if (subIdx >= startIndex && subIdx < indexs) {
- answerList += this.setAnswer(item.questionType, item.correctAnswer);
-
- if (item.qusType == 3) {
- answerList = answerList.slice(0, -1);
+ if (this.form.questionList[0]?.subQuestions) {
+ this.formAns = {
+ ...this.form.questionList[index].subQuestions[indexs],
+ };
+ this.formAns.listIndex = index;
+ let startIndex = indexs - this.formAns.subNum; //批量设置大难开始位置
+ this.form.questionList[index].subQuestions.map((item, subIdx) => {
+ if (subIdx >= startIndex && subIdx < indexs) {
+ answerList += this.setAnswer(item.questionType, item.correctAnswer);
+
+ if (item.qusType == 3) {
+ answerList = answerList.slice(0, -1);
+ }
}
- }
- });
- this.formAns.answerList = answerList;
+ });
+ } else {
+ this.formAns = { ...this.form.questionList[index] };
+ let startIndex = index - this.formAns.subNum; //批量设置开始位置
+ this.formAns.answerList = [];
+ this.formAns.listIndex = index;
+ this.form.questionList.map((item, subIdx) => {
+ if (subIdx >= startIndex && subIdx < index) {
+ answerList += this.setAnswer(item.questionType, item.correctAnswer);
+ if (item.qusType == 3) {
+ answerList = answerList.slice(0, -1);
+ }
+ }
+ });
+ }
+ this.formAns.answerList = answerList;
this.diaSetAns = true;
},
insertTxtAndSetcursor(element, answerList, str) {
@@ -992,20 +1272,31 @@ export default {
//删除批量操作数据
formatQuestionList() {
for (let i = 0; i < this.form.questionList.length; i++) {
- for (
- let j = 0;
- j < this.form.questionList[i].subQuestions?.length;
- j++
- ) {
- if (this.form.questionList[i].subQuestions[j]?.qusType) {
- this.form.questionList[i].subQuestions?.splice(j, 1);
+ if (this.form.questionList[0]?.subQuestions) {
+ for (
+ let j = 0;
+ j < this.form.questionList[i].subQuestions?.length;
+ j++
+ ) {
+ if (this.form.questionList[i].subQuestions[j]?.qusType) {
+ this.form.questionList[i].subQuestions?.splice(j, 1);
+ }
+ }
+ } else {
+ if (this.form.questionList[i].qusType) {
+ this.form.questionList.splice(i, 1);
+ i--;
}
}
}
},
//删除题
- delTabData(subIndex, index) {
- this.form.questionList[index].subQuestions.splice(subIndex, 1);
+ delTabData(index, subIndex) {
+ if (this.form.questionList[0].subQuestions) {
+ this.form.questionList[index].subQuestions.splice(subIndex, 1);
+ } else {
+ this.form.questionList[index].splice(subIndex, 1);
+ }
this.formateQuestion();
},
//切换题型
@@ -1188,22 +1479,28 @@ export default {
}
}
this.form.questionList = data.questionList?.map((item) => {
- let subQuestions =
- item.subQuestions?.map((items) => {
- return {
- ...items,
- selectNum: items.answerOptions?.split(",").length,
- answerOptions: items.answerOptions || "A,B,C,D",
- screenshot: items.screenshot || "",
- correctAnswer: items.correctAnswer || "",
- knowledge: items.knowledge || "",
- };
- }) || [];
- return {
- questionTitle: item.questionTitle,
- subQuestions: subQuestions,
- show: false,
- };
+ if (item.subQuestions) {
+ let subQuestions =
+ item.subQuestions?.map((items) => {
+ return {
+ ...items,
+ selectNum: items.answerOptions?.split(",").length,
+ answerOptions: items.answerOptions || "A,B,C,D",
+ screenshot: items.screenshot || "",
+ correctAnswer: items.correctAnswer || "",
+ knowledge: items.knowledge || "",
+ };
+ }) || [];
+ return {
+ questionTitle: item.questionTitle,
+ subQuestions: subQuestions,
+ show: false,
+ };
+ } else {
+ return {
+ ...item,
+ };
+ }
});
},
},
--
libgit2 0.21.4