فهرست منبع

feat: 学生做正在进行中题目时提示上次做的信息

ChenYangfan 6 سال پیش
والد
کامیت
1ea4096965
2فایلهای تغییر یافته به همراه26 افزوده شده و 12 حذف شده
  1. 1 1
      src/components/Cards/QuizCard.vue
  2. 25 11
      src/views/quiz/StudentDoQuiz.vue

+ 1 - 1
src/components/Cards/QuizCard.vue

@@ -65,7 +65,7 @@ export default {
         } else {
           return { action: '尚未开题', theme: 'orange' }
         }
-      } else if (this.quiz.state === QuizState.notStart) {
+      } else if (this.quiz.state === QuizState.ongoing) {
         if (!this.isTeacher) {
           return { action: '开始做题', theme: 'green' }
         } else {

+ 25 - 11
src/views/quiz/StudentDoQuiz.vue

@@ -2,7 +2,14 @@
   <div class="do-quiz">
     <back-title>{{ quiz.name }}</back-title>
     <form @submit.prevent="handleFormSubmit">
-      <c-button class="mb-16" theme="green" icon="check">提交答案</c-button>
+      <div class="info">
+        <div>
+          提交次数:
+          <span :class="answersInfo.submitNumber === quiz.maxSubmitTime ? 'red' : null">{{answersInfo.submitNumber}} / {{quiz.maxSubmitTime}}</span>
+        </div>
+        <div>上次得分:{{answersInfo.score}}</div>
+        <div>最近提交:{{momentFromNow(answersInfo.submitAt)}}</div>
+      </div>
       <div class="quiz-list mb-16" :key="question.id" v-for="(question, index) in questions">
         <div class="quiz-list__index">{{ index + 1 }}.</div>
         <div>
@@ -39,6 +46,7 @@ import CButton from '@/components/Basic/CButton'
 import CIcon from '@/components/Basic/CIcon'
 import { getOneQuiz, getOneQuizStudentAnswer, submitQuizStudentAnswer } from '@/server/quiz'
 import { getQuestionsOfQuiz } from '@/server/question'
+import momentFromNow from '@/utils/moment-from-now'
 
 export default {
   name: 'StudentDoQuiz',
@@ -48,6 +56,7 @@ export default {
       quiz: createDefaultQuiz(),
       hasSubmit: false,
       questions: null,
+      answersInfo: null,
 
       QuestionKind
     }
@@ -74,6 +83,7 @@ export default {
         this.questions = res
         // 获取之前填写的答案
         getOneQuizStudentAnswer({ quizId }).then(answers => {
+          this.answersInfo = answers
           this.questions = this.questions.map(question => ({
             ...question,
             studentAnswer: answers.answers[question.id]
@@ -100,27 +110,31 @@ export default {
         this.$setSuccessMessage('提交成功')
         this.$router.go(-1)
       }).catch(err => { this.$setErrorMessage(err.response.data.msg) })
-      // submitQuiz({ quizId, answers: this.quiz.questions })
-      //   .then(() => {
-      //     this.hasSubmit = true
-      //     this.$setSuccessMessage('提交成功')
-      //     this.$router.go(-1)
-      //   })
-      //   .catch(err =>
-      //     this.$setErrorMessage(err.response.data.msg)
-      //   )
-    }
+    },
+    momentFromNow
   }
 }
 </script>
 
 <style lang="scss" scoped>
+@import "~@/style/theme.scss";
 .do-quiz {
   margin: 0 auto;
   max-width: 800px;
   padding: 64px 24px;
 }
 
+.info {
+  line-height: 1.6;
+  color: #7a8a9a;
+  margin-bottom: 24px;
+  background: #f7f7f7;
+  padding: 8px 12px;
+}
+
+.red {
+ color: $theme-red;
+}
 .quiz-list {
   display: flex;