Pārlūkot izejas kodu

修改答题流程问题

dusenyao 1 gadu atpakaļ
vecāks
revīzija
43d31288a2

+ 1 - 1
src/utils/transform.js

@@ -24,7 +24,7 @@ export function zeroFill(val) {
  * @param {'normal'|'chinese'} type 格式类型
  * @returns {String} hh:MM:ss 小于1小时返回 MM:ss
  */
-export function secondFormatConversion(val, type = 'normal') {
+export function secondFormatConversion(val = 0, type = 'normal') {
   const seconds = parseInt(val); // 输入的秒数
   const hours = Math.floor(seconds / 3600); // 小时部分
   const minutes = Math.floor((seconds % 3600) / 60); // 分钟部分

+ 2 - 1
src/views/exercise_questions/answer/components/AnswerReport.vue

@@ -27,7 +27,7 @@
         :key="question_id"
         :class="[
           'answer-list-item',
-          { subjectivity: is_objective === 'false', error: answer_status === 2 },
+          { subjectivity: is_objective === 'false', error: answer_status === 2 || answer_status === 0 },
           { remarked: is_remarked === 'true' },
         ]"
         @click="selectQuestion(i)"
@@ -126,6 +126,7 @@ export default {
       }
 
       &.subjectivity {
+        color: $font-color;
         background-color: #fef2a4;
       }
 

+ 45 - 34
src/views/exercise_questions/answer/index.vue

@@ -18,9 +18,7 @@
 
     <main class="main">
       <StartQuestion
-        v-if="
-          curQuestionIndex === -1 && !(user_answer_record_info.is_exist_answer_record === 'true' && answer_mode === 2)
-        "
+        v-if="curQuestionIndex === -1 && !(user_answer_record_info.is_exist_answer_record === 'true')"
         :question-length="questionList.length"
         :answer-time-limit-minute="answer_time_limit_minute"
         @startAnswer="startAnswer"
@@ -96,11 +94,7 @@
       </el-popover>
 
       <div>
-        <template
-          v-if="
-            curQuestionIndex === -1 && !(user_answer_record_info.is_exist_answer_record === 'true' && answer_mode === 2)
-          "
-        >
+        <template v-if="curQuestionIndex === -1 && !(user_answer_record_info.is_exist_answer_record === 'true')">
           <el-button type="primary" round @click="startAnswer">开始答题</el-button>
         </template>
 
@@ -114,7 +108,7 @@
             v-if="curQuestionIndex === questionList.length - 1 && !isTeacherAnnotations"
             type="primary"
             round
-            @click="submitAnswer"
+            @click="confirmSubmitAnswer"
           >
             提交
           </el-button>
@@ -158,13 +152,17 @@ export default {
   },
   mixins: [PreviewQuestionTypeMixin],
   data() {
-    const { id, share_record_id, answer_record_id, exercise_id, question_index } = this.$route.query;
+    const { id, share_record_id, answer_record_id, exercise_id, question_index, back_url } = this.$route.query;
     let questionIndex = Number(question_index);
 
     return {
       exercise_id: id || exercise_id, // 练习题id
       share_record_id, // 分享记录id
       answer_record_id: answer_record_id ?? '', // 答题记录id
+      back_url:
+        back_url?.length > 0
+          ? decodeURIComponent(back_url)
+          : `${window.location.origin}/GCLS-Learn/#/main?tab=ExerciseList`, // 返回链接
       secondFormatConversion,
       isTeacher: this.$store.getters.isTeacher, // 是否是教师
       user_answer_record_info: {
@@ -214,7 +212,11 @@ export default {
     },
     // 是否显示批注
     isAnnotations() {
-      return this.remark.is_remarked === 'true' || this.isTeacherAnnotations;
+      return (
+        (this.remark.is_remarked === 'true' || this.isTeacherAnnotations) &&
+        this.curQuestionIndex >= 0 &&
+        !this.isSubmit
+      );
     },
     // 是否考试模式
     isExamMode() {
@@ -254,12 +256,11 @@ export default {
             this.answer_time_limit_minute = answer_time_limit_minute;
             this.time = answer_time_limit_minute * 60;
             this.loading = false;
-            // 如果是考试模式,且已经存在答题记录,则直接显示答题报告
+            // 如果已经存在答题记录,则直接显示答题报告
             if (this.user_answer_record_info.is_exist_answer_record === 'true' && !this.isTeacher) {
               this.answer_record_id = this.user_answer_record_info.answer_record_id;
               this.answer_mode = answer_mode;
-              // 如果是考试模式,且已经存在答题记录,则直接显示答题报告
-              if (this.isExamMode) this.isSubmit = true;
+              this.isSubmit = true;
             }
             if (!this.isTeacher) {
               this.getAnswerRecordReport();
@@ -288,7 +289,7 @@ export default {
       GetExerciseQuestionIndexList({ exercise_id: this.exercise_id }).then(({ index_list }) => {
         this.questionList = index_list.map((item) => ({
           ...item,
-          isFill: this.isTeacherAnnotations,
+          isFill: this.isTeacherAnnotations || this.user_answer_record_info.is_exist_answer_record === 'true',
         }));
         if (this.question_index >= 0) {
           this.curQuestionIndex = this.question_index;
@@ -301,7 +302,7 @@ export default {
         this.isView = false;
         return;
       }
-      this.$router.push('/personal_question');
+      window.location.href = this.back_url;
     },
     // 倒计时
     countDown() {
@@ -309,6 +310,7 @@ export default {
         this.time -= 1;
         if (this.time === 0) {
           clearInterval(this.countDownTimer);
+          this.handleSubmitAnswer();
         }
       }, 1000);
     },
@@ -319,6 +321,10 @@ export default {
       }
       StartAnswer({ exercise_id: this.exercise_id, share_record_id: this.share_record_id }).then(
         ({ answer_mode, answer_record_id }) => {
+          this.questionList = this.questionList.map((item) => ({
+            ...item,
+            isFill: false,
+          }));
           this.answer_record_id = answer_record_id;
           this.countDown();
           this.answer_mode = answer_mode;
@@ -371,6 +377,7 @@ export default {
     },
     // 得到答题记录题目信息
     getQuestionInfo_AnswerRecord() {
+      if (this.questionList.length === 0) return;
       GetQuestionInfo_AnswerRecord({
         answer_record_id: this.answer_record_id,
         question_id: this.questionList[this.curQuestionIndex].id,
@@ -400,7 +407,7 @@ export default {
       });
     },
     // 提交答题
-    submitAnswer() {
+    confirmSubmitAnswer() {
       if (!this.answer_record_id) return;
 
       this.$confirm('是否确认提交答题?', '提示', {
@@ -409,27 +416,31 @@ export default {
         type: 'warning',
       })
         .then(() => {
-          clearInterval(this.countDownTimer);
-          // 如果已经填写过答案,直接提交
-          if (this.questionList[this.curQuestionIndex].isFill) {
-            SubmitAnswer({ answer_record_id: this.answer_record_id })
-              .then(() => {
-                this.isSubmit = true;
-              })
-              .catch(() => {});
-            return;
-          }
+          this.handleSubmitAnswer();
+        })
+        .catch(() => {});
+    },
 
-          this.fillQuestionAnswer('next').then(() => {
-            SubmitAnswer({ answer_record_id: this.answer_record_id })
-              .then(() => {
-                this.isSubmit = true;
-              })
-              .catch(() => {});
-          });
+    handleSubmitAnswer() {
+      clearInterval(this.countDownTimer);
+      // 如果已经填写过答案,直接提交
+      if (this.questionList[this.curQuestionIndex].isFill) {
+        this.submitAnswer();
+        return;
+      }
+
+      this.fillQuestionAnswer('next').then(() => {
+        this.submitAnswer();
+      });
+    },
+    submitAnswer() {
+      SubmitAnswer({ answer_record_id: this.answer_record_id })
+        .then(() => {
+          this.isSubmit = true;
         })
         .catch(() => {});
     },
+
     selectQuestion(i) {
       this.isSubmit = false;
       this.isView = true;

+ 2 - 0
src/views/home/recovery/AnswerData.vue

@@ -127,6 +127,8 @@ export default {
         query: {
           exercise_share_record_id,
           answer_record_id,
+          exercise_id: this.searchData.exercise_id,
+          share_record_id: this.searchData.share_record_id,
         },
       });
     },

+ 7 - 3
src/views/home/recovery/AnswerRecordList.vue

@@ -52,7 +52,7 @@
             :key="question_id"
             :class="[
               'answer-list-item',
-              { subjectivity: is_objective === 'false', error: answer_status === 2 },
+              { subjectivity: is_objective === 'false', error: answer_status === 2 || answer_status === 0 },
               { remarked: is_remarked === 'true' },
             ]"
             @click="selectQuestion(i)"
@@ -76,9 +76,10 @@ import { GetUserAnswerRecordList, GetAnswerRecordReport, FinishAnswerRemark, Get
 export default {
   name: 'AnswerRecordList',
   data() {
-    const { exercise_share_record_id, answer_record_id } = this.$route.query;
+    const { exercise_share_record_id, answer_record_id, exercise_id, share_record_id } = this.$route.query;
 
     return {
+      backURL: `/answer_data?exercise_id=${exercise_id}&share_record_id=${share_record_id}`,
       secondFormatConversion,
       exercise_share_record_id,
       answer_record_id,
@@ -148,7 +149,9 @@ export default {
         '_blank',
       );
     },
-    goBack() {},
+    goBack() {
+      this.$router.push(this.backURL);
+    },
     /**
      * 完成批注
      */
@@ -284,6 +287,7 @@ export default {
           }
 
           &.subjectivity {
+            color: $font-color;
             background-color: #fef2a4;
           }
 

+ 9 - 8
src/views/share/ShareExercise.vue

@@ -10,9 +10,11 @@ export default {
   name: 'ShareExercise',
 
   data() {
-    let { share_record_id, answer_record_id, exercise_id, question_index } = this.$route.query;
+    const { query } = this.$route;
+    const { share_record_id, answer_record_id, exercise_id, question_index } = query;
 
     return {
+      query,
       share_record_id,
       answer_record_id: answer_record_id || '',
       question_index: question_index || -1,
@@ -42,17 +44,16 @@ export default {
           if (share_record.access_popedom === 2) {
             this.$router.push({
               path: '/answer',
-              query: {
-                share_record_id: this.share_record_id,
-                answer_record_id: this.answer_record_id,
-                question_index: this.question_index,
-                exercise_id: this.exercise_id,
-              },
+              query: this.query,
             });
           }
         })
         .catch(() => {
-          setItem('temporary_link', `GCLS-Exercise/#/open/share/exercise?share_record_id=${this.share_record_id}`);
+          let link = 'GCLS-Exercise/#/open/share/exercise?';
+          for (const [key, value] of this.query.entries()) {
+            link += `${key}=${value}&`;
+          }
+          setItem('temporary_link', link);
         });
     },
   },