|
@@ -9,7 +9,8 @@ import router from "@/router";
|
|
|
import api from "@/api";
|
|
|
export const useThreeExam = (requestFn: Promise<threeApi.threeForceList>, config = {
|
|
|
countDown: true,
|
|
|
- autoAnswer: true
|
|
|
+ autoAnswer: true,
|
|
|
+ recordUncomplete: true
|
|
|
}) => {
|
|
|
const store = useStore()
|
|
|
let timerId = 0
|
|
@@ -408,21 +409,21 @@ export const useThreeExam = (requestFn: Promise<threeApi.threeForceList>, config
|
|
|
};
|
|
|
const setPageToListIndex = (page: number | string) => {
|
|
|
if (list.value.length < Number(page)) {
|
|
|
- message.error({
|
|
|
- content: '超过最大值'
|
|
|
- })
|
|
|
- return
|
|
|
+ message.error({
|
|
|
+ content: '超过最大值'
|
|
|
+ })
|
|
|
+ return
|
|
|
}
|
|
|
else if (Number(page) < 1) {
|
|
|
- message.error({
|
|
|
- content: '低于最小值'
|
|
|
- })
|
|
|
+ message.error({
|
|
|
+ content: '低于最小值'
|
|
|
+ })
|
|
|
}
|
|
|
else {
|
|
|
- listIndex.value = Number(page) - 1
|
|
|
-
|
|
|
+ listIndex.value = Number(page) - 1
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
const nextProblem = () => {
|
|
|
console.log("nextProblem");
|
|
|
if (listIndex.value < list.value.length - 1) {
|
|
@@ -611,18 +612,21 @@ export const useThreeExam = (requestFn: Promise<threeApi.threeForceList>, config
|
|
|
const submitThreeExam = () => {
|
|
|
setUserAnswerAndRes(list.value[listIndex.value].userAnswer)
|
|
|
let score = 0
|
|
|
- const wrongTempList:threeApi.threeForceList["rows"] = [] //临时错题
|
|
|
- const wrongList:threeApi.threeForceList["rows"] = [] //永久错题
|
|
|
- const wrongListRes:string[] = []
|
|
|
+ const wrongTempList: threeApi.threeForceList["rows"] = [] //临时错题
|
|
|
+ const wrongList: threeApi.threeForceList["rows"] = [] //永久错题
|
|
|
+ const wrongListRes: string[] = []
|
|
|
list.value.forEach((item, index) => {
|
|
|
//题目正确加分
|
|
|
- if (item.isComplete && !item.isError&&list.value[index].userAnswer.length>0) {
|
|
|
+ if (item.isComplete && !item.isError && list.value[index].userAnswer.length > 0) {
|
|
|
score = score + 1
|
|
|
}
|
|
|
- else if(!item.isComplete&&list.value[index].userAnswer.length==0){
|
|
|
- //没做的题目
|
|
|
- wrongTempList.push(list.value[index])
|
|
|
- wrongListRes.push('0')
|
|
|
+ else if (!item.isComplete && list.value[index].userAnswer.length == 0) {
|
|
|
+ //没做的题目
|
|
|
+ if (config.recordUncomplete) {
|
|
|
+ wrongTempList.push(list.value[index])
|
|
|
+ wrongListRes.push('0')
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
else {
|
|
|
//错误的题目
|
|
@@ -632,7 +636,7 @@ export const useThreeExam = (requestFn: Promise<threeApi.threeForceList>, config
|
|
|
if (list.value[index].userAnswer == '') {
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (list.value[index].userAnswer == list.value[index]['an' + i]) {
|
|
|
userAnswerIndex = i
|
|
|
}
|
|
@@ -642,25 +646,25 @@ export const useThreeExam = (requestFn: Promise<threeApi.threeForceList>, config
|
|
|
}
|
|
|
})
|
|
|
//保存临时错题
|
|
|
- window.sessionStorage.setItem('threeExam_temp_wrong_list',JSON.stringify(wrongTempList))
|
|
|
+ window.sessionStorage.setItem('threeExam_temp_wrong_list', JSON.stringify(wrongTempList))
|
|
|
//同步全部的错题
|
|
|
api.question.questionthreeWrongWrongs({
|
|
|
-
|
|
|
- wrongs:wrongList.map(item=>{
|
|
|
- return {
|
|
|
- id:item.id,
|
|
|
- timestamp:+ new Date()
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- }).then(res=>{
|
|
|
- store.dispatch('AsyncThreeWrongList')
|
|
|
- })
|
|
|
+
|
|
|
+ wrongs: wrongList.map(item => {
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ timestamp: + new Date()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }).then(res => {
|
|
|
+ store.dispatch('AsyncThreeWrongList')
|
|
|
+ })
|
|
|
router.push({
|
|
|
- path:'/threeExamAnaly',
|
|
|
- query:{
|
|
|
- wrongListRes:JSON.stringify(wrongListRes),
|
|
|
- score:score
|
|
|
+ path: '/threeExamAnaly',
|
|
|
+ query: {
|
|
|
+ wrongListRes: JSON.stringify(wrongListRes),
|
|
|
+ score: score
|
|
|
}
|
|
|
})
|
|
|
}
|