Browse Source

表单评分

11wqe1 2 months ago
parent
commit
78be389bd5
1 changed files with 38 additions and 93 deletions
  1. 38 93
      src/components/pages/test/check/index.vue

+ 38 - 93
src/components/pages/test/check/index.vue

@@ -1522,7 +1522,7 @@
                 label="dee"
                 width="150px"
                 fixed="right"
-                v-if="scoList.length"
+                v-if="scoListCopy.length"
               >
               <template #header>
                 <div>
@@ -1530,7 +1530,7 @@
                 </div>
               </template>
                 <template slot-scope="scope">
-                  <span>{{ userSco(scope.row.userid) }}</span>
+                  <span>{{ userSco(scope.row.id) }}</span>
                 </template>
               </el-table-column>
               <el-table-column
@@ -2083,6 +2083,7 @@ export default {
         fieldList:[]
       },
       scoList:[],
+      scoListCopy:[],
       quoteV:false,
       openCeVal:false,
       LoadingProgress:0,
@@ -2173,7 +2174,7 @@ export default {
     // ai评分分数
     userSco(){
       return function (val) {
-        const con = this.scoList.find(u => u.uid === val);
+        const con = this.scoListCopy.find(u => u.uid === val);
         // console.log('con',con);
 
         return con ? con.sco : '';
@@ -2370,15 +2371,14 @@ export default {
         this.opQvisible = false
     },
  // 点击开始评分
-    async markSco(){
+    async markSco(){ 
       if (!this.cueWord.openCeTit.trim()) return this.$message.error('请输入标题')
       if (!this.cueWord.openCeCon.trim()) return this.$message.error('请输入指令')
       if (this.cueWord.fieldList.length == 0) return this.$message.error('请选择引用字段')
         this.aiscoLoading = true
 
       let forAllList = [];
-      // this.scoList = []
-
+      this.scoList = []
       for (let index = 0; index < this.tableWorksArray.length; index++) {
           let mkAwit = this.loopSco(this.tableWorksArray[index],index)
           forAllList.push(mkAwit);
@@ -2412,42 +2412,20 @@ export default {
       console.log('loopSco',val);
 
       let userWork =[]
-      let _fileid = ''
-for (let index = 0; index < val.array.length; index++) {
+      let _fileid = []
+      for (let index = 0; index < val.array.length; index++) {
           if (val.array[index].type == 3 && this.cueWord.fieldList.includes(val.array[index].json.title)) {
             userWork += val.array[index].json.title +':'+ val.array[index].json.answer2+','
-            // userWork.push( {
-            //   // type:'文本',
-            //   tit: val.array[index].json.title,
-            //   con: val.array[index].json.answer2
-            // })
           }
           if (val.array[index].type == 5 && this.cueWord.fieldList.includes(val.array[index].json.title)) {
-            // console.log('qqq',val.array[index].json.file)
-            // console.log('888',this.cueWord.fieldList)
-
             if (val.array[index].json.file && val.array[index].json.file[0].url) {
-              // console.log('6666')
-              _fileid = await this.createFileid(val.array[index].json.file[0].url)
+              _fileid.push(val.array[index].json.file[0].url)
             }
 
-            userWork += val.array[index].json.title+':' + _fileid+','
-            // userWork.push( {
-            //   // type:"附件",
-            //   detail:val.array[index].json.detail,
-            //   tit: val.array[index].json.title,
-            //   con: _fileid
-            // })
+            userWork += val.array[index].json.title+':' + _fileid.join('、')+','
           }
           if (val.array[index].type == 7 && this.cueWord.fieldList.includes(val.array[index].json.title)) {
             userWork += val.array[index].json.title+':'+val.array[index].json.answer2+','
-            // userWork.push( {
-            //   // type:"评分",
-            //   rule:`${val.array[index].json.small}分-${val.array[index].json.big}分`,
-            //   detail:val.array[index].json.detail,
-            //   tit: val.array[index].json.title,
-            //   con: val.array[index].json.answer2
-            // })
           }
           if (val.array[index].type == 1 && this.cueWord.fieldList.includes(val.array[index].json.title)) {
             let kk = []
@@ -2455,43 +2433,38 @@ for (let index = 0; index < val.array.length; index++) {
               kk.push(val.array[index].json.array[e].option)
             })
             userWork += val.array[index].json.title+':' +kk.join(',')+','
-            // userWork.push( {
-            //   tit: val.array[index].json.title,
-            //   con: kk.join(','),
-            //   type: val.array[index].json.type == 1?"单选题": "多选题",
-            // })
           }
         }
       return new Promise((resolve, reject) => {
         // const result = userWork.filter(item => this.cueWord.fieldList.includes(item.tit));
 
-        let messages = `NOTICE
-                Role: 你是一个资深的教师,你要根据评分标准,对用户回答进行评分
-                  Language: ${this.getLang()}
-
-                  #目标
-                  作业内容中tit是题目,con是用户回答。
-                  根据用户信息与作业内容进行评分。
+        let messages = `
+NOTICE 
+Role: 你是一个资深的教师,你要根据评分标准,对作业内容进行评分
+Language: ${this.getLang()}
 
-                 #评分资料#
+# 目标
+根据评分标准对作业内容进行评分。
 
-                  评价标准:${this.cueWord.openCeCon}
+# 评价标准 #
+${this.cueWord.openCeCon}
 
-                  作业内容 ${this.cueWord.fieldList.includes('提交人') ? '提交人:' +val.name :''}
-                          ${this.cueWord.fieldList.includes('学段') ? '学段:' +this.getTType(this.teaType[0].id,val.cclassid) :''}
-                          ${this.cueWord.fieldList.includes('年级') ? '年级:' +this.getTType(this.teaType[1].id,val.cclassid) :''}
-                          ${this.cueWord.fieldList.includes('学科') ? '学科:' +this.getTType(this.teaType[2].id,val.cclassid) :''}
-                          ${this.cueWord.fieldList.includes('职务') ? '职务:' +this.getTType(this.teaType[3].id,val.cclassid) :''}
-                          ${this.cueWord.fieldList.includes('教龄') ? '教龄:' +this.getTType(this.teaType[4].id,val.cclassid) :''}
-                          ${this.cueWord.fieldList.includes('作业提交时间') ? '作业提交时间:' +val.time :''}
-                          ${userWork}
+# 作业内容 #
+${this.cueWord.fieldList.includes('提交人') ? '提交人:' + val.name : ''},
+${this.cueWord.fieldList.includes('学段') ? '学段:' + this.getTType(this.teaType[0].id, val.cclassid) : ''}
+${this.cueWord.fieldList.includes('年级') ? '年级:' + this.getTType(this.teaType[1].id, val.cclassid) : ''}
+${this.cueWord.fieldList.includes('学科') ? '学科:' + this.getTType(this.teaType[2].id, val.cclassid) : ''}
+${this.cueWord.fieldList.includes('职务') ? '职务:' + this.getTType(this.teaType[3].id, val.cclassid) : ''}
+${this.cueWord.fieldList.includes('教龄') ? '教龄:' + this.getTType(this.teaType[4].id, val.cclassid) : ''}
+${this.cueWord.fieldList.includes('作业提交时间') ? '作业提交时间:' + val.time : ''} 
+${userWork}
 
-                  #输出要求#
-                  根据评价标准对作业内容进行评分,直接输出合计分数!只输出数字,不要输入任何其他无关内容!
+# 输出要求 #
+根据评价标准对作业内容进行评分,直接输出合计分数!只输出阿拉伯数字,不要输入任何其他无关内容!
 
-                  #输出格式#
-                  分数
-                  `;
+# 输出格式 #
+0
+                `;
 
                   // console.log('messages',messages);
 
@@ -2506,7 +2479,7 @@ for (let index = 0; index < val.array.length; index++) {
           ],
           session_name: uuidv4(),
           userId: this.userid,
-          file_ids: _fileid ? [_fileid] : [],
+          file_ids: [],
           isImage: "",
           model: "gpt-4o-2024-11-20"
           };
@@ -2516,45 +2489,15 @@ for (let index = 0; index < val.array.length; index++) {
                  let data = response.data.FunctionResponse;
                   console.log("data", data);
 
-              try {
-                  //  const prompt = [
-                  //     {
-                  //       role: 'user',
-                  //       content: `输出一个json格式的格式如下:{uid:${ val.userid },sco: ${data.message}}}`,
-                  //     },
-                  //   ];
-                  //   this.chat_no_stream(prompt, { type: 'json_object' }).then((res) => {
-                  //     // this.suggestList = JSON.parse(res).suggest;
-                  //     console.log(res);
-                  //   });
-                  let ind = this.scoList.findIndex(e=> e.uid == val.userid )
-                 console.log('ind',ind);
-
-                  if (ind != -1) {
-                    this.scoList.splice(ind,1,{uid: val.userid ,sco: data.message})
-                  }else{
-                    this.scoList.push({uid: val.userid ,sco: data.message})
-                  }
+                  this.scoList.push({uid: val.id ,sco: data.message})
 
-              } catch (error) {
-                 let ind = this.scoList.findIndex(e=> e.uid == val.userid )
-                 console.log('ind',ind);
-
-                  if (ind != -1) {
-                    this.scoList.splice(ind,1,{uid: val.userid ,sco: ''})
-                  }else{
-                    this.scoList.push({uid: val.userid ,sco: ''})
-                  }
-                // this.scoList.push({uid: val.userid ,sco: data.message})
-                this.$message.error( val.name + '评分失败')
-              }
-              this.LoadingProgress = ((this.scoList.length / this.tableWorksArray.length) * 100).toFixed(0)
+                  this.LoadingProgress = ((this.scoList.length / this.tableWorksArray.length) * 100).toFixed(0)
 
               return resolve(1)
             })
             .catch(error => {
               this.aiscoLoading = false
-              this.$message.error('评分失败')
+              this.$message.error(val.name+'评分失败')
               reject(error)
               console.log(error);
             });
@@ -2576,6 +2519,7 @@ for (let index = 0; index < val.array.length; index++) {
                 this.cueWord = JSON.parse(res.data[0][0].cueWord)
                 this.cueWordCopy = JSON.parse(res.data[0][0].cueWord)
                 this.scoList = JSON.parse(res.data[0][0].json)
+                this.scoListCopy = JSON.parse(res.data[0][0].json)
             }else{
               this.cueWord={
                 openCeCon:'', //指令
@@ -2588,6 +2532,7 @@ for (let index = 0; index < val.array.length; index++) {
                 fieldList:[]
               }
               this.scoList=[]
+              this.scoListCopy=[]
             }
             this.aiscoLoading = false