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