Parcourir la source

智能表单、ppt模式、啥啥啥的

SanHQin il y a 2 jours
Parent
commit
1458c3a008

+ 75 - 16
src/components/pages/pptEasy/addCourse.vue

@@ -5107,30 +5107,89 @@ export default {
       //   return;
       // }
       // 判断 this.line 链接是不是 html 文件
-      if (!/\.html(\?|#|$)/i.test(this.line) && !/\.htm(\?|#|$)/i.test(this.line)) {
-        this.$message.error("请输入以.html或.htm结尾的链接");
-        return;
-      }
+      // if (!/\.html(\?|#|$)/i.test(this.line) && !/\.htm(\?|#|$)/i.test(this.line)) {
+      //   this.$message.error("请输入以.html或.htm结尾的链接");
+      //   return;
+      // }
 
       //  使用this.ajax.get 请求 this.line 链接,如果返回 200 则认为链接有效
       // 使用XHR请求判断页面是否可以请求到
+      // 先用iframe判断能否访问contentWindow,不能再用XHR请求
       let isValid = await new Promise((resolve) => {
-        let xhr = new XMLHttpRequest();
-        xhr.open('GET', this.line, true);
-        xhr.onreadystatechange = function() {
-          if (xhr.readyState === 4) {
-            // 只要状态码是200就认为可以请求到
-            if (xhr.status === 200) {
-              resolve(true);
-            } else {
-              resolve(false);
+        // 创建隐藏iframe
+        let iframe = document.createElement('iframe');
+        iframe.style.display = 'none';
+        iframe.src = this.line;
+        let timeout = setTimeout(() => {
+          // 超时,移除iframe,进入XHR判断
+          document.body.removeChild(iframe);
+          // 用XHR判断
+          let xhr = new XMLHttpRequest();
+          xhr.open('GET', this.line, true);
+          xhr.onreadystatechange = function() {
+            if (xhr.readyState === 4) {
+              if (xhr.status === 200) {
+                resolve(true);
+              } else {
+                resolve(false);
+              }
             }
+          };
+          xhr.onerror = function() {
+            resolve(false);
+          };
+          xhr.send();
+        }, 5000); // 2秒超时
+
+        iframe.onload = function() {
+          clearTimeout(timeout);
+          try {
+            // 尝试访问contentWindow.document
+            let doc = iframe.contentWindow.document;
+            // 能访问说明同源,页面可用
+            document.body.removeChild(iframe);
+            resolve(true);
+          } catch (e) {
+            // 跨域或其他异常,移除iframe,进入XHR判断
+            document.body.removeChild(iframe);
+            let xhr = new XMLHttpRequest();
+            xhr.open('GET', iframe.src, true);
+            xhr.onreadystatechange = function() {
+              if (xhr.readyState === 4) {
+                if (xhr.status === 200) {
+                  resolve(true);
+                } else {
+                  resolve(false);
+                }
+              }
+            };
+            xhr.onerror = function() {
+              resolve(false);
+            };
+            xhr.send();
           }
         };
-        xhr.onerror = function() {
-          resolve(false);
+        iframe.onerror = function() {
+          clearTimeout(timeout);
+          document.body.removeChild(iframe);
+          // iframe加载失败,进入XHR判断
+          let xhr = new XMLHttpRequest();
+          xhr.open('GET', iframe.src, true);
+          xhr.onreadystatechange = function() {
+            if (xhr.readyState === 4) {
+              if (xhr.status === 200) {
+                resolve(true);
+              } else {
+                resolve(false);
+              }
+            }
+          };
+          xhr.onerror = function() {
+            resolve(false);
+          };
+          xhr.send();
         };
-        xhr.send();
+        document.body.appendChild(iframe);
       });
 
       if (!isValid) {

+ 14 - 24
src/components/pages/test/check/index.vue

@@ -2974,24 +2974,15 @@ ${JSON.stringify(forAllList)}
           let _worksData = res.data[1];
 
           if(this.timeLimit){
+            console.log("timeLimit", this.timeLimit)
+            // 2024-12-31T16:00:00.000Z,2025-12-31T16:00:00.000Z
             // 根据 timeLimit 筛选 _worksData
+            let [startStr, endStr] = this.timeLimit.split(',');
+            let startDate = startStr ? new Date(startStr) : null;
+            let endDate = endStr ? new Date(endStr) : null;
             _worksData = _worksData.filter(i => {
               if (!i.time) return false;
-              // time 例子:2025年02月25日 10:17:46
-              // timeLimit 例子:"2025~2026" 或 "2025"
-              let timeLimit = this.timeLimit;
-              let startYear, endYear;
-              // 判断是否为区间
-              if (timeLimit.includes('~')) {
-                [startYear, endYear] = timeLimit.split('~').map(y => y.trim());
-                startYear = parseInt(startYear);
-                endYear = parseInt(endYear);
-              } else {
-                // 单独一个年份,只获取该年份的数据
-                startYear = parseInt(timeLimit);
-                endYear = startYear;
-              }
-              // 提取年份、月份、日期
+              // i.time 例子:2025年02月25日 10:17:46
               let match = i.time.match(/^(\d{4})年(\d{2})月(\d{2})日/);
               if (!match) return false;
               let year = parseInt(match[1]);
@@ -2999,16 +2990,15 @@ ${JSON.stringify(forAllList)}
               let day = parseInt(match[3]);
               // 构造当前数据的日期对象
               let curDate = new Date(year, month - 1, day, 0, 0, 0);
-              if (startYear === endYear) {
-                // 只获取该年份的数据
-                return year === startYear;
-              } else {
-                // 构造起始日期(包含)
-                let startDate = new Date(startYear, 0, 1, 0, 0, 0);
-                // 构造结束日期(不包含),即endYear年1月1日
-                let endDate = new Date(endYear, 0, 1, 0, 0, 0);
-                return curDate >= startDate && curDate < endDate;
+              // 判断是否在区间内(包含等于)
+              if (startDate && endDate) {
+                return curDate >= startDate && curDate <= endDate;
+              } else if (startDate) {
+                return curDate >= startDate;
+              } else if (endDate) {
+                return curDate <= endDate;
               }
+              return true;
             });
           }
 

+ 43 - 7
src/components/pages/test/checkAi/aiLeader.vue

@@ -1820,14 +1820,45 @@ ${fileText}
 
             for (let i = 0; i < works.length; i++) {
               let cJson = this.setJSON(
+              JSON.parse(JSON.stringify(JSON.parse(works[i].courseJson)))
+            );
+            console.log(cJson,'===',chapters)
+            // if (JSON.stringify(cJson) == JSON.stringify(chapters)) {
+              let _json = this.JSONSetting(
                 JSON.parse(JSON.stringify(JSON.parse(works[i].courseJson)))
               );
-              if (JSON.stringify(cJson) == JSON.stringify(chapters)) {
-                let _json = this.JSONSetting(
-                  JSON.parse(JSON.stringify(JSON.parse(works[i].courseJson)))
-                );
 
-                _json.forEach(item => {
+              let _json2 = this.JSONSetting(
+                JSON.parse(JSON.stringify(JSON.parse(JSON.stringify(chapters))))
+              );
+              // let cJson = this.setJSON(
+              //   JSON.parse(JSON.stringify(JSON.parse(works[i].courseJson)))
+              // );
+              // if (JSON.stringify(cJson) == JSON.stringify(chapters)) {
+                // let _json = this.JSONSetting(
+                //   JSON.parse(JSON.stringify(JSON.parse(works[i].courseJson)))
+                // );
+
+                // _json.forEach(item => {
+                //   if (item.type == 11) {
+                //     let cid = item.json.answer2;
+                //     let _title = [];
+                //     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] || "";
+                //   }
+                // });
+
+
+                _json2.forEach(item=>{
+                let _index = _json.findIndex(i=>(i.type==item.type && i.ttype==item.ttype && i.json.title==item.json.title))
+                if(_index!=-1){
+                  item.json = _json[_index].json;
                   if (item.type == 11) {
                     let cid = item.json.answer2;
                     let _title = [];
@@ -1840,7 +1871,10 @@ ${fileText}
                     let courseId = item.json.answer2;
                     item.json.answer2 = courseTitles[courseId] || "";
                   }
-                });
+                }
+                })
+              if(JSON.stringify(_json2)==JSON.stringify(this.JSONSetting(JSON.parse(JSON.stringify(chapters)))))continue
+
                 // 更新对应的_json对象的answer2
                 array.push({
                   courseid: works[i].courseid,
@@ -1853,13 +1887,15 @@ ${fileText}
                   uteaName: works[i].uteaName,
                   courseJson: JSON.parse(works[i].courseJson)
                 });
-              }
+              // }
             }
             let obj = {
               courseId: testJson.courseId,
               name: testJson.title,
               worksArray: array
             };
+
+            console.log("表单数据=》",obj)
             // this.courseInfoList.push(obj)
             resolve(obj);
           })

+ 33 - 4
src/components/pages/test/examine/conpoments/targetPage.vue

@@ -1509,9 +1509,16 @@ export default {
           testId: val.join(",")
         }
       ];
+      let _fnStr = `selectExamineTestName`
+      if(this.testExamineBaseList[0].value){
+        const timeValue = JSON.parse(this.testExamineBaseList[0].value).time;
+        params[0].startTime = timeValue[0];
+        params[0].endTime = timeValue[1];
+        _fnStr = `selectExamineTestNameFilterTime`
+      }
       return new Promise(resolve => {
         this.ajax
-          .post(this.$store.state.api + "selectExamineTestName", params)
+          .post(this.$store.state.api + _fnStr, params)
           .then(res => {
             // console.log("resresresres", res.data[0]);
             // console.log(res.data[0]);
@@ -1525,7 +1532,14 @@ export default {
 
     // 查看数据来源
     lookPrize(val) {
-      this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${val}&oid=${this.oid}&org=${this.org}&userid=${this.userid}&type=2&role=0&disableBack=true`;
+      if(this.testExamineBaseList[0].value){
+        const timeValue = JSON.parse(this.testExamineBaseList[0].value).time;
+        this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${val}&oid=${this.oid}&org=${this.org}&userid=${this.userid}&type=2&role=0&disableBack=true&timeLimit=${timeValue}`;
+      }else{
+        this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${val}&oid=${this.oid}&org=${this.org}&userid=${this.userid}&type=2&role=0&disableBack=true`;
+      }
+      // this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${val}&oid=${this.oid}&org=${this.org}&userid=${this.userid}&type=2&role=0&disableBack=true`;
+      // this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${val}&oid=${this.oid}&org=${this.org}&userid=${this.userid}&type=2&role=0&disableBack=true&`;
       // this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/test?userid=${this.userid}&oid=45facc0a-1211-11ec-80ad-005056b86db5&org=&role=0`;
       this.diaIframe = true;
     },
@@ -1653,9 +1667,18 @@ export default {
           testId: val.join(",")
         }
       ];
+
+      let _fnStr = `selectExamineTestName`
+      if(this.testExamineBaseList[0].value){
+        const timeValue = JSON.parse(this.testExamineBaseList[0].value).time;
+        params[0].startTime = timeValue[0];
+        params[0].endTime = timeValue[1];
+        _fnStr = `selectExamineTestNameFilterTime`
+      }
+
       return new Promise(resolve => {
         this.ajax
-          .post(this.$store.state.api + "selectExamineTestName", params)
+          .post(this.$store.state.api + _fnStr, params)
           .then(res => {
             console.log("selectExamineTestName", res.data[0]);
             resolve(res.data[0]);
@@ -1671,7 +1694,13 @@ export default {
       // return console.log(val);
       // this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${val}&oid=${this.oid}&org=${this.org}&type=2&role=0&peopleId=${this.userid}`;
 
-      this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${cid}&oid=${val.organizeid}&userid=${this.userid}&org=${val.org}&type=2&role=0&peopleId=${val.userid}&disableBack=true`;
+      if(this.testExamineBaseList[0].value){
+        const timeValue = JSON.parse(this.testExamineBaseList[0].value).time;
+        this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${cid}&oid=${val.organizeid}&userid=${this.userid}&org=${val.org}&type=2&role=0&peopleId=${val.userid}&disableBack=true&timeLimit=${timeValue}`;
+      }else{
+        this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${cid}&oid=${val.organizeid}&userid=${this.userid}&org=${val.org}&type=2&role=0&peopleId=${val.userid}&disableBack=true`;
+      }
+      // this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/checkToTest?cid=${cid}&oid=${val.organizeid}&userid=${this.userid}&org=${val.org}&type=2&role=0&peopleId=${val.userid}&disableBack=true`;
       // this.ifmUrl = `https://beta.pbl.cocorobo.cn/pbl-teacher-table/dist/#/test?userid=${this.userid}&oid=45facc0a-1211-11ec-80ad-005056b86db5&org=&role=0`;
       this.diaIframe = true;
     },

+ 5 - 1
src/components/pages/workPage/index.vue

@@ -456,6 +456,10 @@ export default {
     },
     studentWorkToWorkData(){
       if(this.studentWork && this.workData){
+        console.log("studentWork",this.studentWork)
+        console.log("workData",this.workData)
+
+
         let _work = JSON.parse(JSON.stringify(this.studentWork));
         if ( this.workData.type == "15") {
           this.workData.json.answer = _work.answer;
@@ -641,7 +645,7 @@ export default {
   height: auto;
   padding: 15px 15px 15px 15px;
   display: flex;
-  flex-wrap: wrap;
+  /* flex-wrap: wrap; */
   background-color: #f3f7fd;
   border-radius: 30px;
   margin: 10px 0 10px 0px;