diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 0ac35ac..01f1246 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -233,7 +233,7 @@ export default { this.experimentHint = project.experimentHint // this.actEndTime = project[0].endTime this.hintOpen = !res.projectManage.hintOpen // 0显示,1不显示 - this.$emit("tell", projectId, this.projectPermissions, this.points) + this.$emit('tell', projectId, this.points) if (this.projectPermissions == 1) { this.text = "剩余" var interval = setInterval(() => { @@ -272,7 +272,7 @@ export default { } else { this.text = "已用"; // 获取当前时间 - this.createTime = new Date().getTime(); + this.createTime = new Date().getTime() //自动开始 if (this.autoStart) { this.startCount() @@ -307,7 +307,7 @@ export default { const item = this.points.find(e => e.judgmentId === judgmentId) if (item) item.code = code // debugger - this.$emit("tell", this.projectId, this.projectPermissions, this.points) + this.$emit('tell', projectId, this.points) this.$emit('recoveryCode', judgmentId + '') }).catch(() => { localStorage.removeItem('codeCache') @@ -347,6 +347,8 @@ export default { // 提交 submit() { const pointList = this.$parent.workbench + // debugger + console.log(pointList) if(!pointList.find(e => e.codeId)) return this.$message.error('请先完成实验') this.$confirm("此操作将视为结束考试, 是否继续?", "提示", { confirmButtonText: "确定", @@ -367,6 +369,7 @@ export default { e.codeId && attributesReqList.push({ codeId: e.codeId, bcId: e.judgmentId, + score: e.score, isSubmit: 0 }) }) @@ -381,6 +384,7 @@ export default { projectId, projectName, assessmentId: this.assessmentId ? this.assessmentId : '', + totalScore: 100, systemId: 1, purpose: this.experimentTarget, attributesReqList diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index f189cff..a704528 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -235,7 +235,8 @@ export default { }, runCode(isWhile) { // isWhile为true表示代码里有while循环,右边的运行结果需要拼接展示,而不是直接覆盖 if (!this.isSubmit) { - if (!this.codeVal) { + let code = this.codeVal + if (!code) { this.$message({ message: "警告哦,内容为空不可运行", type: "warning" @@ -244,7 +245,7 @@ export default { let inputTextReg = this.inputTextReg let inputFuncReg = /input\(['|"]/g // 该正则是验证代码里是否有input,如果有,就要另外做处理,而不是直接传给后端执行 - if (inputTextReg.test(this.codeVal)) { + if (inputTextReg.test(code)) { let sourceCode = this.codeVal sourceCode = sourceCode.replace(inputTextReg,val => { return val.replace(/\\n/g,"") @@ -272,7 +273,6 @@ export default { }else{ this.runResult = modify } - this.errLine = parseInt(modify.substring(modify.indexOf("line") + 4, modify.length)) this.isError = res.message.isError }else if(result.includes('validing:')){ @@ -284,9 +284,13 @@ export default { this.loadIns = Loading.service({ background: 'transparent' }) + // 如果代码有savefig(python里的保存图片的方法),则要把savefig里的图片名字加上个时间戳,防止后台保存图片到服务器的时候图片名字重复导致覆盖 + code = code.replace(/\.savefig\(([\u4e00-\u9fa5\w]*?['"])/mg, str => { + return str + Date.now() + }) // 把代码传给后端,在后端运行Python代码 this.$post(this.api.runPythonCode, { - code: this.codeVal, + code, bcId: this.workbench1, cid: this.courseId, projectId: this.projectId @@ -296,10 +300,12 @@ export default { const result = data.runResult this.loadIns.close() this.picSrc = '' + this.$emit('update:codeId', res.codeId) if(photo){ this.isError = data.retResult - this.runResult = '' - this.picSrc = `${photo}?id=${new Date().getTime()}` + const text = result.replace(photo, '') + this.runResult = text + this.picSrc = photo }else{ // 这段是为要下载图片的项目案例写的,后端会返回图片名称的数组,前端负责循环这个数组,然后下载下来 // 只有该系统有这段代码,因为其他7个系统没有下载图片的项目,后续如果加了,直接把这段代码复制过去即可 @@ -319,7 +325,6 @@ export default { this.isError = data.retResult this.runResult = result this.errLine = parseInt(result.substring(result.indexOf("line") + 4, result.length)) - this.$emit('update:codeId', res.codeId) } } }).catch(res => { diff --git a/src/views/Home.vue b/src/views/Home.vue index fcbc5a2..c6ce0cc 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -133,10 +133,9 @@ export default { this.$refs.mainindex.getClearTime(); }, // 赋值项目id、权限、项目列表 - getQueryIndex(projectId, projectPermissions, workBench) { + getQueryIndex(projectId, workbench) { this.projectId = projectId - this.projectPermissions = projectPermissions - this.workbench = workBench + this.workbench = workbench }, } };