|
@@ -8,7 +8,7 @@
|
|
|
<el-col :span="24" class="main">
|
|
|
<el-col :span="24" class="leaveBtn"> </el-col>
|
|
|
<el-col :span="24" class="leaveList">
|
|
|
- <datiList :datilist="datilist"></datiList>
|
|
|
+ <datiList :datilist="datilist" :form="form" :answer="answer" @submit="onsave"></datiList>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
@@ -21,6 +21,8 @@ import NavBar from '@/layout/common/topInfo.vue';
|
|
|
import datiList from '@/layout/user/datiList.vue';
|
|
|
import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
|
|
|
const { mapActions: mapTask } = createNamespacedHelpers('task');
|
|
|
+const { mapActions: mapTaskUploadtask } = createNamespacedHelpers('uploadtask');
|
|
|
+
|
|
|
export default {
|
|
|
name: 'homework',
|
|
|
props: {},
|
|
@@ -35,6 +37,9 @@ export default {
|
|
|
navShow: true,
|
|
|
title: '',
|
|
|
isleftarrow: '',
|
|
|
+ answer: [],
|
|
|
+ form: {},
|
|
|
+ taskid: '',
|
|
|
}),
|
|
|
mounted() {
|
|
|
this.title = this.$route.meta.title;
|
|
@@ -55,26 +60,88 @@ export default {
|
|
|
name() {
|
|
|
return this.$route.query.name;
|
|
|
},
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
+ lessonid() {
|
|
|
+ return this.$route.query.lessonid;
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
...mapTask({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
|
|
|
+ ...mapTaskUploadtask({ Uploadtasklist: 'query', Uploadtaskadd: 'create', Uploadtaskfet: 'fetch', Uploadtaskupdates: 'update' }),
|
|
|
+
|
|
|
+ //查询作业
|
|
|
async search() {
|
|
|
console.log(this.name);
|
|
|
const res = await this.list();
|
|
|
- var tilist = res.data.filter(item => item.name === this.name);
|
|
|
- for (const result of tilist) {
|
|
|
- this.$set(this, `datilist`, result);
|
|
|
|
|
|
- for (const option of result.question) {
|
|
|
-
|
|
|
- console.log(answer);
|
|
|
+ var tilist = res.data.filter(item => item.code === this.id);
|
|
|
+ let result = tilist[0];
|
|
|
+ console.log(result.id);
|
|
|
+ this.$set(this, `taskid`, result.id);
|
|
|
+ result.question = result.question.map(i => {
|
|
|
+ if (i.type == 1) {
|
|
|
+ i.answers = [];
|
|
|
+ } else {
|
|
|
+ i.answers = '';
|
|
|
}
|
|
|
|
|
|
- // let answer=[]
|
|
|
- }
|
|
|
+ // i.answers = JSON.parse(i.answers);
|
|
|
+ return i;
|
|
|
+ console.log(result.question);
|
|
|
+ });
|
|
|
+ this.$set(this, `datilist`, result);
|
|
|
|
|
|
this.loading = false;
|
|
|
},
|
|
|
+
|
|
|
+ async onsave() {
|
|
|
+ // let data = this.datilist.question;
|
|
|
+ // let new_arr = [];
|
|
|
+ // for (const acc of data) {
|
|
|
+
|
|
|
+ // let less = { questionid: acc._id };
|
|
|
+ // less.answer = JSON.stringify(acc.answers);
|
|
|
+ // new_arr.push(less.answer);
|
|
|
+ // console.log(less);
|
|
|
+ // let answers = [less];
|
|
|
+ // let lesson = { termid: this.user.termid, lessonid: this.lessonid, batchid: this.user.batchid, classid: this.user.classid, studentid: this.user.userid };
|
|
|
+ // lesson.answers = answers;
|
|
|
+ // console.log(lesson);
|
|
|
+ // }
|
|
|
+ let answerss = {
|
|
|
+ termid: this.user.termid,
|
|
|
+ batchid: this.user.batchid,
|
|
|
+ classid: this.user.classid,
|
|
|
+ lessonid: this.lessonid,
|
|
|
+ studentid: this.user.userid,
|
|
|
+ taskid: this.taskid,
|
|
|
+ };
|
|
|
+ let answers = {};
|
|
|
+
|
|
|
+ let data = this.datilist.question;
|
|
|
+ var answer = data.map(i => {
|
|
|
+ answers.questionid = i._id;
|
|
|
+ answers.answer = JSON.stringify(i.answers);
|
|
|
+
|
|
|
+ if (i.type == 1) {
|
|
|
+ return {
|
|
|
+ answer: JSON.stringify(i.answers),
|
|
|
+ questionid: i._id,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ answer: i.answers,
|
|
|
+ questionid: i._id,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log(answer);
|
|
|
+
|
|
|
+ answerss.answer = answer;
|
|
|
+ let res = await this.Uploadtaskadd(answerss);
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|