|
@@ -1327,36 +1327,63 @@ export default {
|
|
|
let courseCount11 = []
|
|
|
let testArray = []
|
|
|
let array = []
|
|
|
+ let courseIds = []; // 初始化一个空数组来存储所有的courseId
|
|
|
for (let i = 0; i < this.works.length; i++) {
|
|
|
let cJson = this.setJSON(JSON.parse(JSON.stringify(JSON.parse(this.works[i].courseJson))))
|
|
|
if (JSON.stringify(cJson) == JSON.stringify(chapters)) {
|
|
|
let _json = this.JSONSetting(JSON.parse(JSON.stringify(JSON.parse(this.works[i].courseJson))))
|
|
|
|
|
|
for (var ja = 0; ja < _json.length; ja++) {
|
|
|
- let _json2 = _json[ja].json
|
|
|
+ let _json2 = _json[ja].json;
|
|
|
if (_json[ja].type == 6) {
|
|
|
- let _cjson = await this.getCourse(_json2.answer2)
|
|
|
- _json[ja].json.answer2 = _cjson ? _cjson.title : ''
|
|
|
+ let courseId = _json2.answer2;
|
|
|
+ courseIds.push(courseId); // 将type为6的courseId添加到数组中
|
|
|
}
|
|
|
- if(_json[ja].type == 11){
|
|
|
- let _answer = _json2.answer2
|
|
|
- _answer.length ? courseCount11 = courseCount11.concat(_answer) : ''
|
|
|
+ if (_json[ja].type == 11) {
|
|
|
+ let _answer = _json2.answer2;
|
|
|
+ _answer.length ? courseCount11 = courseCount11.concat(_answer) : '';
|
|
|
_json[ja].json.courseId = _answer ? _answer : [];
|
|
|
- let params = {
|
|
|
- cid:_answer.length ? _answer.join(",") : ''
|
|
|
- }
|
|
|
+ courseIds = courseIds.concat(_answer); // 将type为11的courseId添加到数组中
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将所有的courseId去重
|
|
|
+ courseIds = Array.from(new Set(courseIds));
|
|
|
+ // 使用一个数组来存储所有的courseId后,执行getCourseInfoTestAll
|
|
|
+ let courseTitles = {}; // 初始化一个空对象来存储所有的courseTitles
|
|
|
+ let params2 = [{
|
|
|
+ cid: courseIds.join(",")
|
|
|
+ }]
|
|
|
+
|
|
|
+ let data2 = await this.ajax.post(this.$store.state.api + 'getCourseInfoTestAll2', params2);
|
|
|
+ let result2 = data2.data[0];
|
|
|
+ result2.forEach(i => {
|
|
|
+ // _title.push(i.title);
|
|
|
+ courseTitles[i.courseId] = i.title;
|
|
|
+ });
|
|
|
+
|
|
|
+ for (let i = 0; i < this.works.length; i++) {
|
|
|
+ let cJson = this.setJSON(JSON.parse(JSON.stringify(JSON.parse(this.works[i].courseJson))))
|
|
|
+ if (JSON.stringify(cJson) == JSON.stringify(chapters)) {
|
|
|
+ let _json = this.JSONSetting(JSON.parse(JSON.stringify(JSON.parse(this.works[i].courseJson))))
|
|
|
|
|
|
- let data = await this.ajax.get(this.$store.state.api + 'getCourseInfoTestAll',params);
|
|
|
- let result = data.data[0]
|
|
|
+ _json.forEach(item => {
|
|
|
+ if (item.type == 11) {
|
|
|
+ let cid = item.json.answer2
|
|
|
let _title = []
|
|
|
- // this.chapters.find(i=>i.type==6).nameFilters = result.map(r=>{return{text:r.title,value:r.courseId}})
|
|
|
- result.forEach(i=>{
|
|
|
- _title.push(i.title)
|
|
|
- })
|
|
|
-
|
|
|
- _json[ja].json.answer2 = _title.length ? _title.join(',') : '';
|
|
|
+ for(var i = 0; i < cid.length; i++){
|
|
|
+ _title.push(courseTitles[cid[i]])
|
|
|
+ }
|
|
|
+ item.json.answer2 = _title.length ? _title.join(",") : '';
|
|
|
}
|
|
|
- }
|
|
|
+ if (item.type == 6) {
|
|
|
+ let courseId = item.json.answer2;
|
|
|
+ item.json.answer2 = courseTitles[courseId] || '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 更新对应的_json对象的answer2
|
|
|
array.push({
|
|
|
courseid: this.works[i].courseid,
|
|
|
id: this.works[i].id,
|
|
@@ -1371,6 +1398,8 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ let allCourseIds = [];
|
|
|
for (var i = 0; i < this.chapters.length; i++) {
|
|
|
let el = this.chapters[i]
|
|
|
let topic = {
|
|
@@ -1382,6 +1411,7 @@ export default {
|
|
|
choice: el.json ? el.json.array : '',
|
|
|
array: [],
|
|
|
answer: el.json ? el.json.answer : '',
|
|
|
+ answer2: '',
|
|
|
count: 0,
|
|
|
courses: el.json ? el.json.courses : [],
|
|
|
small: el.json ? el.json.small : '',
|
|
@@ -1399,30 +1429,9 @@ export default {
|
|
|
} else if (topic.type == 5) {
|
|
|
|
|
|
} else if (topic.type == 6) {
|
|
|
- let _answer = topic.courses
|
|
|
- topic.array = _answer
|
|
|
- topic.courseArray = [];
|
|
|
- let params = {
|
|
|
- cid:topic.array ? topic.array.join(",") : ''
|
|
|
- }
|
|
|
-
|
|
|
- let data = await this.ajax.get(this.$store.state.api + 'getCourseInfoTestAll',params);
|
|
|
- let result = data.data[0]
|
|
|
- // this.chapters.find(i=>i.type==6).nameFilters = result.map(r=>{return{text:r.title,value:r.courseId}})
|
|
|
- result.forEach(i=>{
|
|
|
- if(this.chapters.find(f=>f.type==6).nameFilters.find(c=>c.value==i.title)==undefined){
|
|
|
- this.chapters.find(i=>i.type==6).nameFilters.push({text:i.title,value:i.title})
|
|
|
- }
|
|
|
- })
|
|
|
- // this.chapters.find(i=>i.type==6).nameFilters = result.map(r=>{return{text:r.title,value:r.title}})
|
|
|
- result.forEach(i=>i.update_at=new Date(i.update_at).toLocaleString('zh-CN', {year: 'numeric',month: '2-digit',day: '2-digit',hour: '2-digit',minute: '2-digit',second: '2-digit',hour12: false}).replace(/\//g,'-'))
|
|
|
- topic.courseArray = result;
|
|
|
- // topic.array.forEach(async i => {
|
|
|
- // let data = await this.getCourse(i)
|
|
|
- // console.log(data.update_at)
|
|
|
- // data.update_at = new Date(data.update_at).toLocaleString('zh-CN', {year: 'numeric',month: '2-digit',day: '2-digit',hour: '2-digit',minute: '2-digit',second: '2-digit',hour12: false}).replace(/\//g,'-')
|
|
|
- // topic.courseArray.push(data)
|
|
|
- // })
|
|
|
+ let _answer = topic.array
|
|
|
+
|
|
|
+ allCourseIds = allCourseIds.concat(_answer);
|
|
|
} else if (topic.type == 7) {
|
|
|
for (var t = parseInt(topic.small); t <= parseInt(topic.big); t++) {
|
|
|
topic.array.push({
|
|
@@ -1433,26 +1442,8 @@ export default {
|
|
|
} else if (topic.type == 11) {
|
|
|
const uniqueArray = courseCount11.filter((item, index) => courseCount11.indexOf(item) === index);
|
|
|
let _answer = uniqueArray
|
|
|
- topic.array = _answer
|
|
|
- topic.courseArray = [];
|
|
|
- let params = {
|
|
|
- cid:topic.array ? topic.array.join(",") : ''
|
|
|
- }
|
|
|
-
|
|
|
- let data = await this.ajax.get(this.$store.state.api + 'getCourseInfoTestAll',params);
|
|
|
- let result = data.data[0]
|
|
|
- // this.chapters.find(i=>i.type==6).nameFilters = result.map(r=>{return{text:r.title,value:r.courseId}})
|
|
|
- result.forEach(i=>{
|
|
|
- if(this.chapters.find(f=>f.type==11).nameFilters.find(c=>c.value==i.title)==undefined){
|
|
|
- this.chapters.find(i=>i.type==11).nameFilters.push({text:i.title,value:i.title})
|
|
|
- console.log(this.chapters);
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- result.forEach(i=>i.update_at=new Date(i.update_at).toLocaleString('zh-CN', {year: 'numeric',month: '2-digit',day: '2-digit',hour: '2-digit',minute: '2-digit',second: '2-digit',hour12: false}).replace(/\//g,'-'))
|
|
|
- topic.courseArray = result;
|
|
|
-
|
|
|
+
|
|
|
+ allCourseIds = allCourseIds.concat(_answer);
|
|
|
}
|
|
|
for (var j = 0; j < array.length; j++) {
|
|
|
let el2 = array[j]
|
|
@@ -1483,8 +1474,7 @@ export default {
|
|
|
}
|
|
|
} else if (topic.type == 5) {
|
|
|
let _answer = el2.array[i].json.file ? el2.array[i].json.file : []
|
|
|
- console.log(el2)
|
|
|
- let _user = {userid:el2.userid,username:el2.name}
|
|
|
+ let _user = {userid:el2.userid,username:el2.name}
|
|
|
for (var k = 0; k < _answer.length; k++) {
|
|
|
topic.array.push({..._answer[k],..._user})
|
|
|
}
|
|
@@ -1494,12 +1484,70 @@ export default {
|
|
|
topic.array[_answer].count++
|
|
|
topic.count++
|
|
|
}
|
|
|
+ }else if (topic.type == 6) {
|
|
|
+ if(el2.array[i].json.courses){
|
|
|
+ let _answer = el2.array[i].json.courses.length ? el2.array[i].json.courses.join(",") : ''
|
|
|
+ topic.answer2 = _answer
|
|
|
+ }
|
|
|
+ } else if (topic.type == 11) {
|
|
|
+ if(el2.array[i].json.answer2){
|
|
|
+ let _answer = el2.array[i].json.answer2
|
|
|
+ topic.answer2 = _answer
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
console.log('topictopictopictopic',topic)
|
|
|
testArray.push(topic)
|
|
|
this.fileLoading.push({bool:false,count:0,load:0,progress:0})
|
|
|
}
|
|
|
+
|
|
|
+ // 去重courseId
|
|
|
+ allCourseIds = Array.from(new Set(allCourseIds));
|
|
|
+
|
|
|
+ let params = [{
|
|
|
+ cid: allCourseIds.join(",")
|
|
|
+ }]
|
|
|
+
|
|
|
+ let data = await this.ajax.post(this.$store.state.api + 'getCourseInfoTestAll2',params);
|
|
|
+ let result = data.data[0]
|
|
|
+
|
|
|
+ for (var i = 0; i < this.chapters.length; i++) {
|
|
|
+ let el = this.chapters[i]
|
|
|
+ let topic = testArray[i]
|
|
|
+ if (topic.type == 6 || topic.type == 11) {
|
|
|
+ result.forEach(i=>{
|
|
|
+ i.update_at = new Date(i.update_at).toLocaleString('zh-CN', {year: 'numeric',month: '2-digit',day: '2-digit',hour: '2-digit',minute: '2-digit',second: '2-digit',hour12: false}).replace(/\//g,'-')
|
|
|
+ })
|
|
|
+ if(topic.type == 6){
|
|
|
+ result.forEach(i=>{
|
|
|
+ if(this.chapters.find(f=>f.type==6).nameFilters.find(c=>c.value==i.title)==undefined && topic.answer2.includes(el.courseId)){
|
|
|
+ this.chapters.find(i=>i.type==6).nameFilters.push({text:i.title,value:i.title})
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else if(topic.type == 11){
|
|
|
+ result.forEach(i=>{
|
|
|
+ if(this.chapters.find(f=>f.type==1).nameFilters.find(c=>c.value==i.title)==undefined && topic.answer2.includes(el.title)){
|
|
|
+ this.chapters.find(i=>i.type==11).nameFilters.push({text:i.title,value:i.title})
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // this.chapters.find(i=>i.type==6 || i.type==11).nameFilters = result.map(r=>{return{text:r.title,value:r.courseId}})
|
|
|
+ if(topic.answer2.length){
|
|
|
+ let _answer = topic.answer2
|
|
|
+ topic.courseArray = result.filter(el => {
|
|
|
+ if(topic.type == 11){
|
|
|
+ return _answer.includes(el.title)
|
|
|
+ }else if(topic.type == 6){
|
|
|
+ return _answer.includes(el.courseId)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ topic.courseArray = []
|
|
|
+ }
|
|
|
+ // topic.courseArray = result
|
|
|
+ }
|
|
|
+ }
|
|
|
this.testArray = testArray
|
|
|
this.worksArray = array
|
|
|
this.isLoading = false;
|
|
@@ -2009,11 +2057,11 @@ export default {
|
|
|
let _answer = item.json.answer2
|
|
|
_answer.length ? courseCount11 = courseCount11.concat(_answer) : ''
|
|
|
_json[ja].json.courseId = _answer ? _answer : [];
|
|
|
- let params = {
|
|
|
+ let params = [{
|
|
|
cid:_answer.length ? _answer.join(",") : ''
|
|
|
- }
|
|
|
+ }]
|
|
|
|
|
|
- let data = await this.ajax.get(this.$store.state.api + 'getCourseInfoTestAll',params);
|
|
|
+ let data = await this.ajax.post(this.$store.state.api + 'getCourseInfoTestAll2',params);
|
|
|
let result = data.data[0]
|
|
|
let _title = []
|
|
|
// this.chapters.find(i=>i.type==6).nameFilters = result.map(r=>{return{text:r.title,value:r.courseId}})
|