|
|
@ -329,8 +329,8 @@ export default { |
|
|
|
data () { |
|
|
|
data () { |
|
|
|
return { |
|
|
|
return { |
|
|
|
token: Cookie.get('admin-token'), |
|
|
|
token: Cookie.get('admin-token'), |
|
|
|
assessmentId: Cookie.get('admin-assessmentId'), // 考核id |
|
|
|
assessmentId: Cookie.get('admin-assessmentId') || '', // 考核id |
|
|
|
competitionId: Cookie.get('admin-competitionId'), |
|
|
|
competitionId: Cookie.get('admin-competitionId') || '', |
|
|
|
fromManager: Cookie.get('admin-fromManager'), // 是否是从教师端进入 |
|
|
|
fromManager: Cookie.get('admin-fromManager'), // 是否是从教师端进入 |
|
|
|
courseId: Cookie.get('admin-courseId'), // 课程id |
|
|
|
courseId: Cookie.get('admin-courseId'), // 课程id |
|
|
|
mallId: Cookie.get('admin-mallId'), |
|
|
|
mallId: Cookie.get('admin-mallId'), |
|
|
@ -435,6 +435,7 @@ export default { |
|
|
|
pid: '', |
|
|
|
pid: '', |
|
|
|
cancelRunTimer: null, |
|
|
|
cancelRunTimer: null, |
|
|
|
runCodeConfirm: null, |
|
|
|
runCodeConfirm: null, |
|
|
|
|
|
|
|
isStopRunCode: 0, |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
components: { |
|
|
|
components: { |
|
|
@ -586,24 +587,16 @@ export default { |
|
|
|
newmain.$emit('changeRunStatus', '') |
|
|
|
newmain.$emit('changeRunStatus', '') |
|
|
|
this.runCodeType = fn |
|
|
|
this.runCodeType = fn |
|
|
|
clearTimeout(this.cancelRunTimer) |
|
|
|
clearTimeout(this.cancelRunTimer) |
|
|
|
// this.cancelRunTimer = setTimeout(() => { |
|
|
|
|
|
|
|
// this.runCodeConfirm = this.$confirm('当前代码已运行超过5秒钟,是否终止运行?', '提示', { |
|
|
|
|
|
|
|
// type: 'warning', |
|
|
|
|
|
|
|
// closeOnClickModal: false, |
|
|
|
|
|
|
|
// showClose: false |
|
|
|
|
|
|
|
// }).then(async () => { |
|
|
|
|
|
|
|
// if (this.pid) await this.$post(`${this.api.endRunningProcess}?pid=${this.pid}`) |
|
|
|
|
|
|
|
// if (this.loadIns) this.loadIns.close() |
|
|
|
|
|
|
|
// }).catch(() => { }) |
|
|
|
|
|
|
|
// }, 5000) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 终止运行 |
|
|
|
// 终止运行 |
|
|
|
async stopRunCode () { |
|
|
|
async stopRunCode () { |
|
|
|
|
|
|
|
this.isStopRunCode = 1 |
|
|
|
if (this.pid) await this.$post(`${this.api.endRunningProcess}?pid=${this.pid}`) |
|
|
|
if (this.pid) await this.$post(`${this.api.endRunningProcess}?pid=${this.pid}`) |
|
|
|
this.pid = '' |
|
|
|
this.pid = '' |
|
|
|
if (this.loadIns) this.loadIns.close() |
|
|
|
if (this.loadIns) this.loadIns.close() |
|
|
|
}, |
|
|
|
}, |
|
|
|
inputRunCode (data) { |
|
|
|
inputRunCode (data) { |
|
|
|
|
|
|
|
if (this.isStopRunCode) return false |
|
|
|
const result = data.runResult |
|
|
|
const result = data.runResult |
|
|
|
if (result.includes('File ')) { |
|
|
|
if (result.includes('File ')) { |
|
|
|
this.runResult = result |
|
|
|
this.runResult = result |
|
|
@ -647,8 +640,11 @@ export default { |
|
|
|
this.requestList.map(n => n('interrupt')) |
|
|
|
this.requestList.map(n => n('interrupt')) |
|
|
|
}, 1000) |
|
|
|
}, 1000) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.isStopRunCode = 0 |
|
|
|
this.handleRunCodeCb('inputRunCode') |
|
|
|
this.handleRunCodeCb('inputRunCode') |
|
|
|
axios.post(config.host + this.api.runPythonCode, { |
|
|
|
axios.post(config.host + this.api.runPythonCode, { |
|
|
|
|
|
|
|
assessmentId: this.assessmentId, |
|
|
|
|
|
|
|
competitionId: this.competitionId, |
|
|
|
code: this.sourceCode, |
|
|
|
code: this.sourceCode, |
|
|
|
bcId: this.judgmentId, |
|
|
|
bcId: this.judgmentId, |
|
|
|
cid: this.courseId, |
|
|
|
cid: this.courseId, |
|
|
@ -681,6 +677,7 @@ export default { |
|
|
|
if (this.runCodeType && this[this.runCodeType]) this[this.runCodeType](data) |
|
|
|
if (this.runCodeType && this[this.runCodeType]) this[this.runCodeType](data) |
|
|
|
}, |
|
|
|
}, |
|
|
|
runCodeCb1 (res) { |
|
|
|
runCodeCb1 (res) { |
|
|
|
|
|
|
|
if (this.isStopRunCode) return false |
|
|
|
const result = data.runResult |
|
|
|
const result = data.runResult |
|
|
|
if (result.includes('File ')) { |
|
|
|
if (result.includes('File ')) { |
|
|
|
if (isWhile) { |
|
|
|
if (isWhile) { |
|
|
@ -699,7 +696,7 @@ export default { |
|
|
|
this.$emit('update:retResult', data.retResult) // 更新返回结果 |
|
|
|
this.$emit('update:retResult', data.retResult) // 更新返回结果 |
|
|
|
}, |
|
|
|
}, |
|
|
|
runCodeCb2 (data) { |
|
|
|
runCodeCb2 (data) { |
|
|
|
if (data.sort != this.index) return false |
|
|
|
if (this.isStopRunCode || data.sort != this.index) return false |
|
|
|
// 正常返回结果 |
|
|
|
// 正常返回结果 |
|
|
|
if (data) { |
|
|
|
if (data) { |
|
|
|
const photo = data.photoUrl |
|
|
|
const photo = data.photoUrl |
|
|
@ -774,8 +771,11 @@ export default { |
|
|
|
this.sourceCode = code |
|
|
|
this.sourceCode = code |
|
|
|
|
|
|
|
|
|
|
|
if (!isWhile) this.runResult = '' |
|
|
|
if (!isWhile) this.runResult = '' |
|
|
|
|
|
|
|
this.isStopRunCode = 0 |
|
|
|
this.handleRunCodeCb('runCodeCb1') |
|
|
|
this.handleRunCodeCb('runCodeCb1') |
|
|
|
this.$post(this.api.runPythonCode, { |
|
|
|
this.$post(this.api.runPythonCode, { |
|
|
|
|
|
|
|
assessmentId: this.assessmentId, |
|
|
|
|
|
|
|
competitionId: this.competitionId, |
|
|
|
code, |
|
|
|
code, |
|
|
|
bcId, |
|
|
|
bcId, |
|
|
|
cid, |
|
|
|
cid, |
|
|
@ -799,8 +799,11 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
// 把代码传给后端,在后端运行Python代码 |
|
|
|
// 把代码传给后端,在后端运行Python代码 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.isStopRunCode = 0 |
|
|
|
this.handleRunCodeCb('runCodeCb2') |
|
|
|
this.handleRunCodeCb('runCodeCb2') |
|
|
|
this.$post(this.api.runPythonCode, { |
|
|
|
this.$post(this.api.runPythonCode, { |
|
|
|
|
|
|
|
assessmentId: this.assessmentId, |
|
|
|
|
|
|
|
competitionId: this.competitionId, |
|
|
|
code, |
|
|
|
code, |
|
|
|
bcId, |
|
|
|
bcId, |
|
|
|
cid, |
|
|
|
cid, |
|
|
|