|
@@ -141,6 +141,7 @@ export default {
|
|
|
};
|
|
|
let answers = {};
|
|
|
let data = this.datilist.question;
|
|
|
+
|
|
|
var answer = data.map(i => {
|
|
|
answers.questionid = i._id;
|
|
|
answers.answer = JSON.stringify(i.answers);
|
|
@@ -156,60 +157,134 @@ export default {
|
|
|
};
|
|
|
}
|
|
|
});
|
|
|
- console.log(answer);
|
|
|
|
|
|
//上传
|
|
|
let dati = this.resdata;
|
|
|
//作业
|
|
|
let task = this.datilist;
|
|
|
- console.log(task);
|
|
|
- //合并集合时使用
|
|
|
- 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,
|
|
|
- };
|
|
|
- }
|
|
|
+
|
|
|
+ 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,
|
|
|
+ };
|
|
|
}
|
|
|
- });
|
|
|
- } 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,
|
|
|
- };
|
|
|
- }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ 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,
|
|
|
+ };
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
- //合并数组
|
|
|
- newsc = [...sc, ...newsc];
|
|
|
- var arr = newsc.filter(item => item);
|
|
|
- answerss.answers = arr;
|
|
|
- });
|
|
|
- }
|
|
|
- let res = await this.Uploadtaskupdates(answerss);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 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];
|
|
|
+ // var arr = newsc.filter(item => item);
|
|
|
+ // answerss.answers = arr;
|
|
|
+ });
|
|
|
+
|
|
|
+ // //合并集合时使用
|
|
|
+ // 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);
|
|
|
},
|
|
|
},
|
|
|
};
|