ソースを参照

修改每周答题和专项答题

aaa 4 年 前
コミット
da27c78d91

+ 1 - 1
src/api/modules/user.js

@@ -3,7 +3,7 @@ export default {
   basePath: process.env.VUE_APP_JTXT_URL,
   apiList: {
     //  admin获取所有用户
-    JTXT_GET_USER_ADMIN_USERS: "admin/users",
+    JTXT_GET_USER_ADMIN_USERS: "users",
     // 查询今日积分
     JTXT_GET_USER_DAIYL_POINTS: "user/{userName}/daily-points",
     // 查询总积分

+ 5 - 0
src/views/home/answer/page-answer-recruit-result.vue

@@ -15,6 +15,7 @@
           >返回</van-button
         >
         <van-button
+        v-if="answerRecruitId !='weekly-questions' && answerRecruitId !='special-questions'"
           class="exam-item-detial-button"
           type="primary"
           color="#0088e9"
@@ -27,6 +28,7 @@
 </template>
 
 <script>
+import { mapState } from "vuex";
 export default {
   name: "page-answer-recruit-result",
   components: {},
@@ -46,6 +48,9 @@ export default {
   },
   mounted() {},
   computed: {
+    ...mapState({
+      answerRecruitId: state => state.answer.answerRecruitId
+    }),
     accuracyVal() {
       let that = this;
       if (isNaN(that.grades) || isNaN(that.allQuestionsNum)) {

+ 122 - 6
src/views/home/answer/page-answer-recruit.vue

@@ -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;

+ 11 - 5
src/views/home/answer/page-answer-special.vue

@@ -9,7 +9,6 @@
       <van-cell
         v-for="(item, index) in specialAnswerList"
         :key="index"
-        @click="toMaterialDetail(item)"
       >
         <div slot="default" class="contentItemDiv">
           <div>
@@ -34,7 +33,7 @@
 </template>
 
 <script>
-// import { mapState } from "vuex";
+import { mapState } from "vuex";
 export default {
   name: "page-answer-special",
   components: {},
@@ -55,6 +54,9 @@ export default {
   activated() {
   },
   computed: {
+    ...mapState({
+      chooseEngneeringWork: state => state.user.chooseEngneeringWork
+    })
   },
   methods: {
     getSpecialAnswerList() {
@@ -62,12 +64,12 @@ export default {
       this.loading = false;
       let params = {
         page: this.specialPage,
-        size: this.specialSize
+        size: this.specialSize,
+        engineertypeid: this.chooseEngneeringWork.id
       };
       this.$_http
         .get(this.$_API.GET_JTXT_SPECIAL_QUESTIONS, { params })
         .then(res => {
-          console.log("special----" + JSON.stringify(res));
           this.specialAnswerList = [...this.specialAnswerList, ...res.data.content];
           // 不能上拉了就是加载玩了
           this.finished = res.data.last;
@@ -78,11 +80,15 @@ export default {
           this.$store.commit("toggleLoading", false);
         });
     },
-    clickAnswer() {
+    clickAnswer(item) {
       this.$store.commit("updateAnswerItemStore", {
         field: "answerRecruitId",
         value: "special-questions"
       });
+      this.$store.commit("updateAnswerItemStore", {
+        field: "questionId",
+        value: item.id
+      });
       this.$router.push({ name: "answerRecruit" });
     },
     onLoad() {

+ 7 - 3
src/views/home/answer/page-answer-week.vue

@@ -33,7 +33,7 @@
 </template>
 
 <script>
-// import { mapState } from "vuex";
+import { mapState } from "vuex";
 export default {
   name: "page-answer-week",
   components: {},
@@ -54,13 +54,18 @@ export default {
   activated() {
   },
   computed: {
+    ...mapState({
+      chooseEngneeringWork: state => state.user.chooseEngneeringWork
+    })
   },
   methods: {
     getWeekAnswerList() {
+      console.log("-------------" + JSON.stringify(this.chooseEngneeringWork));
       this.loading = true;
       let params = {
         page: this.weeklyPage,
-        size: this.weeklySize
+        size: this.weeklySize,
+        engineertypeid: this.chooseEngneeringWork.id
       };
       this.$_http
         .get(this.$_API.GET_JTXT_WEEKLY_QUESTIONS, { params })
@@ -76,7 +81,6 @@ export default {
         });
     },
     clickAnswer(item) {
-      console.log("----" + JSON.stringify(item));
       this.$store.commit("updateAnswerItemStore", {
         field: "answerRecruitId",
         value: "weekly-questions"