123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- <template>
- <div>
- <div v-loading="loading" style="cursor: pointer;" @click.stop="markScoreDigBtn">
- <div class="scoreTit">
- <div>任务得分</div>
- <div>{{ totalScore ? totalScore : 0 }}分</div>
- </div>
- <div class="allD">
- <div class="scoreStarBack2">
- <div
- v-for="(e, index) in scoTitList"
- :key="index"
- style="height: 30px;"
- >
- <img
- class="rootImg"
- v-if="e.isai == 1 || !e.isai"
- src="../../../assets/icon/newIcons/blueRoot.png"
- alt=""
- />
- </div>
- </div>
- <div class="scoreStar">
- <div v-for="(e, index) in scoTitList" :key="index">
- <div class="scoreStarBack">
- <el-tooltip
- class="item"
- effect="dark"
- :content="e.detail"
- placement="top"
- >
- <div class="briefTit">
- {{ e.detail }}
- </div>
- </el-tooltip>
- <el-rate
- disabled
- disabled-void-color="#ccc"
- v-model="e.cog"
- ></el-rate>
- </div>
- </div>
- </div>
- </div>
- <div class="AreaCss">
- {{ textarea }}
- <!-- <el-input
- type="textarea"
- disabled
- placeholder="您可在此输入评语"
- v-model="textarea"
- style="padding-bottom: 10px;"
- >
- </el-input> -->
- </div>
- <!-- <div style="width:100%;display:flex;justify-content: flex-end;">
- <el-button size="mini" @click="reset">重置</el-button>
- <el-button type="primary" size="mini" @click="submit">确认</el-button>
- <el-button type="primary" size="mini" @click="AIsubmit"
- >AI评分</el-button
- >
- </div> -->
- </div>
- </div>
- </template>
- <script>
- import { v4 as uuidv4 } from "uuid";
- export default {
- name: "PblStudentTableMarkScore",
- props: [
- "scoTit",
- "scoCon",
- "task",
- "stage",
- "loading",
- "wIndex",
- "toolIndex",
- ],
- data() {
- return {
- homeworkVal: [],
- scoTitList: [],
- markScoPopover: false,
- id: this.$route.query.courseId,
- stUid: this.scoCon.userid,
- userid: this.$route.query.userid,
- total: 0
- };
- },
- computed: {
- totalScore() {
- let a = 0;
- let isPing = 0;
- this.scoTitList.forEach(e => {
- if (e.cog || e.cog == "0") {
- a += e.cog * 1;
- } else {
- isPing += 1;
- }
- });
- let data = 0;
- if (isPing == this.scoTit.length) {
- this.$emit("updateDocSco", {
- val: this.toolIndex,
- val2: this.wIndex,
- val3: null
- });
- } else {
- data = (a / this.scoTit.length).toFixed(1);
- this.$emit("updateDocSco", {
- val: this.toolIndex,
- val2: this.wIndex,
- val3: data
- });
- }
- return data;
- }
- },
- mounted() {
- this.scoTitList = JSON.parse(JSON.stringify(this.scoTit));
- this.getData();
- },
- methods: {
-
- // // 获取文档id
- createFileid(url) {
- let _this = this;
- return new Promise((resolve, reject) => {
- try {
- _this.ajax
- .put("https://gpt4.cocorobo.cn/upload_file_knowledge", {
- url: url
- })
- .then(res => {
- let _data = res.data.FunctionResponse;
- if (_data.result && _data.result.id) {
- resolve(_data.result.id);
- } else {
- resolve(1);
- }
- })
- .catch(function(error) {
- resolve(1);
- });
- } catch (e) {
- resolve(1);
- }
- });
- },
- // 获取单个数据
- getData() {
- // this.fileId =[]
- // console.log(' this.scoCon', this.scoCon);
-
- let params = {
- uid: this.scoCon.userid,
- cid: this.id
- };
- this.ajax
- .get(this.$store.state.api + "selectWorksEvaScore", params)
- .then(res => {
- // console.log("res", res.data);
- if (res.data[0].length > 0) {
- var data2 = [];
- res.data[0].forEach((val, index) => {
- if (val.task == this.task) {
- data2 = res.data[0][index];
- this.homeworkVal = res.data[0][index];
- }
- });
- // console.log('data2',data2);
-
- if (data2.length == 0) {
- this.scoTitList = JSON.parse(JSON.stringify(this.scoTit));
- } else {
- let data = JSON.parse(data2.rate);
- this.scoTitList.forEach((e, index) => {
- e.cog = null;
- for (const key in data) {
- // if (e.value.endsWith('。')) {
- // e.value = e.value.slice(0, -1); // 如果字符串以句号结尾,则去除最后一个字符
- // }
- let result = e.detail.match(/[\u4e00-\u9fa5a-zA-Z]+/g).join("");
- let key2 = key.match(/[\u4e00-\u9fa5a-zA-Z]+/g).join("");
- if (result.indexOf(key2) != -1) {
- e.cog = data[key];
- }
- if ("content" == key) {
- this.textarea = data[key];
- }
- }
- });
- this.scoTitList = JSON.parse(JSON.stringify(this.scoTitList));
- // console.log(this.scoTitList);
- }
- } else {
- this.scoTitList = JSON.parse(JSON.stringify(this.scoTit));
- }
- })
- .catch(err => {
- console.error(err);
- });
- },
- markScoreDigBtn() {
- // console.log('11112222');
- this.$emit("markScoreDig", {
- val: this.stUid,
- val2: this.toolIndex,
- tit: this.scoTit,
- uname:this.scoCon.sName
- });
- },
- // 重置
- reset() {
- this.scoTitList.forEach(e => {
- e.cog = 0;
- // console.log(e.cog);
- });
- },
- // 老师提交评分
- submit() {
- let data = this.scoTitList.map(e => {
- return e.detail + ":" + e.cog;
- });
- // console.log("data", data);
- const processedData = {};
- data.forEach(item => {
- const [key, value] = item.split(":");
- processedData[key] = Number(value) ? Number(value) : 0;
- });
- processedData.content = this.textarea;
- // console.log(processedData);
- let params = {
- cid: this.id,
- s: this.stage,
- t: this.task,
- rate: JSON.stringify(processedData),
- uid: this.stUid
- };
- // return console.log(params);
- this.ajax
- .get(this.$store.state.api + "updateWorksEva", params)
- .then(res => {
- this.$message({
- message: "评价成功",
- type: "success"
- });
- this.$emit("refreshOther", this.toolIndex);
- })
- .catch(err => {
- this.$message.error("评价失败");
- console.error(err);
- });
- },
- // ai评分
- AIsubmit() {
- let tit = this.scoTit;
- tit.forEach((e, index) => {
- if (!e.isai) {
- e.isai = 1;
- }
- });
- let con = JSON.parse(this.scoCon.works);
- this.$emit("updateLoading", {
- val: this.toolIndex,
- val2: this.wIndex,
- val3: true
- });
- let _text = "";
- for (let i = 0; i < tit.length; i++) {
- if (tit[i].isai == 1) {
- _text += `评价名称:${tit[i].value} 评价描述:${tit[i].detail} \n`;
- }
- }
- let laws = "";
- for (let i = 0; i < tit.length; i++) {
- if (tit[i].isai == 1) {
- laws += `评价维度:${tit[i].value} 评价细则:${tit[i].rule} \n`;
- }
- }
- // console.log(_text);
- let msg = `NOTICE
- Role: 你是一个专业的项目式学习导师,你要对学生的评价高度负责。你要根据“六级评价细则”给学生作品评分,并生成需要的JSON数据。
- Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.
- ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
- Instruction: Based on the context, follow "Format example", write content.
- #Context
- ##要求
- 根据<评价细则>和<作业内容>的相关性评价作业,判根据细则评价作业,判断该作业属于六级中的哪个等级。如果作业内容与评价细则无关,则直接评为0星。
-
-
- ##评分资料
- 评价细则:${laws}
- 作业内容:${con.text}
- # Format example
- [{'评价名称':'评价等级0-5(数字)'},{'评价名称':'评价等级0-5(数字)'},{'评价名称':'评价等级0-5(数字)'},{'评价名称':'评价等级0-5(数字)'}]
- `;
- // console.log(msg);
- this.aiGet2(msg);
- },
- // ai打分
- aiGet2(messages, callback) {
- // console.log(this.toolIndex, this.wIndex);
- let _this = this;
- let params = {
- assistant_id: "6063369f-289a-11ef-8bf4-12e77c4cb76b",
- message: [
- {
- type: "text",
- text: messages.replaceAll("\n", " ").replaceAll("*", "")
- }
- ],
- session_name: uuidv4(),
- userId: this.userid,
- file_ids: [],
- model: "gpt-4o-2024-08-06"
- };
- this.ajax
- .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", params)
- .then(response => {
- let data = response.data.FunctionResponse;
- // console.log("data", data);
- if (data.message) {
- let dArray = {};
- try {
- dArray = JSON.parse(
- data.message.replaceAll("```json", "").replaceAll("```", "")
- );
- } catch (error) {
- console.log("error_________________" + error);
- try {
- let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
- let match = data.message.match(regex);
- dArray = JSON.parse(
- match[0]
- .replace(/\n/g, "")
- .replace(/\s{2,}/g, "")
- .replace(/\'/g, '"')
- );
- } catch (error) {
- try {
- dArray = JSON.parse(
- data.message
- .replaceAll("```json", "")
- .replaceAll("# Solution", "")
- .replaceAll("```", "")
- .replace(/\n/g, "")
- .replace(/\s{2,}/g, "")
- .replace(/\'/g, '"')
- );
- } catch (error) {
- console.log("error_________________" + error);
- }
- console.log("error_________________" + error);
- }
- }
- // console.log("dArray3", dArray);
- // _this.submit2(dArray);
- // 提交评分
- // if (!dArray) {
- // _this.$emit("updateLoading", {val:_this.task,val2:_this.wIndex,val3:false});
- // }
- let processedData = {};
- // return console.log(dArray);
- dArray.forEach(function(item) {
- let key = Object.keys(item)[0];
- let value = item[key];
- processedData[key] = value;
- });
- for (const key in processedData) {
- if (!Number.isFinite(processedData[key] * 1)) {
- processedData[key] = 0;
- }
- }
- processedData.content = this.textarea;
- let params = {
- cid: _this.id,
- s: _this.stage,
- t: _this.task,
- rate: JSON.stringify(processedData),
- uid: _this.stUid
- };
- // console.log(params);
- _this.ajax
- .get(_this.$store.state.api + "updateWorksEva", params)
- .then(res => {
- _this.$message({
- message: "评价成功",
- type: "success"
- });
- // console.log(_this.wIndex, _this.task);
- _this.$emit("updateLoading", {
- val: _this.toolIndex,
- val2: _this.wIndex,
- val3: false
- });
- _this.$emit("refreshOther", _this.toolIndex);
- _this.getData();
- // _this.markScoPopover = false;
- // _this.$emit("update:loading", false);
- })
- .catch(err => {
- _this.$message.error("评价失败");
- _this.$emit("updateLoading", {
- val: _this.toolIndex,
- val2: _this.wIndex,
- val3: false
- });
- console.error(err);
- });
- }
- this.$forceUpdate();
- callback ? callback() : "";
- })
- .catch(error => {
- // _this.markScoPopover = false;
- // _this.$emit("update:loading", false);
- _this.$emit("updateLoading", {
- val: _this.toolIndex,
- val2: _this.wIndex,
- val3: false
- });
- _this.$message.error("评价失败");
- // _this.loading = false
- console.log(error);
- });
- },
- // ai循环评分
- async aiupdetaSco(messages, uid, stage, task,_fileid, callback) {
- let _this = this;
- let params = {
- assistant_id: "6063369f-289a-11ef-8bf4-12e77c4cb76b",
- message: [
- {
- type: "text",
- text: messages.replaceAll("\n", " ").replaceAll("*", "")
- }
- ],
- session_name: uuidv4(),
- userId: this.userid,
- file_ids: _fileid ? [_fileid] : [],
- model: "gpt-4o-2024-08-06"
- };
- return new Promise(resolve => {
- this.ajax
- .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", params)
- .then(response => {
- let data = response.data.FunctionResponse;
- // console.log(data);
- if (data.message) {
- let dArray = {};
- try {
- dArray = JSON.parse(
- data.message.replaceAll("```json", "").replaceAll("```", "")
- );
- } catch (error) {
- console.log("error_________________" + error);
- try {
- let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
- let match = data.message.match(regex);
- // console.log("dArray2", match);
- dArray = JSON.parse(
- match[0]
- .replace(/\n/g, "")
- .replace(/\s{2,}/g, "")
- .replace(/\'/g, '"')
- );
- // dArray = data.choices[0].message.content
- } catch (error) {
- try {
- dArray = JSON.parse(
- data.message
- .replaceAll("```json", "")
- .replaceAll("# Solution", "")
- .replaceAll("```", "")
- .replace(/\n/g, "")
- .replace(/\s{2,}/g, "")
- .replace(/\'/g, '"')
- );
- } catch (error) {
- console.log("error_________________" + error);
- }
- console.log("error_________________" + error);
- }
- }
- let processedData = {};
- dArray.forEach(function(item) {
- let key = Object.keys(item)[0];
- let value = item[key];
- processedData[key] = value;
- });
- 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) {
- IsAIsuccess++
- }
- continue;
- }
- }
- continue;
- }
- if (IsAIsuccess != this.scoTitList.length) {
- _this.$message.error("评价失败");
- resolve(1);
- return
- }
- for (const key in processedData) {
- // if (!Number.isFinite(processedData[key] * 1)) {
- // processedData[key] = 0;
- // }
- if (key == "评语") {
- processedData.content = processedData[key];
- }
- }
- delete processedData["评语"];
- // processedData.content = this.textarea;
- let params = {
- cid: _this.id,
- s: stage,
- t: task,
- rate: JSON.stringify(processedData),
- uid: uid
- };
- // console.log("params", params);
- _this.ajax
- .get(_this.$store.state.api + "updateWorksEva", params)
- .then(res => {
- resolve(1);
- _this.$message({
- message: "评价成功",
- type: "success"
- });
- })
- .catch(err => {
- resolve(1);
- _this.$message.error("评价失败");
- console.error(err);
- });
- }
- callback ? callback() : "";
- })
- .catch(error => {
- resolve(1);
- _this.$message.error("评价失败");
- // _this.loading = false
- console.log(error);
- });
- });
- },
-
- }
- };
- </script>
- <style scoped>
- .scoreTit {
- font-size: 16px;
- font-weight: 600;
- display: flex;
- justify-content: space-between;
- box-sizing: border-box;
- }
- .allD {
- margin: 5px 0;
- display: flex;
- width: 100%;
- overflow: auto;
- max-height: 100px;
- min-height: 60px;
- }
- .scoreStar {
- background-color: #f3f7fd;
- padding: 10px;
- height: 100%;
- flex: 1;
- }
- .scoreStar > div:last-child > .scoreStarBack {
- margin-bottom: 0;
- }
- .scoreStarBack {
- flex: 1;
- display: flex;
- justify-content: space-between;
- margin-bottom: 10px;
- }
- .rootImg {
- padding-top: 1px;
- box-sizing: border-box;
- display: block;
- }
- .scoreStarBack2 {
- padding: 10px 0;
- margin-right: 2px;
- }
- .AreaCss {
- margin-bottom: 5px;
- -webkit-line-clamp: 2;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- overflow: hidden;
- text-overflow: ellipsis;
- /* margin-left: 20px; */
- }
- .AreaCss >>> .el-textarea__inner {
- min-height: 60px;
- max-height: 150px;
- padding-bottom: 20px;
- }
- .briefTit {
- width: 150px;
- text-overflow: ellipsis;
- overflow: hidden;
- white-space: nowrap;
- }
- </style>
|