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