代码里有图片的情况下,图片名加上时间戳

ui
jialong.yu 3 years ago
parent bf85c63e2f
commit 0e57c10c13
  1. 10
      src/components/TestPanel.vue
  2. 19
      src/components/codemirror.vue
  3. 5
      src/views/Home.vue

@ -233,7 +233,7 @@ export default {
this.experimentHint = project.experimentHint this.experimentHint = project.experimentHint
// this.actEndTime = project[0].endTime // this.actEndTime = project[0].endTime
this.hintOpen = !res.projectManage.hintOpen // 01 this.hintOpen = !res.projectManage.hintOpen // 01
this.$emit("tell", projectId, this.projectPermissions, this.points) this.$emit('tell', projectId, this.points)
if (this.projectPermissions == 1) { if (this.projectPermissions == 1) {
this.text = "剩余" this.text = "剩余"
var interval = setInterval(() => { var interval = setInterval(() => {
@ -272,7 +272,7 @@ export default {
} else { } else {
this.text = "已用"; this.text = "已用";
// //
this.createTime = new Date().getTime(); this.createTime = new Date().getTime()
// //
if (this.autoStart) { if (this.autoStart) {
this.startCount() this.startCount()
@ -307,7 +307,7 @@ export default {
const item = this.points.find(e => e.judgmentId === judgmentId) const item = this.points.find(e => e.judgmentId === judgmentId)
if (item) item.code = code if (item) item.code = code
// debugger // debugger
this.$emit("tell", this.projectId, this.projectPermissions, this.points) this.$emit('tell', projectId, this.points)
this.$emit('recoveryCode', judgmentId + '') this.$emit('recoveryCode', judgmentId + '')
}).catch(() => { }).catch(() => {
localStorage.removeItem('codeCache') localStorage.removeItem('codeCache')
@ -347,6 +347,8 @@ export default {
// //
submit() { submit() {
const pointList = this.$parent.workbench const pointList = this.$parent.workbench
// debugger
console.log(pointList)
if(!pointList.find(e => e.codeId)) return this.$message.error('请先完成实验') if(!pointList.find(e => e.codeId)) return this.$message.error('请先完成实验')
this.$confirm("此操作将视为结束考试, 是否继续?", "提示", { this.$confirm("此操作将视为结束考试, 是否继续?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
@ -367,6 +369,7 @@ export default {
e.codeId && attributesReqList.push({ e.codeId && attributesReqList.push({
codeId: e.codeId, codeId: e.codeId,
bcId: e.judgmentId, bcId: e.judgmentId,
score: e.score,
isSubmit: 0 isSubmit: 0
}) })
}) })
@ -381,6 +384,7 @@ export default {
projectId, projectId,
projectName, projectName,
assessmentId: this.assessmentId ? this.assessmentId : '', assessmentId: this.assessmentId ? this.assessmentId : '',
totalScore: 100,
systemId: 1, systemId: 1,
purpose: this.experimentTarget, purpose: this.experimentTarget,
attributesReqList attributesReqList

@ -235,7 +235,8 @@ export default {
}, },
runCode(isWhile) { // isWhiletruewhile runCode(isWhile) { // isWhiletruewhile
if (!this.isSubmit) { if (!this.isSubmit) {
if (!this.codeVal) { let code = this.codeVal
if (!code) {
this.$message({ this.$message({
message: "警告哦,内容为空不可运行", message: "警告哦,内容为空不可运行",
type: "warning" type: "warning"
@ -244,7 +245,7 @@ export default {
let inputTextReg = this.inputTextReg let inputTextReg = this.inputTextReg
let inputFuncReg = /input\(['|"]/g let inputFuncReg = /input\(['|"]/g
// input // input
if (inputTextReg.test(this.codeVal)) { if (inputTextReg.test(code)) {
let sourceCode = this.codeVal let sourceCode = this.codeVal
sourceCode = sourceCode.replace(inputTextReg,val => { sourceCode = sourceCode.replace(inputTextReg,val => {
return val.replace(/\\n/g,"") return val.replace(/\\n/g,"")
@ -272,7 +273,6 @@ export default {
}else{ }else{
this.runResult = modify this.runResult = modify
} }
this.errLine = parseInt(modify.substring(modify.indexOf("line") + 4, modify.length)) this.errLine = parseInt(modify.substring(modify.indexOf("line") + 4, modify.length))
this.isError = res.message.isError this.isError = res.message.isError
}else if(result.includes('validing:')){ }else if(result.includes('validing:')){
@ -284,9 +284,13 @@ export default {
this.loadIns = Loading.service({ this.loadIns = Loading.service({
background: 'transparent' background: 'transparent'
}) })
// savefig(python),savefig
code = code.replace(/\.savefig\(([\u4e00-\u9fa5\w]*?['"])/mg, str => {
return str + Date.now()
})
// Python // Python
this.$post(this.api.runPythonCode, { this.$post(this.api.runPythonCode, {
code: this.codeVal, code,
bcId: this.workbench1, bcId: this.workbench1,
cid: this.courseId, cid: this.courseId,
projectId: this.projectId projectId: this.projectId
@ -296,10 +300,12 @@ export default {
const result = data.runResult const result = data.runResult
this.loadIns.close() this.loadIns.close()
this.picSrc = '' this.picSrc = ''
this.$emit('update:codeId', res.codeId)
if(photo){ if(photo){
this.isError = data.retResult this.isError = data.retResult
this.runResult = '' const text = result.replace(photo, '')
this.picSrc = `${photo}?id=${new Date().getTime()}` this.runResult = text
this.picSrc = photo
}else{ }else{
// //
// 7 // 7
@ -319,7 +325,6 @@ export default {
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))
this.$emit('update:codeId', res.codeId)
} }
} }
}).catch(res => { }).catch(res => {

@ -133,10 +133,9 @@ export default {
this.$refs.mainindex.getClearTime(); this.$refs.mainindex.getClearTime();
}, },
// id // id
getQueryIndex(projectId, projectPermissions, workBench) { getQueryIndex(projectId, workbench) {
this.projectId = projectId this.projectId = projectId
this.projectPermissions = projectPermissions this.workbench = workbench
this.workbench = workBench
}, },
} }
}; };

Loading…
Cancel
Save