瀏覽代碼

预览mdtxt,判断ai返回评分是否正确

11wqe1 7 月之前
父節點
當前提交
08a60caa28

+ 91 - 13
src/components/easy2/commpont/markDialog.vue

@@ -284,15 +284,19 @@
             ></iframe>
           </div>
           <div v-if="currentUid.type == 12" style="height: 100%;">
-            <div>
+            <!-- <div style="margin-bottom: 10px;">
               <div
                 style="cursor: pointer;"
                 @click="downloadFile(currentUid.content)"
               >
-                下载txt
+                下载文件
               </div>
-              <!-- <div>{{ currentUid.content }}</div> -->
-            </div>
+            </div> -->
+            <div>{{ TxtMd }}</div>
+            <!-- <div
+              v-html="htmlContent(currentUid.content)"
+            ></div> -->
+            
           </div>
           <div v-if="currentUid.type == 15" style="height: 100%;">
             <div
@@ -376,7 +380,46 @@
 
 <script>
 import { v4 as uuidv4 } from "uuid";
-
+import MarkdownIt from "markdown-it";
+const getFile = (url) => {
+	return new Promise((resolve, reject) => {
+		var credentials = {
+			accessKeyId: "AKIATLPEDU37QV5CHLMH",
+			secretAccessKey: "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",
+		}; //秘钥形式的登录上传
+		window.AWS.config.update(credentials);
+		window.AWS.config.region = "cn-northwest-1"; //设置区域
+		let url2 = url;
+		let _url2 = "";
+		if (
+			url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
+		) {
+			_url2 = url2.split(
+				"https://view.officeapps.live.com/op/view.aspx?src="
+			)[1];
+		} else {
+			_url2 = url2;
+		}
+		var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
+		let name = decodeURIComponent(
+			_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1]
+		);
+		var params = {
+			Bucket: "ccrb",
+			Key: name,
+		};
+		s3.getObject(params, function (err, data) {
+			if (err) {
+				console.log(err, err.stack);
+				resolve({ data: 1 });
+			} else {
+				const fileContent = data.Body.toString('utf-8');
+				resolve({ data: fileContent });
+			} // sxuccessful response
+		});
+		// axios({
+	});
+};
 export default {
   props: [
     "uid",
@@ -398,7 +441,8 @@ export default {
       workList: [], //作业列表
       cid: this.$route.query.courseId,
       cUserid: this.$route.query.userid, //账号登录人id
-      cuScoCon: "",
+      cuScoCon: "", //学生作业内容
+      TxtMd:'',   //txt,md作业内容
       currentUid: {}, //当前评分框学生信息
       current: "", //上一位下一位中的第几位
       DgUid: this.uid, //当前评分框学生id
@@ -434,7 +478,7 @@ export default {
           fullscreenToggle: true //全屏按钮
         }
       },
-      xianObj: ["DOCX", "MD", "TXT", "PDF" ,"PPTX"]
+      xianObj: ["DOCX", "MD", "TXT", "PDF"]
     };
   },
   watch: {
@@ -695,14 +739,15 @@ export default {
             });
 
 
+            // 判断返回数据正确数量
             let IsAIsuccess = 0
-
             for (const tKey in this.scoTitList) {
               for (const key in processedData) {
                 let result = this.scoTitList[tKey].detail.match(/[\u4e00-\u9fa5a-zA-Z]+/g).join("");
                 let key2 = key.match(/[\u4e00-\u9fa5a-zA-Z]+/g).join("");
                 if (key != "评语") {
-                  if (result.indexOf(key2) != -1) {
+                  let isNumK = /^\d+(\.\d+)?$/.test(processedData[key]);
+                  if (result.indexOf(key2) != -1 && isNumK) {
                      IsAIsuccess++
                   }
                   continue;
@@ -711,6 +756,7 @@ export default {
               continue;
             }
 
+            // 计算可以ai评分的评价标准数量
             let scotNum = 0
             this.scoTitList.forEach(e=>{
               if (e.isai == 1) {
@@ -720,8 +766,8 @@ export default {
 
 
             if (IsAIsuccess != scotNum) {
-              // _this.$message.error("评价失败");
-              // _this.ScLoading = false;
+              console.log('评价失败');
+              
               this.aiGet2(messages,_fileid)
               return
             }
@@ -877,6 +923,7 @@ export default {
         .then(res => {
           let data = res.data[0];
 
+          // markSco为提交列表展示的分数
           data.forEach(e => {
             if (e.rate) {
               let data2 = JSON.parse(e.rate);
@@ -901,11 +948,15 @@ export default {
               e.markSco = null;
             }
           });
+          // 提交列表
           this.workList = data;
 
           data.forEach((e, index) => {
             if (e.userid == this.DgUid) {
               this.currentUid = e;
+              console.log('e',e);
+              
+              // 1截图  3问答 4word文档类型 5视频  10表格 13文档 
 
               if (
                 this.currentUid.type == 3 ||
@@ -930,6 +981,13 @@ export default {
               if (this.currentUid.type == 5) {
                 this.playerOptions.sources[0].src = this.currentUid.content;
               }
+              if (this.currentUid.type == 12) {
+                this.TxtMd = ''
+                getFile(this.currentUid.content).then(res=>{
+                  this.TxtMd = res.data;
+                })
+               
+              }
               this.current = index;
               this.workId = e.id;
               this.appraise(e);
@@ -972,6 +1030,7 @@ export default {
         .then(res => {
           let data = res.data[0];
 
+          // 计算markSco提交列表分数
           data.forEach(e => {
             if (e.rate) {
               let data2 = JSON.parse(e.rate);
@@ -996,12 +1055,15 @@ export default {
               e.markSco = null;
             }
           });
+          // 提交列表
           this.workList = data;
 
+
+          // 划分作业类型
           data.forEach((e, index) => {
             if (e.userid == this.DgUid) {
               this.currentUid = e;
-
+              // 1截图  3问答 4word文档类型 5视频  10表格 13文档 
               if (
                 this.currentUid.type == 3 ||
                 this.currentUid.type == 10 ||
@@ -1014,17 +1076,26 @@ export default {
               if (this.currentUid.type == 4) {
                 let a = this.currentUid.content;
                 let data = a.slice(a.lastIndexOf(".") + 1);
-                this.cuScoCon = this.currentUid.content;
 
                 if (data == "pdf") {
                   this.ifPdf = 1;
                 } else {
                   this.ifPdf = 0;
                 }
+                this.cuScoCon = this.currentUid.content;
+
               }
               if (this.currentUid.type == 5) {
                 this.playerOptions.sources[0].src = this.currentUid.content;
               }
+              if (this.currentUid.type == 12) {
+                this.TxtMd = ''
+                getFile(this.currentUid.content).then(res=>{
+                  this.TxtMd = res.data;
+                })
+               
+              }
+              
               this.workId = e.id;
               this.appraise(e);
             }
@@ -1408,4 +1479,11 @@ export default {
 .video-player >>> .video-js {
   height: 100%;
 }
+.markBox{
+  padding: 20px 14px;
+  line-height: 29px;
+  font-size: 16px;
+  background: #f4f4f4;
+  border-radius: 5px;
+}
 </style>

+ 3 - 1
src/components/easy2/commpont/markScore.vue

@@ -530,7 +530,9 @@ export default {
                   let result = this.scoTitList[tKey].detail.match(/[\u4e00-\u9fa5a-zA-Z]+/g).join("");
                   let key2 = key.match(/[\u4e00-\u9fa5a-zA-Z]+/g).join("");
                   if (key != "评语") {
-                    if (result.indexOf(key2) != -1) {
+                  let isNumK = /^\d+(\.\d+)?$/.test(processedData[key]);
+
+                    if (result.indexOf(key2) != -1 && isNumK) {
                       IsAIsuccess++
                     }
                     continue;

+ 1 - 16
src/components/easy2/studyStudent.vue

@@ -13701,26 +13701,11 @@ export default {
        
         forAllList.push(mkAwit)
 
-
-
-        
         // this.$refs[mk][0].getData()
 
         // this.AIloading[toolIndex][i].loading=false
       }
-      // console.log('forAllList',forAllList);
-      
-      // Promise.allSettled(forAllList)
-      // .then(results => {
-      //   results.forEach(result => {
-      //     if (result.status === 'fulfilled') {
-      //       console.log('成功:', result.value);
-      //     } else if (result.status === 'rejected') {
-      //       console.log('失败:', result.reason);
-      //       // 在这里可以选择如何处理失败的 Promise,而不会中止整个 Promise.allSettled
-      //     }
-      //   });
-      // });
+     
       Promise.all(forAllList).then(values=>{
         console.log('values',values)
         this.$message({