提交联调

ui
jialong.yu 3 years ago
parent 85994d8519
commit aa01c8e99a
  1. 67
      src/components/TestPanel.vue
  2. 61
      src/components/codemirror.vue
  3. 2
      src/config/index.js
  4. 18
      src/util/index.js
  5. 4
      src/views/Home.vue

@ -73,21 +73,25 @@
<el-table :data="taskList" :stripe="true" height="405"> <el-table :data="taskList" :stripe="true" height="405">
<el-table-column type="index"></el-table-column> <el-table-column type="index"></el-table-column>
<el-table-column prop="name" label="判分标准" align="center"></el-table-column> <el-table-column prop="name" label="判分标准" align="center"></el-table-column>
<el-table-column prop="right" label="完成结果" align="center"> <el-table-column label="完成结果" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="isSubmit">
<i <i
v-if="scope.row.right=='0'" v-if="scope.row.finishedResult"
class="el-icon-check" class="el-icon-check right"
style="color:green;font-size:20px"
></i> ></i>
<i <i
v-else-if="scope.row.right=='-1'" v-else
class="el-icon-close" class="el-icon-close wrong"
style="color:red;font-size:20px"
></i> ></i>
</template> </template>
</template>
</el-table-column>
<el-table-column prop="score" label="得分" align="center">
<template slot-scope="scope">
<template v-if="isSubmit">{{ scope.row.score }}</template>
</template>
</el-table-column> </el-table-column>
<el-table-column prop="score1" label="得分" align="center"></el-table-column>
</el-table> </el-table>
</el-card> </el-card>
</el-col> </el-col>
@ -302,14 +306,15 @@ export default {
localStorage.removeItem('codeCache') localStorage.removeItem('codeCache')
this.isSubmit = false this.isSubmit = false
newmain.$emit('isSubmit', this.isSubmit) newmain.$emit('isSubmit', this.isSubmit)
const points = this.points
points.map(e => {
e.code = ''
e.codeId = ''
e.answer = ''
})
this.$emit('tell', this.projectId, points)
this.$emit('recoveryCode') this.$emit('recoveryCode')
this.startCount() this.startCount()
// let taskList = this.taskList
// taskList.map(n => {
// delete n.score
// delete n.right
// })
// this.taskList = JSON.parse(JSON.stringify(taskList))
}, },
// //
submit() { submit() {
@ -358,23 +363,20 @@ export default {
localStorage.removeItem('codeCache') localStorage.removeItem('codeCache')
this.isSubmit = true this.isSubmit = true
newmain.$emit('isSubmit', this.isSubmit) newmain.$emit('isSubmit', this.isSubmit)
let list = res.message let list = res.retInfo
let result = []
let taskList = this.taskList let taskList = this.taskList
result.map(n => { var score = 0
if(taskList.find(e => e.judgmentPointsId == n.judgmentPointsId).isError){ taskList.map(e => {
n.score = 0 let item = list.find(n => n.judgmentPointsId === e.judgmentId)
n.right = -1 if (item) {
e.score = item.score
e.finishedResult = item.finishedResult
} else {
e.score = 0
} }
score += e.score
}) })
this.taskList = result this.grade = util.handleZero(score)
//
var s = 0;
this.taskList.forEach(element => {
// this.test = element.score;
// s += this.test;
this.grade = s;
});
}) })
.catch(err => {}) .catch(err => {})
}).catch(() => {}) }).catch(() => {})
@ -441,7 +443,6 @@ export default {
cursor: pointer; cursor: pointer;
display: block !important; display: block !important;
} }
//el-main
.el-main { .el-main {
width: 60%; width: 60%;
background-color: #fff; background-color: #fff;
@ -689,4 +690,12 @@ export default {
border-radius: 0; border-radius: 0;
background: #dddddd; background: #dddddd;
} }
.right {
color: #00af00;
font-size: 20px;
}
.wrong {
color: #f00;
font-size: 20px;
}
</style> </style>

@ -161,24 +161,12 @@ export default {
ready() { ready() {
this.$refs.myCmGenerate.codemirror.setSize("auto", "calc(100vh - 149px)"); this.$refs.myCmGenerate.codemirror.setSize("auto", "calc(100vh - 149px)");
}, },
// /**
downloadFile(fileName,url) { * python代码里如果有input函数的话是做了单独的处理的原理是先把所有input函数都替换成exit函数再在exit函数里加上特定标识再通过接口传给后端去执行
var x = new XMLHttpRequest() * 因为exit函数是跟input有类似的效果就是都会产生阻塞所以python引擎一旦遇到exit进程就会被停止然后返回exit函数里面的值而这个值就是上面说的特定标识加上原本这个input函数里的值
x.open("GET", url, true) * 然后就可以通过这个返回的值来提示给用户让用户继续输入
x.responseType = 'blob' * 下面这个函数就是递归执行这个input输入过程的函数
x.onload=function(e) { */
var url = window.URL.createObjectURL(x.response)
var a = document.createElement('a')
a.href = url
a.download = fileName
a.click()
}
x.send()
},
// pythoninputinputexitexit
// exitinputpythonexitexitinput
//
// input
confirmInput(msg){ confirmInput(msg){
let receiveResult = msg.replace('validing:','') let receiveResult = msg.replace('validing:','')
this.runResult += receiveResult this.runResult += receiveResult
@ -299,37 +287,36 @@ export default {
const data = res.code const data = res.code
const photo = data.photoUrl const photo = data.photoUrl
const result = data.runResult const result = data.runResult
this.$emit('cache') this.$emit('cache') //
this.loadIns.close() this.loadIns.close()
this.picSrc = '' this.picSrc = ''
this.$emit('update:codeId', res.codeId) this.$emit('update:codeId', res.codeId) // coddeId
this.$emit('update:answer', result) this.$emit('update:answer', result) //
if(photo){ let imgList = ''
this.isError = '' try {
const text = result.replace(photo, '') imgList = eval(result)
} catch (error) {}
//
if (photo) {
this.isError = '' //
const text = result.replace(photo, '') //
this.runResult = text this.runResult = text
this.picSrc = photo this.picSrc = photo
}else{ } else if (imgList instanceof Array && imgList.length && (imgList[0].includes('.jpg') || imgList[0].includes('.png') || imgList[0].includes('img'))) {
// /**
// 7 * 这段是为要下载图片的项目案例写的后端会返回图片名称的数组前端负责循环这个数组然后下载下来
if(0){ * 只有该系统有这段代码因为其他7个系统没有下载图片的项目后续如果加了直接把这段代码复制过去即可
if(result instanceof Array && result.length && (result[0].includes('.jpg') || result[0].includes('.png') || result[0].includes('.gif'))){ */
result.map((n,i) => { imgList.map((n,i) => {
this.downloadFile(`${i+1}.jpg`,n) util.downloadFile(`${i+1}.jpg`,n)
}) })
this.isError = 0 this.isError = 0
this.runResult = '下载完成' this.runResult = '下载完成'
}else{
this.isError = 0
this.runResult = data.runResult
this.errLine = parseInt(result.substring(modify.indexOf("line") + 4, modify.length))
}
} else { } else {
this.isError = data.retResult this.isError = data.retResult
this.runResult = result this.runResult = result
this.errLine = parseInt(result.substring(result.indexOf("line") + 4, result.length)) this.errLine = parseInt(result.substring(result.indexOf("line") + 4, result.length))
} }
}
}).catch(res => { }).catch(res => {
res.status == 500 && this.$message.error('检测到代码里有非法代码,请检查是否有调用系统命令。') res.status == 500 && this.$message.error('检测到代码里有非法代码,请检查是否有调用系统命令。')
this.loadIns.close() this.loadIns.close()

@ -7,7 +7,7 @@ if(isHh) {
host = "http://10.196.131.73/"; host = "http://10.196.131.73/";
} else if(isBeta) { } else if(isBeta) {
host = "http://39.108.250.202:9000/"; host = "http://39.108.250.202:9000/";
host = "http://192.168.31.151:9000/"; // host = "http://192.168.31.151:9000/";
} else if(isPro) { } else if(isPro) {
host = "http://www.occupationlab.com/"; host = "http://www.occupationlab.com/";
} else { } else {

@ -38,5 +38,23 @@ export default {
} }
} }
return fmt return fmt
},
// 下载文件
downloadFile(fileName,url) {
var x = new XMLHttpRequest()
x.open("GET", url, true)
x.responseType = 'blob'
x.onload=function(e) {
var url = window.URL.createObjectURL(x.response)
var a = document.createElement('a')
a.href = url
a.download = fileName
a.click()
}
x.send()
},
// 小于0前面加上0
handleZero (num) {
return num < 10 ? '0' + num : num
} }
} }

@ -74,7 +74,7 @@ export default {
} }
}, },
methods: { methods: {
// //
leavePage(){ leavePage(){
const list = this.workbench const list = this.workbench
if(!this.$refs.mainindex.isSubmit && list.length && list.some(e => e.code)){ if(!this.$refs.mainindex.isSubmit && list.length && list.some(e => e.code)){
@ -82,7 +82,7 @@ export default {
projectId: this.projectId, projectId: this.projectId,
judgmentId: list[Number(this.curTab)].judgmentId judgmentId: list[Number(this.curTab)].judgmentId
} }
localStorage.setItem('codeCache', JSON.stringify(cache)) localStorage.setItem('codeCache', JSON.stringify(cache)) // ididid
list.map(e => { list.map(e => {
if (e.code) { if (e.code) {
let data = { let data = {

Loading…
Cancel
Save