|
@@ -247,9 +247,9 @@ export default {
|
|
|
if (this.answerRecruitId === "weekly-questions") {
|
|
|
// 开始每周答题
|
|
|
this.startWeeklyQuestion();
|
|
|
- } else if (this.answerRecruitId === "weekly-questions") {
|
|
|
+ } else if (this.answerRecruitId === "special-questions") {
|
|
|
// 开始专项答题
|
|
|
- this.startWeeklyQuestion();
|
|
|
+ this.startSpecialQuestion();
|
|
|
} else {
|
|
|
this.startNormalQuestion();
|
|
|
}
|
|
@@ -292,13 +292,28 @@ export default {
|
|
|
// 开始每周答题
|
|
|
startWeeklyQuestion() {
|
|
|
this.$_http
|
|
|
- .get(
|
|
|
+ .post(
|
|
|
this.$pathParams(this.$_API.POST_WEEKLY_QUESTIONS_START, {
|
|
|
questionId: this.questionId
|
|
|
- })
|
|
|
+ }),
|
|
|
+ this.userInfo
|
|
|
)
|
|
|
.then(res => {
|
|
|
- console.log("--------" + JSON.stringify(res));
|
|
|
+ if (res.data) {
|
|
|
+ if (res.data.length === 0) {
|
|
|
+ this.isInited = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let httpResultData = [];
|
|
|
+ res.data.forEach(element => {
|
|
|
+ this.answerStatus.push(0);
|
|
|
+ });
|
|
|
+ res.data.forEach((item, index) => {
|
|
|
+ httpResultData.push(this.setPersonDataFun(item));
|
|
|
+ });
|
|
|
+ this.examQuestionList = httpResultData;
|
|
|
+ this.handleExamQuestionItemFun(this.examQuestionList[0], 0);
|
|
|
+ }
|
|
|
})
|
|
|
.catch(() => {
|
|
|
this.$store.commit("toggleLoading", false);
|
|
@@ -306,7 +321,33 @@ export default {
|
|
|
},
|
|
|
// 开始专项答题
|
|
|
startSpecialQuestion() {
|
|
|
-
|
|
|
+ this.$_http
|
|
|
+ .post(
|
|
|
+ this.$pathParams(this.$_API.POST_SPECIAL_QUESTIONS_START, {
|
|
|
+ questionId: this.questionId
|
|
|
+ }),
|
|
|
+ this.userInfo
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ if (res.data) {
|
|
|
+ if (res.data.length === 0) {
|
|
|
+ this.isInited = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let httpResultData = [];
|
|
|
+ res.data.forEach(element => {
|
|
|
+ this.answerStatus.push(0);
|
|
|
+ });
|
|
|
+ res.data.forEach((item, index) => {
|
|
|
+ httpResultData.push(this.setPersonDataFun(item));
|
|
|
+ });
|
|
|
+ this.examQuestionList = httpResultData;
|
|
|
+ this.handleExamQuestionItemFun(this.examQuestionList[0], 0);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$store.commit("toggleLoading", false);
|
|
|
+ });
|
|
|
},
|
|
|
// 方法:过滤试题的类型,添加用户作答的字段
|
|
|
setPersonDataFun(httpResultDataItme) {
|
|
@@ -520,6 +561,15 @@ export default {
|
|
|
this.$store.commit("toggleLoading", true);
|
|
|
let grades = this.getUserExamAllPointsFun(); // 方法:计算成绩
|
|
|
let answers = this.getUserExamAllAnswersFun(); // 方法:获取当前用户所有题目作答的答案
|
|
|
+ if (this.answerRecruitId === "weekly-questions") {
|
|
|
+ this.weeklyExamsEnd(grades, answers);
|
|
|
+ } else if (this.answerRecruitId === "special-questions") {
|
|
|
+ this.specialExamEnd(grades, answers);
|
|
|
+ } else {
|
|
|
+ this.normalExamsEnd(grades, answers);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ normalExamsEnd(grades, answers) {
|
|
|
let params = {
|
|
|
userId: this.userInfo.userName,
|
|
|
examId: this.answerRecruitId,
|
|
@@ -552,6 +602,72 @@ export default {
|
|
|
this.$router.back();
|
|
|
});
|
|
|
},
|
|
|
+ weeklyExamsEnd(grades, answers) {
|
|
|
+ let params = {
|
|
|
+ userName: this.userInfo.userName,
|
|
|
+ weeklyQuestionId: this.questionId,
|
|
|
+ points: grades, // 成绩:积分
|
|
|
+ startTime: "", // this.answerTime.startTime,
|
|
|
+ endTime: "", // this.answerTime.endTime
|
|
|
+ userAnswers: answers
|
|
|
+ };
|
|
|
+ this.$_http
|
|
|
+ .post(
|
|
|
+ this.$pathParams(this.$_API.POST_WEEKLY_QUESTIONS_END, {
|
|
|
+ questionId: this.questionId
|
|
|
+ }),
|
|
|
+ params
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ this.$store.commit("toggleLoading", false);
|
|
|
+ this.$router.replace({
|
|
|
+ name: "answerRecruitResult",
|
|
|
+ params: {
|
|
|
+ allQuestionsNum: this.examQuestionList.length,
|
|
|
+ grades: grades
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$store.commit("toggleLoading", false);
|
|
|
+ Dialog.close();
|
|
|
+ Dialog({ message: "结束考试异常,请联系系统管理员" });
|
|
|
+ this.$router.back();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ specialExamEnd(grades, answers) {
|
|
|
+ let params = {
|
|
|
+ userName: this.userInfo.userName,
|
|
|
+ specialQuestionId: this.questionId,
|
|
|
+ points: grades, // 成绩:积分
|
|
|
+ startTime: "", // this.answerTime.startTime,
|
|
|
+ endTime: "", // this.answerTime.endTime
|
|
|
+ userAnswers: answers
|
|
|
+ };
|
|
|
+ this.$_http
|
|
|
+ .post(
|
|
|
+ this.$pathParams(this.$_API.POST_SPECIAL_QUESTIONS_END, {
|
|
|
+ questionId: this.questionId
|
|
|
+ }),
|
|
|
+ params
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ this.$store.commit("toggleLoading", false);
|
|
|
+ this.$router.replace({
|
|
|
+ name: "answerRecruitResult",
|
|
|
+ params: {
|
|
|
+ allQuestionsNum: this.examQuestionList.length,
|
|
|
+ grades: grades
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$store.commit("toggleLoading", false);
|
|
|
+ Dialog.close();
|
|
|
+ Dialog({ message: "结束考试异常,请联系系统管理员" });
|
|
|
+ this.$router.back();
|
|
|
+ });
|
|
|
+ },
|
|
|
// 方法:计算成绩
|
|
|
getUserExamAllPointsFun() {
|
|
|
let grades = 0;
|