diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 9223350..1ee741b 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -137,6 +137,7 @@ import util from '@/util' export default { data() { return { + systemId: util.getCookie('systemId'), classId: util.getCookie('classId'), className: util.getCookie('className') ? decodeURI(util.getCookie('className')) : '', courseId: util.getCookie('courseId'), @@ -190,7 +191,7 @@ export default { // 获取项目列表 getList(){ let data = { - systemId: 1, + systemId: this.systemId, cId: this.courseId, // 课程id permissions: this.projectPermissions // 练习/考核 } @@ -221,6 +222,7 @@ export default { points.map(e => { e.code = '' // 后端返回的字段没有code,要手动加上以存储运行的代码 e.codeId = '' // 代码通过接口传给后端运行后,接口会返回一个codeId,提交的时候需要传这个codeId + e.answer = '' // 代码运行结果 }) this.points = points this.taskList = points // 实验任务 @@ -267,7 +269,7 @@ export default { const item = points.find(e => e.judgmentId === judgmentId) if (item) item.code = code this.$emit('tell', projectId, points) - this.$emit('recoveryCode', points.findIndex(e => e.judgmentId === judgmentId) + '') + this.$emit('recoveryCode', points.findIndex(e => e.judgmentId === judgmentId) + '') // 切换为缓存的判分点,tab索引值要为字符串 }).catch(res => {}) } else { const item = this.points.find(e => e.judgmentId === judgmentId) @@ -290,9 +292,8 @@ export default { this.isSubmit = false this.countVal = 0 this.grade = '00' - // 切换实训项目-标签页回到第一个位置 - this.$emit('recoveryCode') - newmain.$emit('isSubmit', this.isSubmit) + this.$emit('recoveryCode') // 切换实训项目后回到第一个判分点 + newmain.$emit('isSubmit', this.isSubmit) // 选择项目后把提交状态重置为未提交 }, //重新开始 reload() { @@ -330,11 +331,11 @@ export default { // 判分点参数 const attributesReqList = [] pointList.map(e => { - e.codeId && attributesReqList.push({ + attributesReqList.push({ codeId: e.codeId, bcId: e.judgmentId, - score: e.score, - isSubmit: 0 + isSubmit: e.codeId ? 1 : 0, + answer: e.answer }) }) const data = { diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index 6acd19e..2ac3019 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -233,6 +233,7 @@ export default { }).catch(err => {}) }, + // 运行代码 runCode(isWhile) { // isWhile为true表示代码里有while循环,右边的运行结果需要拼接展示,而不是直接覆盖 if (!this.isSubmit) { let code = this.codeVal @@ -298,9 +299,11 @@ export default { const data = res.code const photo = data.photoUrl const result = data.runResult + this.$emit('cache') this.loadIns.close() this.picSrc = '' this.$emit('update:codeId', res.codeId) + this.$emit('update:answer', result) if(photo){ this.isError = '' const text = result.replace(photo, '') diff --git a/src/config/index.js b/src/config/index.js index 75e589d..becd3f1 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -7,7 +7,7 @@ if(isHh) { host = "http://10.196.131.73/"; } else if(isBeta) { host = "http://39.108.250.202:9000/"; - // host = "http://192.168.31.151:9000/"; + host = "http://192.168.31.151:9000/"; } else if(isPro) { host = "http://www.occupationlab.com/"; } else { diff --git a/src/views/Home.vue b/src/views/Home.vue index 54120f3..3d80be5 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -28,6 +28,8 @@ :code.sync="item.code" :workbench1="item.judgmentId" :codeId.sync="item.codeId" + :answer.sync="item.answer" + @cache="leavePage" > @@ -66,6 +68,7 @@ export default { }, mounted() { this.autoLogout() + // 绑定页面离开监听 window.onbeforeunload = () => { this.leavePage() } @@ -74,7 +77,7 @@ export default { // 页面离开的时候保存未提交的代码(只有练习和未提交状态下才会调用该接口) leavePage(){ const list = this.workbench - if(!this.$refs.mainindex.isSubmit && !this.assessmentId && list.length && list.some(e => e.code)){ + if(!this.$refs.mainindex.isSubmit && list.length && list.some(e => e.code)){ const cache = { projectId: this.projectId, judgmentId: list[Number(this.curTab)].judgmentId