|
@@ -1,12 +1,12 @@
|
|
<template>
|
|
<template>
|
|
- <div v-if="isInited" class="page-exam-question-box">
|
|
|
|
|
|
+ <div class="page-exam-question-box">
|
|
<van-nav-bar title="考试" />
|
|
<van-nav-bar title="考试" />
|
|
<!-- 倒计时 -->
|
|
<!-- 倒计时 -->
|
|
- <div class="exam-question-countdown">
|
|
|
|
|
|
+ <div v-if="isInited" class="exam-question-countdown">
|
|
<span>剩余考试时间:{{ timeDiff }}</span>
|
|
<span>剩余考试时间:{{ timeDiff }}</span>
|
|
</div>
|
|
</div>
|
|
<!-- 题序盒子 -->
|
|
<!-- 题序盒子 -->
|
|
- <div class="exam-question-list">
|
|
|
|
|
|
+ <div v-if="isInited" class="exam-question-list">
|
|
<!-- 辅助间隙,样式问题 -->
|
|
<!-- 辅助间隙,样式问题 -->
|
|
<div class="exam-question-start">st</div>
|
|
<div class="exam-question-start">st</div>
|
|
<!-- 题序 -->
|
|
<!-- 题序 -->
|
|
@@ -27,9 +27,9 @@
|
|
</div>
|
|
</div>
|
|
<!-- 题目卡片 -->
|
|
<!-- 题目卡片 -->
|
|
<div class="exam-question-div">
|
|
<div class="exam-question-div">
|
|
- <div class="exam-question-card">
|
|
|
|
|
|
+ <div v-if="examQuestionList.length > 0" class="exam-question-card">
|
|
<!-- 标题、分数、题页 -->
|
|
<!-- 标题、分数、题页 -->
|
|
- <div v-if="examQuestionList.length" class="exam-question-head">
|
|
|
|
|
|
+ <div class="exam-question-head">
|
|
<div class="exam-question-head-left">
|
|
<div class="exam-question-head-left">
|
|
<div class="exam-question-head-left-icon"></div>
|
|
<div class="exam-question-head-left-icon"></div>
|
|
<div class="exam-question-head-left-txt">
|
|
<div class="exam-question-head-left-txt">
|
|
@@ -48,23 +48,20 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 描述 -->
|
|
<!-- 描述 -->
|
|
- <div v-if="examQuestionList.length" class="exam-question-describe">
|
|
|
|
|
|
+ <div class="exam-question-describe">
|
|
{{
|
|
{{
|
|
examQuestionList[answerIndex].questionContent ||
|
|
examQuestionList[answerIndex].questionContent ||
|
|
examQuestionList[answerIndex].content
|
|
examQuestionList[answerIndex].content
|
|
}}
|
|
}}
|
|
</div>
|
|
</div>
|
|
<!-- 答题列表 -->
|
|
<!-- 答题列表 -->
|
|
- <!-- 单选题、多选题的选项区域 -->
|
|
|
|
|
|
+ <!-- 单选题、多选题、判断题 的选项区域 -->
|
|
<div
|
|
<div
|
|
v-if="
|
|
v-if="
|
|
- examQuestionList.length &&
|
|
|
|
- (examQuestionList[answerIndex].type ===
|
|
|
|
- questionType.TrueOrFalse ||
|
|
|
|
- examQuestionList[answerIndex].type ===
|
|
|
|
- questionType.singleChoice ||
|
|
|
|
- examQuestionList[answerIndex].type ===
|
|
|
|
- questionType.multipleChoice)
|
|
|
|
|
|
+ examQuestionList[answerIndex].type === questionType.TrueOrFalse ||
|
|
|
|
+ examQuestionList[answerIndex].type ===
|
|
|
|
+ questionType.singleChoice ||
|
|
|
|
+ examQuestionList[answerIndex].type === questionType.multipleChoice
|
|
"
|
|
"
|
|
class="exam-question-options"
|
|
class="exam-question-options"
|
|
>
|
|
>
|
|
@@ -82,10 +79,7 @@
|
|
</div>
|
|
</div>
|
|
<!-- 填空题的答题区域 -->
|
|
<!-- 填空题的答题区域 -->
|
|
<div
|
|
<div
|
|
- v-if="
|
|
|
|
- examQuestionList.length &&
|
|
|
|
- examQuestionList[answerIndex].type === questionType.gapFilling
|
|
|
|
- "
|
|
|
|
|
|
+ v-if="examQuestionList[answerIndex].type === questionType.gapFilling"
|
|
class="exam-question-gapFilling"
|
|
class="exam-question-gapFilling"
|
|
>
|
|
>
|
|
<textarea
|
|
<textarea
|
|
@@ -118,6 +112,15 @@
|
|
>
|
|
>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div v-else class="exam-question-card">
|
|
|
|
+ <div v-if="isInited" class="exam-question-card-nodata">暂无数据</div>
|
|
|
|
+ <div
|
|
|
|
+ v-else
|
|
|
|
+ class="exam-question-card-nodata exam-question-card-loading"
|
|
|
|
+ >
|
|
|
|
+ 加载中...
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
<!-- 拍照用 -->
|
|
<!-- 拍照用 -->
|
|
<input
|
|
<input
|
|
@@ -126,7 +129,7 @@
|
|
name="file"
|
|
name="file"
|
|
accept="image/*"
|
|
accept="image/*"
|
|
capture="user"
|
|
capture="user"
|
|
- @change="startTakePhotoFUn"
|
|
|
|
|
|
+ @change="takePhotoCallbackFun"
|
|
style="display: none"
|
|
style="display: none"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
@@ -144,7 +147,7 @@ export default {
|
|
singleChoice: "DanXuan", // 单选题
|
|
singleChoice: "DanXuan", // 单选题
|
|
multipleChoice: "DuoXuan", // 多选题
|
|
multipleChoice: "DuoXuan", // 多选题
|
|
gapFilling: "TianKong", // 填空题
|
|
gapFilling: "TianKong", // 填空题
|
|
- TrueOrFalse: "PanDuanTi" // 判断题
|
|
|
|
|
|
+ TrueOrFalse: "PanDuan" // 判断题
|
|
}, // 试题类型
|
|
}, // 试题类型
|
|
examEndTimeSeconds: null, // 考试结束时的毫秒秒数
|
|
examEndTimeSeconds: null, // 考试结束时的毫秒秒数
|
|
examBeforeHalfEndTimeSeconds: null, // 开始考试一半时间的毫秒秒数
|
|
examBeforeHalfEndTimeSeconds: null, // 开始考试一半时间的毫秒秒数
|
|
@@ -157,6 +160,7 @@ export default {
|
|
inputValue: [], // 填空题时输入框的值
|
|
inputValue: [], // 填空题时输入框的值
|
|
isInited: false, // 是否已初始化完毕
|
|
isInited: false, // 是否已初始化完毕
|
|
isOverHalfTime: false, // 是否已超过1/3的考试时间
|
|
isOverHalfTime: false, // 是否已超过1/3的考试时间
|
|
|
|
+ isTakePhoto: false, // 是否已进行了拍照
|
|
answerTime: {
|
|
answerTime: {
|
|
startTime: 0,
|
|
startTime: 0,
|
|
endTime: 0
|
|
endTime: 0
|
|
@@ -176,7 +180,6 @@ export default {
|
|
this.initDataFun(); // 初始化数据信息
|
|
this.initDataFun(); // 初始化数据信息
|
|
},
|
|
},
|
|
beforeDestroy() {
|
|
beforeDestroy() {
|
|
- console.log("in");
|
|
|
|
if (this.interval) {
|
|
if (this.interval) {
|
|
clearInterval(this.interval); // 销毁前清空计时器
|
|
clearInterval(this.interval); // 销毁前清空计时器
|
|
}
|
|
}
|
|
@@ -210,7 +213,6 @@ export default {
|
|
// 方法:开始考试
|
|
// 方法:开始考试
|
|
examStartFun() {
|
|
examStartFun() {
|
|
this.$store.commit("toggleLoading", true);
|
|
this.$store.commit("toggleLoading", true);
|
|
- console.log(this.chooseEngneeringWork);
|
|
|
|
let params = {
|
|
let params = {
|
|
type: this.chooseEngneeringWork.value
|
|
type: this.chooseEngneeringWork.value
|
|
};
|
|
};
|
|
@@ -331,10 +333,6 @@ export default {
|
|
let curTime = Date.now(); // 获取当前时间的毫秒时间戳
|
|
let curTime = Date.now(); // 获取当前时间的毫秒时间戳
|
|
if (!isStart) {
|
|
if (!isStart) {
|
|
this.examBeforeHalfEndTimeSeconds = this.examEndTimeSeconds - curTime; // 获取当前开始考试的时间的毫秒秒数
|
|
this.examBeforeHalfEndTimeSeconds = this.examEndTimeSeconds - curTime; // 获取当前开始考试的时间的毫秒秒数
|
|
- console.log(
|
|
|
|
- "examBeforeHalfEndTimeSeconds:",
|
|
|
|
- this.examBeforeHalfEndTimeSeconds
|
|
|
|
- );
|
|
|
|
isStart = true;
|
|
isStart = true;
|
|
}
|
|
}
|
|
let diffTime = this.examEndTimeSeconds - curTime; // 计算出当前时间距离目标时间的时间差
|
|
let diffTime = this.examEndTimeSeconds - curTime; // 计算出当前时间距离目标时间的时间差
|
|
@@ -386,13 +384,10 @@ export default {
|
|
break;
|
|
break;
|
|
case this.questionType.gapFilling:
|
|
case this.questionType.gapFilling:
|
|
typeTxt = "填空题";
|
|
typeTxt = "填空题";
|
|
- console.log(content);
|
|
|
|
questionInputNum = this.getPlaceholderCount(content);
|
|
questionInputNum = this.getPlaceholderCount(content);
|
|
questionContent = content.replace("$PH$", "()");
|
|
questionContent = content.replace("$PH$", "()");
|
|
- console.log(questionContent, questionInputNum);
|
|
|
|
break;
|
|
break;
|
|
case this.questionType.TrueOrFalse:
|
|
case this.questionType.TrueOrFalse:
|
|
- console.log("判断题");
|
|
|
|
typeTxt = "判断题";
|
|
typeTxt = "判断题";
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -423,6 +418,7 @@ export default {
|
|
switch (item.type) {
|
|
switch (item.type) {
|
|
case this.questionType.singleChoice:
|
|
case this.questionType.singleChoice:
|
|
case this.questionType.multipleChoice:
|
|
case this.questionType.multipleChoice:
|
|
|
|
+ case this.questionType.TrueOrFalse:
|
|
this.answerValue = [...new Set(item.userAnswer)];
|
|
this.answerValue = [...new Set(item.userAnswer)];
|
|
break;
|
|
break;
|
|
case this.questionType.gapFilling:
|
|
case this.questionType.gapFilling:
|
|
@@ -488,7 +484,7 @@ export default {
|
|
this.examQuestionList[this.answerIndex].userAnswer = this.answerValue;
|
|
this.examQuestionList[this.answerIndex].userAnswer = this.answerValue;
|
|
this.handleNextFun();
|
|
this.handleNextFun();
|
|
// 若超过了了考试时间的1/3,则需要调用拍照
|
|
// 若超过了了考试时间的1/3,则需要调用拍照
|
|
- if (this.isOverHalfTime) {
|
|
|
|
|
|
+ if (this.isOverHalfTime && !this.isTakePhoto) {
|
|
this.$refs.uploadUserInput.click(); // 调用拍照工具
|
|
this.$refs.uploadUserInput.click(); // 调用拍照工具
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -555,38 +551,66 @@ export default {
|
|
getUserExamAllPointsFun() {
|
|
getUserExamAllPointsFun() {
|
|
let grades = 0;
|
|
let grades = 0;
|
|
this.examQuestionList.forEach((item, index) => {
|
|
this.examQuestionList.forEach((item, index) => {
|
|
- let sureNum = 0;
|
|
|
|
- item.finalAnswer.forEach(it => {
|
|
|
|
- item.userAnswer.forEach(answerItem => {
|
|
|
|
- if (it === answerItem) {
|
|
|
|
- sureNum++;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- if (sureNum === item.finalAnswer.length) {
|
|
|
|
|
|
+ // let sureNum = 0;
|
|
|
|
+ // item.finalAnswer.forEach(it => {
|
|
|
|
+ // item.userAnswer.forEach(answerItem => {
|
|
|
|
+ // if (it === answerItem) {
|
|
|
|
+ // sureNum++;
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // });
|
|
|
|
+ // if (sureNum === item.finalAnswer.length) {
|
|
|
|
+ // grades++; // 默认每题一分
|
|
|
|
+ // }
|
|
|
|
+ let isSure = this.getAnswerItemResultFun(item);
|
|
|
|
+ if (isSure) {
|
|
grades++; // 默认每题一分
|
|
grades++; // 默认每题一分
|
|
}
|
|
}
|
|
});
|
|
});
|
|
return grades;
|
|
return grades;
|
|
},
|
|
},
|
|
|
|
+ // 方法:判断当前题目是否正确
|
|
|
|
+ getAnswerItemResultFun(item) {
|
|
|
|
+ let isSure = false;
|
|
|
|
+ let lastAnswer = [""];
|
|
|
|
+ lastAnswer[0] = this.getUserAnswerSortFun(item);
|
|
|
|
+ if (lastAnswer[0] === item.finalAnswer[0]) {
|
|
|
|
+ isSure = true;
|
|
|
|
+ }
|
|
|
|
+ return isSure;
|
|
|
|
+ },
|
|
|
|
+ // 获取用户所选选项的升序编号答案
|
|
|
|
+ getUserAnswerSortFun(item) {
|
|
|
|
+ let newUnserAnswer = [];
|
|
|
|
+ item.answers.forEach((itemOne, indexOne) => {
|
|
|
|
+ item.userAnswer.forEach(itemTwo => {
|
|
|
|
+ if (itemOne === itemTwo) {
|
|
|
|
+ newUnserAnswer.push(this.formatQuestionIndex(indexOne));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ newUnserAnswer.sort();
|
|
|
|
+ return newUnserAnswer.join("");
|
|
|
|
+ },
|
|
// 方法:获取题目的答案
|
|
// 方法:获取题目的答案
|
|
getUserExamAllAnswersFun() {
|
|
getUserExamAllAnswersFun() {
|
|
let answers = [];
|
|
let answers = [];
|
|
this.examQuestionList.forEach((item, index) => {
|
|
this.examQuestionList.forEach((item, index) => {
|
|
- // answers[index] = item.userAnswer;
|
|
|
|
- answers[index] = item.userAnswer.join("||");
|
|
|
|
|
|
+ // answers[index] = item.userAnswer.join("||");
|
|
|
|
+ answers[index] = this.getUserAnswerSortFun(item);
|
|
});
|
|
});
|
|
return answers;
|
|
return answers;
|
|
},
|
|
},
|
|
// 方法:开始考试
|
|
// 方法:开始考试
|
|
- startTakePhotoFUn(event) {
|
|
|
|
|
|
+ takePhotoCallbackFun(event) {
|
|
let file = event.target.files[0]; // 获取文件对象
|
|
let file = event.target.files[0]; // 获取文件对象
|
|
if (file) {
|
|
if (file) {
|
|
|
|
+ this.isTakePhoto = true;
|
|
// let fd = new FormData(); // 构造formdata对象
|
|
// let fd = new FormData(); // 构造formdata对象
|
|
// fd.append("file", file); // 向formdata里面存放键值对存放图片文件
|
|
// fd.append("file", file); // 向formdata里面存放键值对存放图片文件
|
|
// fd.append("userId", this.userInfo.id); // 向formdata里面存放用户的ID
|
|
// fd.append("userId", this.userInfo.id); // 向formdata里面存放用户的ID
|
|
// console.log(fd);
|
|
// console.log(fd);
|
|
- this.$router.replace({ name: "Exam" });
|
|
|
|
|
|
+ // this.$router.replace({ name: "Exam" });
|
|
} else {
|
|
} else {
|
|
Toast("请完成拍照后,再进行考试");
|
|
Toast("请完成拍照后,再进行考试");
|
|
}
|
|
}
|
|
@@ -735,6 +759,19 @@ export default {
|
|
margin-top: 0.75rem;
|
|
margin-top: 0.75rem;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ .exam-question-card-loading,
|
|
|
|
+ .exam-question-card-nodata {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 5rem;
|
|
|
|
+ color: #333;
|
|
|
|
+ font-size: 0.7rem;
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ align-items: center;
|
|
|
|
+ }
|
|
|
|
+ .exam-question-card-loading {
|
|
|
|
+ color: #0088e9;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|