|
@@ -2,6 +2,7 @@ import {
|
|
|
examUserExamStart,
|
|
examUserExamStart,
|
|
|
examUserExamCommitmentConfirm,
|
|
examUserExamCommitmentConfirm,
|
|
|
examUserCoursewareLearningRestart,
|
|
examUserCoursewareLearningRestart,
|
|
|
|
|
+ examUserExamAttemptFinished,
|
|
|
} from '@/pages_safetyEducationExamination/api/index.js'
|
|
} from '@/pages_safetyEducationExamination/api/index.js'
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -41,44 +42,36 @@ export async function goToExamPage(item, callbacks = {}) {
|
|
|
const currentPage = pages[pages.length - 1];
|
|
const currentPage = pages[pages.length - 1];
|
|
|
const currentRoute = currentPage.route;
|
|
const currentRoute = currentPage.route;
|
|
|
if (item.mockExamId) {
|
|
if (item.mockExamId) {
|
|
|
- const examData = encodeURIComponent(JSON.stringify(item));
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${item.examId}&attemptId=${item.mockExamId}`,
|
|
|
|
|
- });
|
|
|
|
|
- // if(currentRoute == 'pages_safetyEducationExamination/views/exam/mockExamInfo' || currentRoute == 'pages_safetyEducationExamination/views/exam/onlineExamInfo'){
|
|
|
|
|
- // uni.navigateTo({
|
|
|
|
|
- // url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${item.examId}&attemptId=${item.mockExamId}`,
|
|
|
|
|
- // });
|
|
|
|
|
- // }else{
|
|
|
|
|
- // uni.navigateTo({
|
|
|
|
|
- // url: `/pages_safetyEducationExamination/views/exam/mockExamInfo?examData=${examData}`,
|
|
|
|
|
- // });
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ // const examData = encodeURIComponent(JSON.stringify(item));
|
|
|
|
|
+ // uni.navigateTo({
|
|
|
|
|
+ // url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${item.examId}&attemptId=${item.mockExamId}`,
|
|
|
|
|
+ // });
|
|
|
|
|
+ let obj = {
|
|
|
|
|
+ examId: item.examId,
|
|
|
|
|
+ attemptId: item.mockExamId,
|
|
|
|
|
+ };
|
|
|
|
|
+ console.log('goToExamPage-obj',obj)
|
|
|
|
|
+ examUserExamAttemptFinishedPlay(2,obj);
|
|
|
} else {
|
|
} else {
|
|
|
- try {
|
|
|
|
|
- const { data } = await examUserExamStart({ examId: item.examId, examScene: 2 });
|
|
|
|
|
- if (data.code === 200 && data.data && data.data.attemptId) {
|
|
|
|
|
- const filled = { ...item, attemptId: data.data.attemptId };
|
|
|
|
|
- const examData = encodeURIComponent(JSON.stringify(filled));
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${item.examId}&attemptId=${data.data.attemptId}`,
|
|
|
|
|
- });
|
|
|
|
|
- // if(currentRoute == 'pages_safetyEducationExamination/views/exam/mockExamInfo'){
|
|
|
|
|
- // uni.navigateTo({
|
|
|
|
|
- // url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${item.examId}&attemptId=${data.data.attemptId}`,
|
|
|
|
|
- // });
|
|
|
|
|
- // }else{
|
|
|
|
|
- // uni.navigateTo({
|
|
|
|
|
- // url: `/pages_safetyEducationExamination/views/exam/mockExamInfo?examData=${examData}`,
|
|
|
|
|
- // });
|
|
|
|
|
- // }
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.showToast({ title: data.message || '获取模拟试卷失败', icon: 'none' });
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.error('获取模拟试卷失败', e);
|
|
|
|
|
- uni.showToast({ title: '获取模拟试卷失败', icon: 'none' });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let obj = {
|
|
|
|
|
+ examId: item.examId,
|
|
|
|
|
+ };
|
|
|
|
|
+ examUserExamStartPlay(2,obj);
|
|
|
|
|
+ // try {
|
|
|
|
|
+ // const { data } = await examUserExamStart({ examId: item.examId, examScene: 2 });
|
|
|
|
|
+ // if (data.code === 200 && data.data && data.data.attemptId) {
|
|
|
|
|
+ // const filled = { ...item, attemptId: data.data.attemptId };
|
|
|
|
|
+ // const examData = encodeURIComponent(JSON.stringify(filled));
|
|
|
|
|
+ // uni.navigateTo({
|
|
|
|
|
+ // url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${item.examId}&attemptId=${data.data.attemptId}`,
|
|
|
|
|
+ // });
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // uni.showToast({ title: data.message || '获取模拟试卷失败', icon: 'none' });
|
|
|
|
|
+ // }
|
|
|
|
|
+ // } catch (e) {
|
|
|
|
|
+ // console.error('获取模拟试卷失败', e);
|
|
|
|
|
+ // uni.showToast({ title: '获取模拟试卷失败', icon: 'none' });
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else if (item.conditionType == 4) {
|
|
} else if (item.conditionType == 4) {
|
|
@@ -99,7 +92,13 @@ export async function resolveExamEntry(item, callbacks = {}) {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 不需要承诺书,直接进入考试
|
|
// 不需要承诺书,直接进入考试
|
|
|
- await startFormalExam(item);
|
|
|
|
|
|
|
+ // await startFormalExam(item);
|
|
|
|
|
+ if(item.attemptId){
|
|
|
|
|
+ console.log('resolveExamEntry-item',item)
|
|
|
|
|
+ examUserExamAttemptFinishedPlay(1,item);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ examUserExamStartPlay(1,item);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -128,15 +127,22 @@ export async function confirmCommitmentAndStart(preData, onClose) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- console.log('确认1')
|
|
|
|
|
const { data } = await examUserExamCommitmentConfirm({ attemptId });
|
|
const { data } = await examUserExamCommitmentConfirm({ attemptId });
|
|
|
- console.log('确认2')
|
|
|
|
|
if (data.code === 200) {
|
|
if (data.code === 200) {
|
|
|
- console.log('确认3')
|
|
|
|
|
if (typeof onClose === 'function') {
|
|
if (typeof onClose === 'function') {
|
|
|
onClose();
|
|
onClose();
|
|
|
} else {
|
|
} else {
|
|
|
- navigateToExamPlay(preData.examId, attemptId, preData.examKind);
|
|
|
|
|
|
|
+ // navigateToExamPlay(preData.examId, attemptId, preData.examKind);
|
|
|
|
|
+ let obj = {
|
|
|
|
|
+ examId: preData.examId,
|
|
|
|
|
+ attemptId: attemptId,
|
|
|
|
|
+ type: '1',
|
|
|
|
|
+ examKind:preData.examKind,
|
|
|
|
|
+ attemptLimit:preData.attemptLimit,
|
|
|
|
|
+ attemptCount:preData.attemptCount,
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log('confirmCommitmentAndStart-obj',obj)
|
|
|
|
|
+ examUserExamAttemptFinishedPlay(1,obj);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({ title: data.message || '确认失败', icon: 'none' });
|
|
uni.showToast({ title: data.message || '确认失败', icon: 'none' });
|
|
@@ -211,3 +217,83 @@ export async function examUserCoursewareLearningRestartFunction(coursewareId ) {
|
|
|
}
|
|
}
|
|
|
} catch (e) { console.error('重新开始学习课件失败', e); }
|
|
} catch (e) { console.error('重新开始学习课件失败', e); }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//二次确认考试是否已结束
|
|
|
|
|
+export async function examUserExamAttemptFinishedPlay(type,item) {
|
|
|
|
|
+ console.log('调用了')
|
|
|
|
|
+ try {
|
|
|
|
|
+ console.log('item',item)
|
|
|
|
|
+ const { data } = await examUserExamAttemptFinished({ attemptId:item.attemptId });
|
|
|
|
|
+ if (data.code == 200) {
|
|
|
|
|
+ if(data.data){
|
|
|
|
|
+ //已结束
|
|
|
|
|
+ if(type == 1){
|
|
|
|
|
+ //在线考试
|
|
|
|
|
+ if(item.attemptLimit == 0 || item.attemptCount < item.attemptLimit){
|
|
|
|
|
+ //获取新试卷
|
|
|
|
|
+ examUserExamStartPlay(type,item)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //无可用次数 提示并刷新数据列表
|
|
|
|
|
+ uni.showToast({ title: '当前考试已结束', icon: 'none' });
|
|
|
|
|
+ checkData();
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(type == 2){
|
|
|
|
|
+ //模拟考试-获取新试卷
|
|
|
|
|
+ examUserExamStartPlay(type,item)
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //未结束
|
|
|
|
|
+ confirmTitle(type,item);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) { console.error('二次确认考试是否已结束失败', e);}
|
|
|
|
|
+}
|
|
|
|
|
+//获取新试卷
|
|
|
|
|
+export async function examUserExamStartPlay(type,item) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const { data } = await examUserExamStart({ examId: item.examId, examScene: type });
|
|
|
|
|
+ if (data.code === 200 && data.data && data.data.attemptId) {
|
|
|
|
|
+ let obj = {
|
|
|
|
|
+ examId: item.examId,
|
|
|
|
|
+ attemptId: data.data.attemptId,
|
|
|
|
|
+ };
|
|
|
|
|
+ if(type == 1){
|
|
|
|
|
+ obj.type = 1;
|
|
|
|
|
+ obj.examKind = item.examKind;
|
|
|
|
|
+ }
|
|
|
|
|
+ confirmTitle(type,obj);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({ title: data.message || '获取试卷失败', icon: 'none' });
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('获取试卷失败', e);
|
|
|
|
|
+ uni.showToast({ title: '获取试卷失败', icon: 'none' });
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+//弹窗确认
|
|
|
|
|
+export async function confirmTitle(type,item) {
|
|
|
|
|
+ if(type == 1){
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '进入考试页面',
|
|
|
|
|
+ content: `考试期间未完成答题请勿离开页面,离开后倒计时仍会继续,超时将自动交卷并记录成绩,扣除 1 次考试机会。`,
|
|
|
|
|
+ confirmText:'确定进入',
|
|
|
|
|
+ success: async (res) => {
|
|
|
|
|
+ if (res.confirm) {
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: `/pages_safetyEducationExamination/views/exam/onlineExamPlay?examId=${encodeURIComponent(item.examId)}&attemptId=${encodeURIComponent(item.attemptId)}&examKind=${encodeURIComponent(item.examKind || '')}`,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }else if(type == 2){
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${item.examId}&attemptId=${item.attemptId}`,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//监听数据刷新事件
|
|
|
|
|
+export function checkData(data) {
|
|
|
|
|
+ uni.$emit('onDataCheckSuccess', data)
|
|
|
|
|
+}
|