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

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

Loading…
Cancel
Save