Browse Source

总分完善

dusenyao 11 months ago
parent
commit
f176ac4682

+ 9 - 0
src/api/exercise.js

@@ -286,3 +286,12 @@ export function StopShareRecord(data) {
 export function MoveQuestion(data) {
   return http.post(`/TeachingServer/ExerciseManager/MoveQuestion`, data);
 }
+
+/**
+ * 得到练习题总分
+ * @param {object} data
+ * @param {string} data.exercise_id 练习题id
+ */
+export function GetExerciseScore(data) {
+  return http.post(`/TeachingServer/ExerciseManager/GetExerciseScore`, data);
+}

+ 12 - 5
src/views/exercise_questions/create/components/create.vue

@@ -43,7 +43,7 @@
 </template>
 
 <script>
-import { SaveQuestion } from '@/api/exercise';
+import { SaveQuestion, GetExerciseScore } from '@/api/exercise';
 import { timeFormatConversion } from '@/utils/transform';
 import { exerciseTypeList } from '@/views/exercise_questions/data/questionType';
 
@@ -84,6 +84,7 @@ export default {
       recognition: this.recognition,
     };
   },
+  inject: ['exercise_id'],
   props: {
     curIndex: {
       type: Number,
@@ -97,16 +98,13 @@ export default {
       type: Boolean,
       required: true,
     },
-    totalScore: {
-      type: Number,
-      required: true,
-    },
   },
   data() {
     return {
       exerciseTypeList,
       timer: null,
       curSaveDate: '',
+      totalScore: 0, // 当前卷面分
       exerciseComponents: {
         select: SelectQuestion,
         judge: JudgeQuestion,
@@ -141,6 +139,9 @@ export default {
       return this.exerciseComponents[this.indexList[this.curIndex].type];
     },
   },
+  created() {
+    this.getExerciseScore();
+  },
   mounted() {
     this.resetSaveDate();
   },
@@ -222,10 +223,16 @@ export default {
         if (this.curSaveDate !== curDate) {
           this.curSaveDate = curDate;
         }
+        this.getExerciseScore();
       } catch (err) {
         console.log(err);
       }
     },
+    getExerciseScore() {
+      GetExerciseScore({ exercise_id: this.exercise_id }).then(({ score }) => {
+        this.totalScore = score;
+      });
+    },
     /**
      * 智能识别
      * @param {String} text

+ 1 - 4
src/views/exercise_questions/create/index.vue

@@ -38,7 +38,6 @@
       v-loading="loading"
       :cur-index="curIndex"
       :index-list="index_list"
-      :total-score="totalScore"
       :loading="loading"
       @selectExerciseItem="selectExerciseItem"
       @setPreview="setPreview"
@@ -128,7 +127,6 @@ export default {
       back_url: back_url || '/personal_question', // 返回地址
       visible: false, // 选择题目类型弹窗
       importVisible: false, // 一键导入弹窗
-      totalScore: 0, // 总分
     };
   },
   computed: {
@@ -213,9 +211,8 @@ export default {
      */
     getExerciseQuestionIndexList(init = false, isAdd = false) {
       GetExerciseQuestionIndexList({ exercise_id: this.exercise_id })
-        .then(({ index_list, score }) => {
+        .then(({ index_list }) => {
           this.index_list = index_list;
-          this.totalScore = score;
           if (isAdd) {
             this.curIndex = this.index_list.length - 1;
           }