reghao 7 месяцев назад
Родитель
Сommit
da70d00b91

+ 2 - 2
src/api/exam.js

@@ -49,8 +49,8 @@ export function getPapers(param) {
   return get(examApi.getPaper, param)
 }
 
-export function getPaper(paperId) {
-  return get(examApi.getPaper + '/' + paperId)
+export function getPaper(paperId, status) {
+  return get(examApi.getPaper + '/' + paperId + '?status=' + status)
 }
 
 export function getPaperKeyValues() {

+ 52 - 3
src/views/exam/ExamList.vue

@@ -65,10 +65,29 @@
         >
           <template slot-scope="scope">
             <el-button
+              v-if="scope.row.status === 1"
               size="mini"
-              type="warning"
+              type="success"
               @click="prepareExam(scope.$index, scope.row)"
             >去考试</el-button>
+            <el-button
+              v-else-if="scope.row.status === 2"
+              size="mini"
+              type="warning"
+              @click="waitMark(scope.$index, scope.row)"
+            >待批改</el-button>
+            <el-button
+              v-else-if="scope.row.status === 3"
+              size="mini"
+              type="danger"
+              @click="markPaper(scope.$index, scope.row)"
+            >去批改</el-button>
+            <el-button
+              v-else
+              size="mini"
+              type="warning"
+              @click="viewResult(scope.$index, scope.row)"
+            >看结果</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -218,8 +237,38 @@ export default {
       }
     },
     startExam(paperId) {
-      const routeData = this.$router.resolve({ path: '/exam/starts/' + paperId })
-      window.open(routeData.href, '_blank')
+      const routeUrl = this.$router.resolve({
+        path: '/exam/paper/card/' + paperId,
+        query: {
+          status: 2
+        }
+      })
+      window.open(routeUrl.href, '_blank')
+    },
+    waitMark(index, row) {
+      const paperId = row.examId
+      this.$message.info('待批改 -> ' + paperId)
+    },
+    markPaper(index, row) {
+      const paperId = row.examId
+      const routeUrl = this.$router.resolve({
+        path: '/exam/paper/card/' + paperId,
+        query: {
+          status: 3
+        }
+      })
+      window.open(routeUrl.href, '_blank')
+    },
+    viewResult(index, row) {
+      const paperId = row.examId
+      this.$message.info('查看结果 -> ' + paperId)
+      const routeUrl = this.$router.resolve({
+        path: '/exam/paper/card/' + paperId,
+        query: {
+          status: 4
+        }
+      })
+      window.open(routeUrl.href, '_blank')
     }
   }
 }

+ 7 - 2
src/views/exam/ExamPaper.vue

@@ -198,8 +198,13 @@ export default {
     },
     previewPaper(index, row) {
       const paperId = row.examId
-      const routeData = this.$router.resolve({ path: '/exam/preview/' + paperId })
-      window.open(routeData.href, '_blank')
+      const routeUrl = this.$router.resolve({
+        path: '/exam/paper/card/' + paperId,
+        query: {
+          status: 1
+        }
+      })
+      window.open(routeUrl.href, '_blank')
     }
   }
 }

+ 6 - 32
src/views/exam/ExamQuestion.vue

@@ -495,38 +495,12 @@ export default {
       },
       // 试题类型
       questionType: [
-        {
-          id: 1,
-          name: '单选题'
-        },
-        {
-          id: 2,
-          name: '多选题'
-        },
-        {
-          id: 3,
-          name: '不定项选择题'
-        },
-        {
-          id: 4,
-          name: '判断题'
-        },
-        {
-          id: 5,
-          name: '填空题'
-        },
-        {
-          id: 6,
-          name: '问答题'
-        },
-        {
-          id: 7,
-          name: '理解题'
-        },
-        {
-          id: 8,
-          name: '組题'
-        }
+        { id: 1, name: '单选题' },
+        { id: 2, name: '多选题' },
+        { id: 3, name: '判断题' },
+        { id: 4, name: '填空题' },
+        { id: 5, name: '问答题' },
+        { id: 6, name: '组合题' }
       ],
       // 题库信息
       allSubject: [],

+ 10 - 42
src/views/exam/ExamQuestionAdd.vue

@@ -45,12 +45,6 @@
               </el-select>
             </el-form-item>
             <el-form-item label="试题内容" label-width="120px" prop="questionContent">
-              <!--              <el-input
-                              v-model="addQuForm.questionContent"
-                              style="margin-left: 5px"
-                              type="textarea"
-                              :rows="5"
-                            />-->
               <editor id="tinymce" v-model="addQuForm.questionContent" :init="init" />
             </el-form-item>
             <el-form-item label="试题解析" label-width="120px" prop="analysis">
@@ -61,7 +55,7 @@
                 :rows="5"
               />
             </el-form-item>
-            <div v-if="addQuForm.questionType <= 3">
+            <div v-if="addQuForm.questionType <= 2">
               <el-button
                 type="primary"
                 plain
@@ -110,7 +104,7 @@
                 </el-table>
               </el-form-item>
             </div>
-            <div v-else-if="addQuForm.questionType === 4">
+            <div v-else-if="addQuForm.questionType === 3">
               <el-form-item label="试题答案" label-width="120px" prop="option">
                 <el-radio-group v-model="answerContent4" @change="onRadioChange">
                   <el-radio :label="0">正确</el-radio>
@@ -118,7 +112,7 @@
                 </el-radio-group>
               </el-form-item>
             </div>
-            <div v-else-if="addQuForm.questionType === 5">
+            <div v-else-if="addQuForm.questionType === 4 || addQuForm.questionType === 5">
               <el-button
                 type="primary"
                 plain
@@ -161,7 +155,7 @@
                 </el-table>
               </el-form-item>
             </div>
-            <div v-else-if="addQuForm.questionType === 8">
+            <div v-else-if="addQuForm.questionType === 6">
               <el-button
                 type="primary"
                 plain
@@ -347,38 +341,12 @@ export default {
       },
       // 试题类型
       questionType: [
-        {
-          id: 1,
-          name: '单选题'
-        },
-        {
-          id: 2,
-          name: '多选题'
-        },
-        {
-          id: 3,
-          name: '不定项选择题'
-        },
-        {
-          id: 4,
-          name: '判断题'
-        },
-        {
-          id: 5,
-          name: '填空题'
-        },
-        {
-          id: 6,
-          name: '问答题'
-        },
-        {
-          id: 7,
-          name: '理解题'
-        },
-        {
-          id: 8,
-          name: '組题'
-        }
+        { id: 1, name: '单选题' },
+        { id: 2, name: '多选题' },
+        { id: 3, name: '判断题' },
+        { id: 4, name: '填空题' },
+        { id: 5, name: '问答题' },
+        { id: 6, name: '组合题' }
       ],
       // 题库信息
       allSubject: [],

+ 174 - 84
src/views/exam/ExamQuestionCard.vue

@@ -18,9 +18,12 @@
               <el-card class="box-card">
                 <div class="text item">
                   <span v-html="item1.questionContent" />
+                  <div v-for="(option, optionIndex) in item1.questionOptions" :key="optionIndex">
+                    <span v-html="option.content" />
+                  </div>
                   <el-divider />
                   <el-radio-group
-                    v-model="userAnswerMap[item1.questionId][0]"
+                    v-model="userAnswerMap[item1.questionId].submitAnswer[0]"
                     @change="(val) => {
                       onRadioChange(val, item1)
                     }"
@@ -30,65 +33,115 @@
                     <el-radio :label="3">C</el-radio>
                     <el-radio :label="4">D</el-radio>
                   </el-radio-group>
+                  <el-row v-if="status !== 2">
+                    <el-divider />
+                    <el-row>
+                      <span style="color: red">正确答案</span>
+                    </el-row>
+                    <el-row v-for="(item2, index2) in userAnswerMap[item1.questionId].correctAnswer" :key="index2">
+                      {{ item2 }}
+                    </el-row>
+                  </el-row>
                 </div>
               </el-card>
             </div>
-            <el-divider />
           </div>
-          <div v-else-if="key === '2' || key === '3'">
+          <div v-else-if="key === '2'">
             <h1>多项选择题/不定项选择题</h1>
             <div v-for="(item1, index1) in values" :key="index1">
-              <span v-html="item1.questionContent" />
-              <el-checkbox-group
-                v-model="userAnswerMap[item1.questionId]"
-                @change="(val) => {
-                  onCheckboxChange(val, item1)
-                }"
-              >
-                <el-checkbox label="1">A</el-checkbox>
-                <el-checkbox label="2">B</el-checkbox>
-                <el-checkbox label="3">C</el-checkbox>
-                <el-checkbox label="4">D</el-checkbox>
-              </el-checkbox-group>
+              <el-card class="box-card">
+                <div class="text item">
+                  <span v-html="item1.questionContent" />
+                  <div v-for="(option, optionIndex) in item1.questionOptions" :key="optionIndex">
+                    <span v-html="option.content" />
+                  </div>
+                  <el-divider />
+                  <el-checkbox-group
+                    v-model="userAnswerMap[item1.questionId].submitAnswer"
+                    @change="(val) => {
+                      onCheckboxChange(val, item1)
+                    }"
+                  >
+                    <el-checkbox label="1">A</el-checkbox>
+                    <el-checkbox label="2">B</el-checkbox>
+                    <el-checkbox label="3">C</el-checkbox>
+                    <el-checkbox label="4">D</el-checkbox>
+                  </el-checkbox-group>
+                  <el-row v-if="status !== 2">
+                    <el-divider />
+                    <el-row>
+                      <span style="color: red">正确答案</span>
+                    </el-row>
+                    <el-row v-for="(item2, index2) in userAnswerMap[item1.questionId].correctAnswer" :key="index2">
+                      {{ item2 }}
+                    </el-row>
+                  </el-row>
+                </div>
+              </el-card>
             </div>
             <el-divider />
           </div>
-          <div v-else-if="key === '4'">
+          <div v-else-if="key === '3'">
             <h1>判断题</h1>
             <div v-for="(item1, index1) in values" :key="index1">
-              <span v-html="item1.questionContent" />
-              <el-radio-group
-                v-model="userAnswerMap[item1.questionId][0]"
-                @change="(val) => {
-                  onRadioChange(val, item1)
-                }"
-              >
-                <el-radio :label="1">正确</el-radio>
-                <el-radio :label="2">错误</el-radio>
-              </el-radio-group>
+              <el-card class="box-card">
+                <div class="text item">
+                  <span v-html="item1.questionContent" />
+                  <el-radio-group
+                    v-model="userAnswerMap[item1.questionId].submitAnswer[0]"
+                    @change="(val) => {
+                      onRadioChange(val, item1)
+                    }"
+                  >
+                    <el-radio :label="1">正确</el-radio>
+                    <el-radio :label="2">错误</el-radio>
+                  </el-radio-group>
+                  <el-row v-if="status !== 2">
+                    <el-divider />
+                    <el-row>
+                      <span style="color: red">正确答案</span>
+                    </el-row>
+                    <el-row>
+                      {{ userAnswerMap[item1.questionId].correctAnswer[0] }}
+                    </el-row>
+                  </el-row>
+                </div>
+              </el-card>
             </div>
             <el-divider />
           </div>
-          <div v-else-if="key === '5'">
+          <div v-else-if="key === '4'">
             <h1>填空题</h1>
             <div v-for="(item1, index1) in values" :key="index1">
-              <span v-html="item1.questionContent" />
-              <div v-for="(item2, index2) in userAnswerMap[item1.questionId]" :key="index2">
-                <span style="left: 0;margin-right: 1px;color: black;">第 {{ index2 + 1 }} 题</span>
-                <el-input
-                  v-model="userAnswerMap[item1.questionId][index2]"
-                  type="text"
-                  placeholder="请输入答案"
-                  style="width: 20%; padding-right: 2px"
-                  @blur="(val) => {
-                    onInputBlur(val, item1)
-                  }"
-                />
-              </div>
+              <el-card class="box-card">
+                <div class="text item">
+                  <span v-html="item1.questionContent" />
+                  <div v-for="(item2, index2) in userAnswerMap[item1.questionId].submitAnswer" :key="index2">
+                    <span style="left: 0;margin-right: 1px;color: black;">第 {{ index2 + 1 }} 题</span>
+                    <el-input
+                      v-model="userAnswerMap[item1.questionId].submitAnswer[index2]"
+                      type="text"
+                      placeholder="请输入答案"
+                      style="width: 20%; padding-right: 2px"
+                      @blur="(val) => {
+                        onInputBlur(val, item1)
+                      }"
+                    />
+                  </div>
+                  <el-row v-if="status !== 2">
+                    <el-divider />
+                    <el-row>
+                      <span style="color: red">正确答案</span>
+                    </el-row>
+                    <el-row>
+                      {{ userAnswerMap[item1.questionId].correctAnswer[0] }}
+                    </el-row>
+                  </el-row>
+                </div>
+              </el-card>
             </div>
-            <el-divider />
           </div>
-          <div v-else-if="key === '6'">
+          <div v-else-if="key === '5'">
             <h1>问答题</h1>
             <div v-for="(item1, index1) in values" :key="index1" class="movie-list">
               <el-card class="box-card">
@@ -97,26 +150,43 @@
                   <el-divider />
                   <editor
                     :id="item1.questionId+''"
-                    v-model="userAnswerMap[item1.questionId][0]"
+                    v-model="userAnswerMap[item1.questionId].submitAnswer[0]"
                     :init="init"
                     style="width: 50%"
                   />
+                  <el-row v-if="status !== 2">
+                    <el-divider />
+                    <el-row>
+                      <span style="color: red">正确答案</span>
+                    </el-row>
+                    <el-row>
+                      {{ userAnswerMap[item1.questionId].correctAnswer[0] }}
+                    </el-row>
+                  </el-row>
                 </div>
               </el-card>
             </div>
             <el-divider />
           </div>
-          <div v-else-if="key === '8'">
+          <div v-else-if="key === '6'">
             <h1>组合题</h1>
             <div v-for="(item1, index1) in values" :key="index1">
-              <span v-html="item1.questionContent" />
+              <el-card class="box-card">
+                <div class="text item">
+                  <span v-html="item1.questionContent" />
+                </div>
+              </el-card>
             </div>
             <el-divider />
           </div>
           <div v-else>
             <h1>未知试题类型</h1>
             <div v-for="(item1, index1) in values" :key="index1">
-              <span v-html="item1.questionContent" />
+              <el-card class="box-card">
+                <div class="text item">
+                  <span v-html="item1.questionContent" />
+                </div>
+              </el-card>
             </div>
             <el-divider />
           </div>
@@ -188,12 +258,10 @@ export default {
       questionTypeList: [
         { id: 1, name: '单选题' },
         { id: 2, name: '多选题' },
-        { id: 3, name: '不定项选择题' },
-        { id: 4, name: '判断题' },
-        { id: 5, name: '填空题' },
-        { id: 6, name: '问答题' },
-        { id: 7, name: '理解题' },
-        { id: 8, name: '組题' }
+        { id: 3, name: '判断题' },
+        { id: 4, name: '填空题' },
+        { id: 5, name: '问答题' },
+        { id: 6, name: '组合题' }
       ],
       examInfo: null,
       questionMap: null,
@@ -205,8 +273,10 @@ export default {
       ],
       userAnswerMap: null,
       paperId: 0,
+      status: 0,
       paperInfo: {
         name: '',
+        status: 0,
         duration: 0,
         totalScore: 0
       },
@@ -217,9 +287,19 @@ export default {
   },
   created() {
     document.title = '试卷详情'
-
     this.paperId = this.$route.params.paperId
-    this.getPaperDetail(this.paperId)
+    const statusStr = this.$route.query.status
+    this.status = parseInt(statusStr)
+    if (this.status === 1) {
+      document.title = '试卷预览'
+    } else if (this.status === 2) {
+    } else if (this.status === 3) {
+      document.title = '试卷批改'
+    } else if (this.status === 4) {
+      document.title = '试卷结果'
+    }
+
+    this.getPaperDetail()
   },
   methods: {
     renderByMathjax() {
@@ -232,11 +312,12 @@ export default {
         this.MathJax.MathQueue1(className)
       })
     },
-    getPaperDetail(paperId) {
-      getPaper(paperId).then((resp) => {
+    getPaperDetail() {
+      getPaper(this.paperId, this.status).then((resp) => {
         if (resp.code === 0) {
           const respData = resp.data
           this.paperInfo.name = respData.name
+          this.paperInfo.status = respData.status
           this.paperInfo.duration = respData.duration
           this.paperInfo.totalScore = respData.totalScore
 
@@ -246,6 +327,13 @@ export default {
         } else {
           this.$message.error(resp.msg)
         }
+      }).catch((error) => {
+        this.$notify({
+          title: 'Tips',
+          message: error.message,
+          type: 'error',
+          duration: 2000
+        })
       })
     },
     onSubmitPaper() {
@@ -254,12 +342,34 @@ export default {
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
-        this.submitPaper()
-        this.$notify({
-          title: 'Tips',
-          message: '试卷已提交, 继续加油! *^▽^*',
-          type: 'success',
-          duration: 2000
+        var userAnswers = []
+        for (const key in this.userAnswerMap) {
+          const userAnswer = {}
+          userAnswer.questionId = key
+          userAnswer.answers = this.userAnswerMap[key]
+          userAnswers.push(this.userAnswerMap[key])
+        }
+
+        var userResult = {}
+        userResult.paperId = this.paperId
+        userResult.userAnswers = userAnswers
+        submitExam(userResult).then(resp => {
+          if (resp.code === 0) {
+            this.$notify({
+              title: 'Tips',
+              message: '试卷已提交, 继续加油! *^▽^*',
+              type: 'success',
+              duration: 2000
+            })
+            this.$router.push('/exam/list')
+          }
+        }).catch((error) => {
+          this.$notify({
+            title: 'Tips',
+            message: error.message,
+            type: 'error',
+            duration: 2000
+          })
         })
       }).catch(() => {
         this.$notify({
@@ -291,8 +401,8 @@ export default {
       for (const key in this.userAnswerMap) {
         const userAnswer = {}
         userAnswer.questionId = key
-        userAnswer.answers = this.userAnswerMap[key]
-        userAnswers.push(userAnswer)
+        userAnswer.submitAnswer = this.userAnswerMap[key]
+        userAnswers.push(this.userAnswerMap[key])
       }
 
       var userResult = {}
@@ -305,26 +415,6 @@ export default {
       }).catch((e) => {
         console.log(e)
       })
-    },
-    submitPaper() {
-      var userAnswers = []
-      for (const key in this.userAnswerMap) {
-        const userAnswer = {}
-        userAnswer.questionId = key
-        userAnswer.answers = this.userAnswerMap[key]
-        userAnswers.push(userAnswer)
-      }
-
-      var userResult = {}
-      userResult.paperId = this.paperId
-      userResult.userAnswers = userAnswers
-      submitExam(userResult).then(resp => {
-        if (resp.code !== 0) {
-          console.log(resp.msg)
-        }
-      }).catch((e) => {
-        console.log(e)
-      })
     }
   }
 }