|
|
|
@ -127,21 +127,22 @@ |
|
|
|
|
<script> |
|
|
|
|
import newmain from "../util/newMain"; |
|
|
|
|
import util from '@/util' |
|
|
|
|
import Cookie from 'js-cookie' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
systemId: util.getCookie('systemId') || 1, |
|
|
|
|
classId: util.getCookie('classId'), |
|
|
|
|
className: util.getCookie('className') ? decodeURI(util.getCookie('className')) : '', |
|
|
|
|
courseId: util.getCookie('courseId'), |
|
|
|
|
projectId: util.getCookie('projectId') ? Number(util.getCookie('projectId')) : '', |
|
|
|
|
assessmentId: util.getCookie('assessmentId'), |
|
|
|
|
systemId: Cookie.get('admin-systemId') || 1, |
|
|
|
|
classId: Cookie.get('admin-classId'), |
|
|
|
|
className: Cookie.get('admin-className') ? decodeURI(Cookie.get('admin-className')) : '', |
|
|
|
|
courseId: Cookie.get('admin-courseId'), |
|
|
|
|
projectId: Cookie.get('admin-projectId') ? Number(Cookie.get('admin-projectId')) : '', |
|
|
|
|
assessmentId: Cookie.get('admin-assessmentId'), |
|
|
|
|
curSystemId: 1, |
|
|
|
|
projectPermissions: 0, // 项目权限(0、练习 1、考核 2、竞赛) |
|
|
|
|
isSubmit: false, // 是否提交的标识 |
|
|
|
|
entryTime: new Date(), |
|
|
|
|
startTime: util.getCookie('startTime'), |
|
|
|
|
endTime: util.getCookie('stopTime'), |
|
|
|
|
startTime: Cookie.get('admin-startTime'), |
|
|
|
|
endTime: Cookie.get('admin-stopTime'), |
|
|
|
|
pannelVisible: true, // 实验面板显示标识 |
|
|
|
|
grade: '00', // 得分 |
|
|
|
|
text: '', // 倒计时前面的文字,练习:所用;考核:剩余。练习是计时,考核是倒计时 |
|
|
|
@ -310,74 +311,81 @@ export default { |
|
|
|
|
// 深拷贝判分列表,下面接口获取到有缓存代码就直接存进去,如果用户选择了恢复代码,再用这个列表替换原来的判分列表 |
|
|
|
|
points = JSON.parse(JSON.stringify(this.points)) |
|
|
|
|
} |
|
|
|
|
let newJudgmentId = '' // 要恢复到第一个有代码的判分规则,因为有代码的规则可能不是第一个,所以要判断如果这个为空,才把索引赋给该变量 |
|
|
|
|
const promiseList = [] // promise数组 |
|
|
|
|
let hasCache = 0 // 是否有缓存 |
|
|
|
|
points.map((e, i) => { |
|
|
|
|
const judgmentId = e.judgmentId |
|
|
|
|
promiseList.push(new Promise((resolve,reject) => { |
|
|
|
|
this.$post(this.api.getLastCache, { |
|
|
|
|
assessmentId: assessmentId ? Number(assessmentId) : '', |
|
|
|
|
bcId: judgmentId, |
|
|
|
|
projectId, // 项目id,同上 |
|
|
|
|
cid // 课程id |
|
|
|
|
}).then(res => { |
|
|
|
|
this.closeLoad() |
|
|
|
|
const code = res.getLastCache |
|
|
|
|
// 如果有缓存代码 |
|
|
|
|
if (code) { |
|
|
|
|
hasCache = 1 |
|
|
|
|
if (newJudgmentId === '') newJudgmentId = i |
|
|
|
|
e.code = code |
|
|
|
|
} |
|
|
|
|
resolve() |
|
|
|
|
}).catch(res => { |
|
|
|
|
reject() |
|
|
|
|
this.closeLoad() |
|
|
|
|
}) |
|
|
|
|
})) |
|
|
|
|
}) |
|
|
|
|
// 如果有缓存代码,再提示用户是否要继续上次的实验 |
|
|
|
|
Promise.all(promiseList).then(_ => { |
|
|
|
|
hasCache && this.$confirm('是否要继续上次的实验?', '提示', { |
|
|
|
|
confirmButtonText: '是', |
|
|
|
|
cancelButtonText: '否', |
|
|
|
|
type: 'success' |
|
|
|
|
}).then(() => { |
|
|
|
|
localStorage.removeItem('codeCache') // 恢复代码后清除本地缓存 |
|
|
|
|
this.projectId = projectId |
|
|
|
|
// 如果是本地缓存里有项目id,则要再次获取项目详情,取判分列表再次赋值;本地没有缓存则取只恢复第一个判分点的代码 |
|
|
|
|
if (pId) { |
|
|
|
|
this.getProDetail().then(() => { |
|
|
|
|
// 如果是没有代码的缓存,则只需要恢复项目,否则,就调接口查询缓存代码 |
|
|
|
|
if (cache.empty) { |
|
|
|
|
this.projectId = projectId |
|
|
|
|
this.closeLoad() |
|
|
|
|
localStorage.removeItem('codeCache') |
|
|
|
|
} else { |
|
|
|
|
let newJudgmentId = '' // 要恢复到第一个有代码的判分规则,因为有代码的规则可能不是第一个,所以要判断如果这个为空,才把索引赋给该变量 |
|
|
|
|
const promiseList = [] // promise数组 |
|
|
|
|
let hasCache = 0 // 是否有缓存 |
|
|
|
|
points.map((e, i) => { |
|
|
|
|
const judgmentId = e.judgmentId |
|
|
|
|
promiseList.push(new Promise((resolve,reject) => { |
|
|
|
|
this.$post(this.api.getLastCache, { |
|
|
|
|
assessmentId: assessmentId ? Number(assessmentId) : '', |
|
|
|
|
bcId: judgmentId, |
|
|
|
|
projectId, // 项目id,同上 |
|
|
|
|
cid // 课程id |
|
|
|
|
}).then(res => { |
|
|
|
|
this.closeLoad() |
|
|
|
|
const code = res.getLastCache |
|
|
|
|
// 如果有缓存代码 |
|
|
|
|
if (code) { |
|
|
|
|
hasCache = 1 |
|
|
|
|
if (newJudgmentId === '') newJudgmentId = i |
|
|
|
|
e.code = code |
|
|
|
|
} |
|
|
|
|
resolve() |
|
|
|
|
}).catch(res => { |
|
|
|
|
reject() |
|
|
|
|
this.closeLoad() |
|
|
|
|
}) |
|
|
|
|
})) |
|
|
|
|
}) |
|
|
|
|
// 如果有缓存代码,再提示用户是否要继续上次的实验 |
|
|
|
|
Promise.all(promiseList).then(_ => { |
|
|
|
|
hasCache && this.$confirm('是否要继续上次的实验?', '提示', { |
|
|
|
|
confirmButtonText: '是', |
|
|
|
|
cancelButtonText: '否', |
|
|
|
|
type: 'success' |
|
|
|
|
}).then(() => { |
|
|
|
|
localStorage.removeItem('codeCache') // 恢复代码后清除本地缓存 |
|
|
|
|
this.projectId = projectId |
|
|
|
|
// 如果是本地缓存里有项目id,则要再次获取项目详情,取判分列表再次赋值;本地没有缓存则取只恢复第一个判分点的代码 |
|
|
|
|
if (pId) { |
|
|
|
|
this.getProDetail().then(() => { |
|
|
|
|
this.points.map(e => { |
|
|
|
|
const item = points.find(n => n.judgmentId === e.judgmentId) |
|
|
|
|
if (item && item.code) this.$set(e, 'code', item.code) |
|
|
|
|
}) |
|
|
|
|
this.$emit('tell', projectId, this.curSystemId, this.points) |
|
|
|
|
this.$emit('recoveryCode', newJudgmentId + '') // 切换为缓存的判分点,tab索引值要为字符串 |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
} else { |
|
|
|
|
this.points.map(e => { |
|
|
|
|
const item = points.find(n => n.judgmentId === e.judgmentId) |
|
|
|
|
if (item && item.code) this.$set(e, 'code', item.code) |
|
|
|
|
}) |
|
|
|
|
this.$emit('tell', projectId, this.curSystemId, this.points) |
|
|
|
|
this.$emit('recoveryCode', newJudgmentId + '') // 切换为缓存的判分点,tab索引值要为字符串 |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
} else { |
|
|
|
|
this.points.map(e => { |
|
|
|
|
const item = points.find(n => n.judgmentId === e.judgmentId) |
|
|
|
|
if (item && item.code) this.$set(e, 'code', item.code) |
|
|
|
|
this.$emit('recoveryCode') |
|
|
|
|
} |
|
|
|
|
}).catch(() => { |
|
|
|
|
// 选择了不继续上次的实验,则清除本地缓存,并删除服务器里缓存的代码 |
|
|
|
|
localStorage.removeItem('codeCache') |
|
|
|
|
// 删除该项目下所有判分规则的缓存代码 |
|
|
|
|
points.map(e => { |
|
|
|
|
e.code && this.$post(this.api.delCache, { |
|
|
|
|
assessmentId, |
|
|
|
|
bcId: e.judgmentId, |
|
|
|
|
projectId, |
|
|
|
|
cid |
|
|
|
|
}).then(res => {}).catch(() => {}) |
|
|
|
|
}) |
|
|
|
|
this.$emit('tell', projectId, this.curSystemId, this.points) |
|
|
|
|
this.$emit('recoveryCode') |
|
|
|
|
} |
|
|
|
|
}).catch(() => { |
|
|
|
|
// 选择了不继续上次的实验,则清除本地缓存,并删除服务器里缓存的代码 |
|
|
|
|
localStorage.removeItem('codeCache') |
|
|
|
|
// 删除该项目下所有判分规则的缓存代码 |
|
|
|
|
points.map(e => { |
|
|
|
|
e.code && this.$post(`${this.api.delCache}`, { |
|
|
|
|
assessmentId, |
|
|
|
|
bcId: e.judgmentId, |
|
|
|
|
projectId, |
|
|
|
|
cid |
|
|
|
|
}).then(res => {}).catch(() => {}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 定时查询考核状态(只有考核才需要定时查,查到考核如果结束后,直接提交考核) |
|
|
|
|
getStatus() { |
|
|
|
|