|
@@ -96,6 +96,9 @@ export default {
|
|
|
let lessonid = this.lessonid;
|
|
|
|
|
|
let ress = await this.Uploadtasklist({ lessonid });
|
|
|
+
|
|
|
+ console.log(ress.data);
|
|
|
+
|
|
|
console.log(ress.data);
|
|
|
|
|
|
this.$set(this, `resdata`, ress.data);
|
|
@@ -160,131 +163,147 @@ export default {
|
|
|
|
|
|
//上传
|
|
|
let dati = this.resdata;
|
|
|
- //作业
|
|
|
- let task = this.datilist;
|
|
|
-
|
|
|
- task.question.map(n => {
|
|
|
- console.log(n._id);
|
|
|
-
|
|
|
- if (n.type == 1) {
|
|
|
- // a b array类型
|
|
|
- let a = n.answer.split(';');
|
|
|
- let b = n.answers;
|
|
|
-
|
|
|
- let c = new Set(a);
|
|
|
- let d = new Set(b);
|
|
|
- console.log(d);
|
|
|
- console.log(c);
|
|
|
- let differenceABSet = new Set([...d].filter(x => !c.has(x)));
|
|
|
-
|
|
|
- var sc = this.datilist.question.map(a => {
|
|
|
- if (n._id == a._id) {
|
|
|
- console.log('dw');
|
|
|
-
|
|
|
- if (differenceABSet.size === 0) {
|
|
|
- return {
|
|
|
- // 转换成string
|
|
|
- answer: JSON.stringify(n.answers),
|
|
|
- questionid: n._id,
|
|
|
- questionscore: n.score,
|
|
|
- };
|
|
|
+ console.log(dati);
|
|
|
+
|
|
|
+ if (dati.length) {
|
|
|
+ let task = this.datilist;
|
|
|
+ let newsc = [];
|
|
|
+ task.question.map(n => {
|
|
|
+ if (n.type == 1) {
|
|
|
+ // a b array类型
|
|
|
+ let a = n.answer.split(';');
|
|
|
+ let b = n.answers;
|
|
|
+
|
|
|
+ let c = new Set(a);
|
|
|
+ let d = new Set(b);
|
|
|
+
|
|
|
+ let differenceABSet = new Set([...d].filter(x => !c.has(x)));
|
|
|
+
|
|
|
+ var sc = this.datilist.question.map(a => {
|
|
|
+ if (n._id == a._id) {
|
|
|
+ if (differenceABSet.size === 0) {
|
|
|
+ return {
|
|
|
+ // 转换成string
|
|
|
+ // answer: JSON.stringify(n.answers),
|
|
|
+
|
|
|
+ answer: JSON.stringify(n.answers),
|
|
|
+ questionid: n._id,
|
|
|
+ questionscore: n.score,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ // 转换成string
|
|
|
+ // answer: JSON.stringify(n.answers),
|
|
|
+
|
|
|
+ answer: JSON.stringify(n.answers),
|
|
|
+ questionid: n._id,
|
|
|
+ questionscore: 0,
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- console.log(sc);
|
|
|
- } else {
|
|
|
- console.log(this.datilist.question);
|
|
|
-
|
|
|
- var sc = this.datilist.question.map(a => {
|
|
|
- console.log(n._id);
|
|
|
- console.log(a.questionid);
|
|
|
-
|
|
|
- if (n._id == a._id) {
|
|
|
- if (n.answers === n.answer) {
|
|
|
- return {
|
|
|
- answer: n.answers,
|
|
|
- questionid: n._id,
|
|
|
- questionscore: n.score,
|
|
|
- };
|
|
|
- } else {
|
|
|
- return {
|
|
|
- answer: n.answers,
|
|
|
- questionid: n._id,
|
|
|
- questionscore: 0,
|
|
|
- };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ var sc = this.datilist.question.map(a => {
|
|
|
+ if (n._id == a._id) {
|
|
|
+ if (n.answers === n.answer) {
|
|
|
+ return {
|
|
|
+ answer: n.answers,
|
|
|
+ questionid: n._id,
|
|
|
+ questionscore: n.score,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ answer: n.answers,
|
|
|
+ questionid: n._id,
|
|
|
+ questionscore: 0,
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // var sc = shangchan.answers.map(a => {
|
|
|
- // //字符串判断答案
|
|
|
- // if (n._id == a.questionid) {
|
|
|
- // if (n.answers === n.answer) {
|
|
|
- // return {
|
|
|
- // answer: n.answers,
|
|
|
- // questionid: n._id,
|
|
|
- // questionscore: n.score,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- // console.log(sc);
|
|
|
+ newsc = [...sc, ...newsc];
|
|
|
|
|
|
- //合并数组
|
|
|
- // newsc = [...sc, ...newsc];
|
|
|
- // var arr = newsc.filter(item => item);
|
|
|
- // answerss.answers = arr;
|
|
|
- });
|
|
|
+ var arr = newsc.filter(item => item);
|
|
|
+ answerss.answers = arr;
|
|
|
+ });
|
|
|
+ console.log(answerss);
|
|
|
+
|
|
|
+ let res = await this.Uploadtaskupdates(answerss);
|
|
|
+ } else {
|
|
|
+ //作业
|
|
|
+ let task = this.datilist;
|
|
|
+ let newsc = [];
|
|
|
+ task.question.map(n => {
|
|
|
+ console.log(n._id);
|
|
|
|
|
|
- // //合并集合时使用
|
|
|
- // let newsc = [];
|
|
|
- // for (const shangchan of dati) {
|
|
|
- // console.log(shangchan);
|
|
|
- // task.question.map(n => {
|
|
|
- // if (n.type == 1) {
|
|
|
- // // a b array类型
|
|
|
- // let a = n.answer.split(';');
|
|
|
- // let b = n.answers;
|
|
|
- // console.log(b);
|
|
|
- // let c = new Set(a);
|
|
|
- // let d = new Set(b);
|
|
|
- // //差集判断答案
|
|
|
- // let differenceABSet = new Set([...d].filter(x => !c.has(x)));
|
|
|
- // var sc = shangchan.answers.map(a => {
|
|
|
- // if (n._id == a.questionid) {
|
|
|
- // if (differenceABSet.size === 0) {
|
|
|
- // return {
|
|
|
- // // 转换成string
|
|
|
- // answer: JSON.stringify(n.answers),
|
|
|
- // questionid: n._id,
|
|
|
- // questionscore: n.score,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- // } else {
|
|
|
- // var sc = shangchan.answers.map(a => {
|
|
|
- // //字符串判断答案
|
|
|
- // if (n._id == a.questionid) {
|
|
|
- // if (n.answers === n.answer) {
|
|
|
- // return {
|
|
|
- // answer: n.answers,
|
|
|
- // questionid: n._id,
|
|
|
- // questionscore: n.score,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
- // //合并数组
|
|
|
- // newsc = [...sc, ...newsc];
|
|
|
- // var arr = newsc.filter(item => item);
|
|
|
- // answerss.answers = arr;
|
|
|
- // });
|
|
|
- // }
|
|
|
- // let res = await this.Uploadtaskupdates(answerss);
|
|
|
+ if (n.type == 1) {
|
|
|
+ // a b array类型
|
|
|
+ let a = n.answer.split(';');
|
|
|
+ let b = n.answers;
|
|
|
+
|
|
|
+ let c = new Set(a);
|
|
|
+ let d = new Set(b);
|
|
|
+
|
|
|
+ let differenceABSet = new Set([...d].filter(x => !c.has(x)));
|
|
|
+
|
|
|
+ var sc = this.datilist.question.map(a => {
|
|
|
+ if (n._id == a._id) {
|
|
|
+ if (differenceABSet.size === 0) {
|
|
|
+ console.log(n.answers);
|
|
|
+
|
|
|
+ return {
|
|
|
+ // 转换成string
|
|
|
+ // answer: JSON.stringify(n.answers),
|
|
|
+
|
|
|
+ answer: JSON.stringify(n.answers),
|
|
|
+ questionid: n._id,
|
|
|
+ questionscore: n.score,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ // 转换成string
|
|
|
+ // answer: JSON.stringify(n.answers),
|
|
|
+
|
|
|
+ answer: JSON.stringify(n.answers),
|
|
|
+ questionid: n._id,
|
|
|
+ questionscore: 0,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log(this.datilist.question);
|
|
|
+ var sc = this.datilist.question.map(a => {
|
|
|
+ if (n._id == a._id) {
|
|
|
+ if (n.answers === n.answer) {
|
|
|
+ return {
|
|
|
+ answer: n.answers,
|
|
|
+ questionid: n._id,
|
|
|
+ questionscore: n.score,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ answer: n.answers,
|
|
|
+ questionid: n._id,
|
|
|
+ questionscore: 0,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ newsc = [...sc, ...newsc];
|
|
|
+
|
|
|
+ console.log(newsc);
|
|
|
+ var arr = newsc.filter(item => item);
|
|
|
+ answerss.answers = arr;
|
|
|
+ console.log(answerss);
|
|
|
+ });
|
|
|
+ console.log(answerss);
|
|
|
+
|
|
|
+ let res = await this.Uploadtaskadd(answerss);
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
};
|