|
@@ -649,68 +649,148 @@ export default {
|
|
|
});
|
|
|
let score = 0; //计算总分
|
|
|
let reportStatus = 0;
|
|
|
- let number = 0;
|
|
|
+ let number = 0; //做对的题目数量
|
|
|
+ let doQuestionNum = 0; //做过的题目数量
|
|
|
+ let allScore = 0; //总分
|
|
|
let passScore = 0;
|
|
|
+ let doWrongQuestionIds = []; //错题和未做题id(客观题)
|
|
|
+ let doQuestionIds = []; //做过的题目id
|
|
|
+ let rightQuestionIds = []; //做对的题目id
|
|
|
this.questionList.forEach((item, index) => {
|
|
|
- passScore = item.passScore
|
|
|
+ // passScore = item.passScore
|
|
|
if (item.type == 1) {
|
|
|
+ //正确
|
|
|
if (item.ques == item.ans) {
|
|
|
item.scoreResult = item.score;
|
|
|
score += item.score;
|
|
|
number++;
|
|
|
- } else {
|
|
|
-
|
|
|
- item.scoreResult = 0;
|
|
|
+ rightQuestionIds.push(item.questionId)
|
|
|
+ } else { //错误
|
|
|
+ item.scoreResult = 0;
|
|
|
+ doWrongQuestionIds.push(item.questionId)
|
|
|
+ }
|
|
|
+ allScore += item.score;
|
|
|
+ if (item.ques) {
|
|
|
+ doQuestionNum++;
|
|
|
+ doQuestionIds.push(item.questionId)
|
|
|
}
|
|
|
} else if (item.type == 2) {
|
|
|
let isRight =
|
|
|
- item.ques &&
|
|
|
- item.ques.every((quesItem, quesIndex) => {
|
|
|
+ item.ans &&
|
|
|
+ item.ans.every((quesItem, quesIndex) => {
|
|
|
return item.ques[quesIndex] == item.ans[quesIndex];
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
if (isRight) {
|
|
|
- item.scoreResult = item.score;
|
|
|
score += item.score;
|
|
|
number++;
|
|
|
+ item.scoreResult = item.score;
|
|
|
+ rightQuestionIds.push(item.questionId)
|
|
|
} else {
|
|
|
+ let checkboxScore = item.score; //获取单题总分数
|
|
|
+ item.ques.forEach((ques,quesIndex) => {
|
|
|
+ //选错一个全扣
|
|
|
+ if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
|
|
|
+ checkboxScore = 0;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(checkboxScore)
|
|
|
+
|
|
|
+ //没选错
|
|
|
+ if(checkboxScore) {
|
|
|
+
|
|
|
+ item.ans.forEach((ans,quesIndex) => {
|
|
|
+ //漏选扣一部分
|
|
|
+ console.log(item.ques.indexOf(item.ans[quesIndex]))
|
|
|
+ if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
|
|
|
+ checkboxScore -= item.partScore;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ if(checkboxScore <= 0) { //0分
|
|
|
item.scoreResult = 0;
|
|
|
+ doWrongQuestionIds.push(item.questionId)
|
|
|
+ } else { //部分分
|
|
|
+ number++;
|
|
|
+ item.scoreResult = checkboxScore;
|
|
|
+ score += checkboxScore;
|
|
|
+ rightQuestionIds.push(item.questionId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ allScore += item.score;
|
|
|
+ if (item.ques && item.ques.length) {
|
|
|
+ doQuestionNum++;
|
|
|
+ doQuestionIds.push(item.questionId)
|
|
|
}
|
|
|
} else if (item.type == 3) {
|
|
|
if (item.ques == item.ans) {
|
|
|
item.scoreResult = item.score;
|
|
|
score += item.score;
|
|
|
number++;
|
|
|
+ rightQuestionIds.push(item.questionId)
|
|
|
} else {
|
|
|
-
|
|
|
item.scoreResult = 0;
|
|
|
+ doWrongQuestionIds.push(item.questionId)
|
|
|
+ }
|
|
|
+ allScore += item.score;
|
|
|
+ if (item.ques) {
|
|
|
+ doQuestionNum++;
|
|
|
+ doQuestionIds.push(item.questionId)
|
|
|
+ }
|
|
|
+ } else if (item.type == 4) {
|
|
|
+ if (item.ques && item.ques.length) {
|
|
|
+ doQuestionNum++;
|
|
|
+ }
|
|
|
+ } else if (item.type == 5) {
|
|
|
+ if (item.ques) {
|
|
|
+ doQuestionNum++;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- if(score >= passScore) {
|
|
|
+
|
|
|
+ //大于60分及格
|
|
|
+ if(score >= 60) {
|
|
|
reportStatus = 1
|
|
|
} else {
|
|
|
reportStatus = 0
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ //交卷
|
|
|
this.$api
|
|
|
.examRecordEdit({
|
|
|
examId: this.id,
|
|
|
goodsId: this.goodsId,
|
|
|
reportStatus:reportStatus,
|
|
|
- doQuestionNum: this.questionOverNum(),
|
|
|
recordId: this.recordId,
|
|
|
rightQuestionNum: number,
|
|
|
status: 1,
|
|
|
+ doQuestionIds:doQuestionIds.join(','),
|
|
|
+ rightQuestionIds:rightQuestionIds.join(','),
|
|
|
+ doQuestionNum: doQuestionNum,
|
|
|
performance: score,
|
|
|
totalScore: allScore,
|
|
|
examTime: parseInt(this.allTimes),
|
|
|
doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
|
|
|
historyExamJson: JSON.stringify(this.questionList)
|
|
|
})
|
|
|
- .then(res => {});
|
|
|
+ .then(res => {
|
|
|
+ this.isSubmit = true;
|
|
|
+ if (res.data.code == 200) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //错题集id提交(客观题)
|
|
|
+ this.$api.examWrongRecord({
|
|
|
+ examId: this.id,
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ questionIds: doWrongQuestionIds,
|
|
|
+ recordId: this.recordId
|
|
|
+ }).then(res => {
|
|
|
+
|
|
|
+ });
|
|
|
},
|
|
|
/**
|
|
|
* 立即交卷
|
|
@@ -740,18 +820,47 @@ export default {
|
|
|
}
|
|
|
} else if (item.type == 2) {
|
|
|
let isRight =
|
|
|
- item.ques &&
|
|
|
- item.ques.every((quesItem, quesIndex) => {
|
|
|
+ item.ans &&
|
|
|
+ item.ans.every((quesItem, quesIndex) => {
|
|
|
return item.ques[quesIndex] == item.ans[quesIndex];
|
|
|
});
|
|
|
|
|
|
if (isRight) {
|
|
|
score += item.score;
|
|
|
number++;
|
|
|
+ } else {
|
|
|
+ let checkboxScore = item.score; //获取单题总分数
|
|
|
+ item.ques.forEach((ques,quesIndex) => {
|
|
|
+ //选错一个全扣
|
|
|
+ if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
|
|
|
+ checkboxScore = 0;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(checkboxScore)
|
|
|
+
|
|
|
+ //没选错
|
|
|
+ if(checkboxScore) {
|
|
|
+
|
|
|
+ item.ans.forEach((ans,quesIndex) => {
|
|
|
+ //漏选扣一部分
|
|
|
+ console.log(item.ques.indexOf(item.ans[quesIndex]))
|
|
|
+ if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
|
|
|
+ checkboxScore -= item.partScore;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(checkboxScore <= 0) { //0分
|
|
|
+
|
|
|
+ } else { //部分分
|
|
|
+ number++;
|
|
|
+ score += checkboxScore;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
if (item.ques && item.ques.length) {
|
|
|
doQuestionNum++;
|
|
|
+ doQuestionIds.push(item.questionId)
|
|
|
}
|
|
|
} else if (item.type == 3) {
|
|
|
if (item.ques == item.ans) {
|
|
@@ -1188,8 +1297,8 @@ export default {
|
|
|
}
|
|
|
} else if (item.type == 2) {
|
|
|
let isRight =
|
|
|
- item.ques &&
|
|
|
- item.ques.every((quesItem, quesIndex) => {
|
|
|
+ item.ans &&
|
|
|
+ item.ans.every((quesItem, quesIndex) => {
|
|
|
return item.ques[quesIndex] == item.ans[quesIndex];
|
|
|
});
|
|
|
|
|
@@ -1199,8 +1308,37 @@ export default {
|
|
|
item.scoreResult = item.score;
|
|
|
rightQuestionIds.push(item.questionId)
|
|
|
} else {
|
|
|
- item.scoreResult = 0;
|
|
|
- doWrongQuestionIds.push(item.questionId)
|
|
|
+ let checkboxScore = item.score; //获取单题总分数
|
|
|
+ item.ques.forEach((ques,quesIndex) => {
|
|
|
+ //选错一个全扣
|
|
|
+ if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
|
|
|
+ checkboxScore = 0;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(checkboxScore)
|
|
|
+
|
|
|
+ //没选错
|
|
|
+ if(checkboxScore) {
|
|
|
+
|
|
|
+ item.ans.forEach((ans,quesIndex) => {
|
|
|
+ //漏选扣一部分
|
|
|
+ console.log(item.ques.indexOf(item.ans[quesIndex]))
|
|
|
+ if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
|
|
|
+ checkboxScore -= item.partScore;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(checkboxScore <= 0) { //0分
|
|
|
+ item.scoreResult = 0;
|
|
|
+ doWrongQuestionIds.push(item.questionId)
|
|
|
+ } else { //部分分
|
|
|
+ number++;
|
|
|
+ item.scoreResult = checkboxScore;
|
|
|
+ score += checkboxScore;
|
|
|
+ rightQuestionIds.push(item.questionId)
|
|
|
+ }
|
|
|
}
|
|
|
allScore += item.score;
|
|
|
if (item.ques && item.ques.length) {
|