yujialong 8 months ago
parent f98551590c
commit 798b02e176
  1. 10
      src/components/TestPanel.vue
  2. 29
      src/components/codemirror.vue

@ -675,6 +675,7 @@ export default {
if (result) { if (result) {
hasCache = 1 hasCache = 1
if (newJudgmentId === '') newJudgmentId = i if (newJudgmentId === '') newJudgmentId = i
e.finalCode = result.code
e.code = result.code e.code = result.code
e.codeId = result.id e.codeId = result.id
e.answer = result.runResult e.answer = result.runResult
@ -704,6 +705,7 @@ export default {
this.points.map(e => { this.points.map(e => {
const item = points.find(n => n.judgmentId === e.judgmentId) const item = points.find(n => n.judgmentId === e.judgmentId)
if (item) { if (item) {
item.finalCode && this.$set(e, 'finalCode', item.finalCode)
item.code && this.$set(e, 'code', item.code) item.code && this.$set(e, 'code', item.code)
item.codeId && this.$set(e, 'codeId', item.codeId) item.codeId && this.$set(e, 'codeId', item.codeId)
item.answer && this.$set(e, 'answer', item.answer) item.answer && this.$set(e, 'answer', item.answer)
@ -717,6 +719,7 @@ export default {
} else { } else {
this.points.map(e => { this.points.map(e => {
const item = points.find(n => n.judgmentId === e.judgmentId) const item = points.find(n => n.judgmentId === e.judgmentId)
item.finalCode && this.$set(e, 'finalCode', item.finalCode)
item.code && this.$set(e, 'code', item.code) item.code && this.$set(e, 'code', item.code)
item.codeId && this.$set(e, 'codeId', item.codeId) item.codeId && this.$set(e, 'codeId', item.codeId)
item.answer && this.$set(e, 'answer', item.answer) item.answer && this.$set(e, 'answer', item.answer)
@ -892,6 +895,8 @@ export default {
if (e.code || e.codeResult) { if (e.code || e.codeResult) {
this.runCodeType = 'vscodeRunCode' this.runCodeType = 'vscodeRunCode'
await this.$post(this.api.runPythonCode, { await this.$post(this.api.runPythonCode, {
assessmentId: this.assessmentId,
competitionId: this.competitionId,
code: e.code, code: e.code,
bcId: e.judgmentId, bcId: e.judgmentId,
cid: this.courseId, cid: this.courseId,
@ -908,6 +913,8 @@ export default {
if (!pointList.find(e => e.codeId)) { if (!pointList.find(e => e.codeId)) {
this.runCodeType = 'emptyRunCode' this.runCodeType = 'emptyRunCode'
this.$post(this.api.runPythonCode, { this.$post(this.api.runPythonCode, {
assessmentId: this.assessmentId,
competitionId: this.competitionId,
code: '', code: '',
bcId: pointList[0].judgmentId, bcId: pointList[0].judgmentId,
cid: this.courseId, cid: this.courseId,
@ -1263,8 +1270,9 @@ export default {
// //
heartbeatDetection () { heartbeatDetection () {
setInterval(async () => { setInterval(async () => {
this.client.send('ping')
await this.$get(this.api.heartbeatDetection) await this.$get(this.api.heartbeatDetection)
}, 58 * 1000) }, 56 * 1000)
}, },
// //
getUserDetail () { getUserDetail () {

@ -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,

Loading…
Cancel
Save