Ver código fonte

川北相关考试修改

cyy 7 meses atrás
pai
commit
567318e151

+ 47 - 14
src/views/platform/examination/question/edit.vue

@@ -55,13 +55,11 @@
           </el-select>
         </el-form-item>
       </div>
-      <div
-        class="inline-item"
-        :class="
-          ['单选题', '多选题', '判断题'].includes(form.ti_xing_) ? 'mb-20' : ''
-        "
-      >
-        <el-form-item prop="ping_fen_fang_shi">
+      <div class="inline-item mb-20">
+        <el-form-item
+          prop="ping_fen_fang_shi"
+          style="margin-bottom: 0 !important"
+        >
           <template slot="label">
             评分方式
             <el-tooltip
@@ -72,7 +70,7 @@
               <i class="el-icon-question question-icon">:</i>
             </el-tooltip>
           </template>
-          <el-radio-group v-model="questionRateType" disabled>
+          <el-radio-group v-model.sync="questionRateType" :disabled="!estimate">
             <el-radio-button label="自动">自动</el-radio-button>
             <el-radio-button label="手动">手动</el-radio-button>
           </el-radio-group>
@@ -275,7 +273,11 @@
           />
           <div v-if="!readonly" class="operate-btn">
             <el-button
-              v-if="index === 0 && optionList.length < 20"
+              v-if="
+                index === 0 &&
+                optionList.length < 20 &&
+                !(estimate && questionRateType === '自动')
+              "
               type="primary"
               :tabindex="-1"
               icon="el-icon-plus"
@@ -283,7 +285,7 @@
               @click="addOption"
             />
             <el-button
-              v-else-if="index === optionList.length - 1"
+              v-else-if="index === optionList.length - 1 && index !== 0"
               type="danger"
               :tabindex="-1"
               icon="el-icon-delete"
@@ -469,15 +471,22 @@ export default {
         ],
         fen_zhi_: [{ required: true, message: this.$t('validate.required') }]
       },
-      optionList: JSON.parse(JSON.stringify(defaultOptions))
+      optionList: JSON.parse(JSON.stringify(defaultOptions)),
+      attachmentTF: false,
+      gapFillingAutomatic: false,
+      questionRateType: ''
     }
   },
   computed: {
     formData() {
       return this.data
     },
-    questionRateType() {
-      return this.rateType[this.form.ti_xing_] || ''
+    estimate() {
+      return (
+        this.attachmentTF &&
+        this.optionList.length === 1 &&
+        this.form.ti_xing_ === '填空题'
+      )
     }
   },
   watch: {
@@ -486,8 +495,30 @@ export default {
         this.dialogVisible = this.visible
       }
       // immediate: true
+    },
+    'form.ti_xing_': {
+      handler: async function (val, oldVal) {
+        if (
+          this.attachmentTF &&
+          this.optionList.length === 1 &&
+          val === '填空题'
+        ) {
+          this.questionRateType = this.form.ping_fen_fang_shi
+        } else {
+          this.questionRateType = this.rateType[val] || ''
+        }
+      },
+      immediate: true
     }
   },
+  created() {
+    this.attachmentTF =
+      this.$store.getters.setting?.examTag?.tagData?.attachmentTF || false
+
+    this.gapFillingAutomatic =
+      this.$store.getters.setting?.examTag?.tagData?.gapFillingAutomatic ||
+      false
+  },
   mounted() {
     this.getQuestionData()
   },
@@ -635,7 +666,9 @@ export default {
           const emptyIndex = this.optionList.findIndex((item) => !item.content)
           if (emptyIndex !== -1) {
             const tip1 = `答案${emptyIndex + 1}内容为空,请填写后再保存!`
-            const tip2 = `选项${String.fromCharCode('A'.charCodeAt(0) + emptyIndex)}内容为空,请填写后再保存!`
+            const tip2 = `选项${String.fromCharCode(
+              'A'.charCodeAt(0) + emptyIndex
+            )}内容为空,请填写后再保存!`
             return ActionUtils.saveErrorMessage(
               questionType === '填空题' ? tip1 : tip2
             )

+ 35 - 2
src/views/platform/examination/question/judge.vue

@@ -45,9 +45,30 @@
                     :key="`${index}${i}`"
                     :value="o"
                     :type="item.questionType === '简答题' ? 'textarea' : 'text'"
-                    :rows="item.questionType === '简答题' ? 12 : 1"
+                    :rows="
+                      item.questionType === '简答题' && item.fuJian
+                        ? 4
+                        : item.questionType === '简答题'
+                        ? 12
+                        : 1
+                    "
                     readonly
                   />
+                  <ibps-attachment
+                    v-if="
+                      item.questionType === '简答题' &&
+                      attachmentTF &&
+                      item.fuJian
+                    "
+                    v-model="item.fuJian"
+                    :download="true"
+                    multiple
+                    accept="*"
+                    :readonly="true"
+                    :limit="5"
+                    :file-size="10 * 1024 * 1024"
+                    style="width: 100%; margin-top: 10px; font-size: 14px"
+                  />
                 </div>
               </div>
               <div class="right">
@@ -164,6 +185,8 @@ import { getSetting } from '@/utils/query'
 
 export default {
   components: {
+    IbpsAttachment: () =>
+      import('@/business/platform/file/attachment/selector'),
     IbpsImage: () => import('@/business/platform/file/image')
   },
   props: {
@@ -220,7 +243,9 @@ export default {
       groupedArray: [], // 答卷id数组
       showIndex: 1,
       groupByUser: false,
-      userId
+      userId,
+      attachmentTF: false,
+      gapFillingAutomatic: false
     }
   },
   computed: {
@@ -294,6 +319,14 @@ export default {
       }
     }
   },
+  created() {
+    this.attachmentTF =
+      this.$store.getters.setting?.examTag?.tagData?.attachmentTF || false
+
+    this.gapFillingAutomatic =
+      this.$store.getters.setting?.examTag?.tagData?.gapFillingAutomatic ||
+      false
+  },
   async mounted() {
     const { tagData, tagName } = (await getSetting('examTag')) || {}
     if (tagData) {

+ 26 - 1
src/views/platform/examination/questionBank/detail.vue

@@ -180,6 +180,19 @@
                       :rows="q.questionType === '简答题' ? 12 : 1"
                       readonly
                     />
+                    <ibps-attachment
+                      v-if="
+                        q.questionType === '简答题' && attachmentTF && q.fuJian
+                      "
+                      v-model="q.fuJian"
+                      :download="true"
+                      multiple
+                      accept="*"
+                      :readonly="true"
+                      :limit="5"
+                      :file-size="10 * 1024 * 1024"
+                      style="width: 100%; margin-top: 10px; font-size: 14px"
+                    />
                   </template>
                 </div>
               </div>
@@ -295,6 +308,8 @@
 import { cloneDeep } from 'lodash'
 export default {
   components: {
+    IbpsAttachment: () =>
+      import('@/business/platform/file/attachment/selector'),
     IbpsImage: () => import('@/business/platform/file/image')
   },
   props: {
@@ -344,7 +359,9 @@ export default {
         3: '#FFFF00',
         4: '#FFA500',
         5: '#FF0000'
-      }
+      },
+      attachmentTF: false,
+      gapFillingAutomatic: false
     }
   },
   computed: {
@@ -382,6 +399,14 @@ export default {
       }
     }
   },
+  created() {
+    this.attachmentTF =
+      this.$store.getters.setting?.examTag?.tagData?.attachmentTF || false
+
+    this.gapFillingAutomatic =
+      this.$store.getters.setting?.examTag?.tagData?.gapFillingAutomatic ||
+      false
+  },
   mounted() {
     this.loadData()
     // 监听键盘事件

+ 90 - 27
src/views/platform/examination/questionBank/test.vue

@@ -80,15 +80,27 @@
                   @blur="textareaFocused = false"
                 />
               </template>
-              <el-input
-                v-else-if="item.questionType === '简答题'"
-                v-model="item.answer"
-                type="textarea"
-                :autosize="{ minRows: 4, maxRows: 8 }"
-                placeholder="请输入您的答案"
-                @focus="textareaFocused = true"
-                @blur="textareaFocused = false"
-              />
+              <div v-else-if="item.questionType === '简答题'">
+                <el-input
+                  v-model="item.answer"
+                  type="textarea"
+                  :autosize="{ minRows: 4, maxRows: 8 }"
+                  placeholder="请输入您的答案"
+                  @focus="textareaFocused = true"
+                  @blur="textareaFocused = false"
+                />
+                <ibps-attachment
+                  v-if="attachmentTF"
+                  v-model="item.fuJian"
+                  :download="true"
+                  multiple
+                  accept="*"
+                  :readonly="false"
+                  :limit="5"
+                  :file-size="10 * 1024 * 1024"
+                  style="width: 100%; margin-top: 10px; font-size: 14px"
+                />
+              </div>
             </div>
           </div>
         </template>
@@ -169,6 +181,8 @@ import { shuffle, round } from 'lodash'
 
 export default {
   components: {
+    IbpsAttachment: () =>
+      import('@/business/platform/file/attachment/selector'),
     IbpsImage: () => import('@/business/platform/file/image')
   },
   props: {
@@ -235,7 +249,9 @@ export default {
       showIndex: 1,
       userId,
       countdownNotify: false,
-      textareaFocused: false // input 聚焦状态
+      textareaFocused: false, // input 聚焦状态
+      attachmentTF: false,
+      gapFillingAutomatic: false
     }
   },
   computed: {
@@ -266,15 +282,18 @@ export default {
     },
     showIndex: {
       handler(val, oldVal) {
-        this.pagination.currentPage = Math.ceil(val / this.pagination.pageSize)
-        this.activeName = this.pagination.currentPage + ''
-        const temp = this.questionList[oldVal - 1]
-        if (['填空题'].includes(temp.questionType)) {
-          temp.answer = temp.options.map((item) => item.answer)
-        }
+        this.handleShowIndex(val, oldVal)
       }
     }
   },
+  created() {
+    this.attachmentTF =
+      this.$store.getters.setting?.examTag?.tagData?.attachmentTF || false
+
+    this.gapFillingAutomatic =
+      this.$store.getters.setting?.examTag?.tagData?.gapFillingAutomatic ||
+      false
+  },
   mounted() {
     this.loadData()
     this.startCountdown()
@@ -290,6 +309,14 @@ export default {
     // Watermark.set('', '')
   },
   methods: {
+    handleShowIndex(val, oldVal) {
+      this.pagination.currentPage = Math.ceil(val / this.pagination.pageSize)
+      this.activeName = this.pagination.currentPage + ''
+      const temp = this.questionList[oldVal - 1]
+      if (['填空题'].includes(temp.questionType)) {
+        temp.answer = temp.options.map((item) => item.answer)
+      }
+    },
     pageRange(pageNo) {
       return {
         start: (pageNo - 1) * this.pagination.pageSize + 1,
@@ -311,7 +338,6 @@ export default {
         return
       }
       this.questionList = await this.getQuestionData()
-      // console.log(this.questionList)
       // console.log(this.examData)
     },
     startCountdown() {
@@ -431,6 +457,7 @@ export default {
               }
               item.img = item.img ? JSON.parse(item.img) : ''
               item.answer = item.questionType === '多选题' ? [] : null
+              item.fuJian = ''
             })
             this.loading = false
             resolve(data)
@@ -445,16 +472,19 @@ export default {
       const finished = []
       this.questionList.forEach((item) => {
         if (item.questionType === '填空题') {
-          console.log('item.answer', item.answer, item.options, item.options.map((op) => op.answer))
           finished.push(
-            item.options && !item.options.some((i) => i.answer === '' || i.answer === null)
+            item.options &&
+              !item.options.some((i) => i.answer === '' || i.answer === null)
           )
         } else if (item.questionType === '多选题') {
           finished.push(item.answer.some((i) => i) && true)
+        } else if (item.questionType === '简答题' && this.attachmentTF) {
+          finished.push((item.answer || item.fuJian) && true)
         } else {
           finished.push(item.answer && true)
         }
       })
+      // console.log(finished, 'finishedfinished')
       // const finished = this.questionList.filter(item => (item.questionType !== '填空题' && item.answer) || (item.questionType === '填空题' && item.answer && !item.answer.some(i => i === '' || i === null))).length
       const finishedCount = finished.filter((i) => i).length
       const progress = round(
@@ -537,13 +567,24 @@ export default {
         this.showIndex++
       }, 200)
     },
-    getScore({ questionType, answer, rightKey, score }) {
+    getScore({ questionType, answer, rightKey, score, options }) {
       if (questionType === '多选题') {
         const temp = rightKey.split(',')
         return answer.length === temp.length &&
           answer.every((i) => temp.includes(i))
           ? score
           : 0
+      } else if (questionType === '填空题') {
+        const rightKeyArr = JSON.parse(rightKey)
+        const goal = Number((score / rightKeyArr.length).toFixed(2))
+        let add = 0
+        options.forEach((item, i) => {
+          const mid = rightKeyArr[i].split(',')
+          if (mid.includes(item.answer)) {
+            add += goal
+          }
+        })
+        return add
       } else {
         return answer === rightKey ? score : 0
       }
@@ -554,11 +595,18 @@ export default {
         this.questionList.forEach((item, index) => {
           if (item.questionType === '填空题') {
             const t =
-              item.options && !item.options.some((i) => i.answer === '' || i.answer === null)
+              item.options &&
+              !item.options.some((i) => i.answer === '' || i.answer === null)
             incompleteList.push(!t ? index + 1 : '')
           } else if (item.questionType === '多选题') {
             const t = item.answer && item.answer.length
             incompleteList.push(!t ? index + 1 : '')
+          } else if (item.questionType === '简答题') {
+            if (this.attachmentTF) {
+              incompleteList.push(!item.answer && !item.fuJian ? index + 1 : '')
+            } else {
+              incompleteList.push(!item.answer ? index + 1 : '')
+            }
           } else {
             incompleteList.push(!item.answer ? index + 1 : '')
           }
@@ -581,12 +629,19 @@ export default {
       }
       // 处理最后一题无法自动提交的bug
       if (
-        this.questionList[this.questionList.length - 1] !== '判断题' &&
-        this.questionList[this.questionList.length - 1] !== '单选题'
+        this.questionList[this.questionList.length - 1].questionType !==
+          '判断题' &&
+        this.questionList[this.questionList.length - 1].questionType !==
+          '单选题'
       ) {
         const temp = this.showIndex
         if (this.showIndex !== this.questionList.length) {
           this.showIndex = this.questionList.length
+        } else if (
+          this.showIndex === this.questionList.length &&
+          this.showIndex === 1
+        ) {
+          this.handleShowIndex(1, 1)
         } else {
           this.showIndex = 1
         }
@@ -605,9 +660,13 @@ export default {
         const autoType = ['单选题', '多选题', '判断题'].includes(
           item.questionType
         )
+        const autoFillType =
+          item.questionType === '填空题' &&
+          item.rateType === '自动' &&
+          this.gapFillingAutomatic
         const multipleType = ['多选题', '填空题'].includes(item.questionType)
         const selectType = ['多选题', '单选题'].includes(item.questionType)
-        submitData.push({
+        let obj = {
           parent_id_: this.id,
           ti_mu_id_: item.questionId,
           ti_gan_: item.stem,
@@ -624,13 +683,17 @@ export default {
             multipleType && item.answer
               ? JSON.stringify(item.answer)
               : item.answer,
-          shi_fou_yi_yue_: autoType ? '是' : '否',
+          shi_fou_yi_yue_: autoType || autoFillType ? '是' : '否',
           ping_yue_shi_jian: autoType ? time : '',
-          de_fen_: autoType ? this.getScore(item) : '',
+          de_fen_: autoType || autoFillType ? this.getScore(item) : '',
           jie_xi_: '',
           nan_du_: item.questionLevel || 0,
           da_an_jie_xi_: item.resolution || ''
-        })
+        }
+        if (this.attachmentTF) {
+          obj['fu_jian_'] = item.fuJian || ''
+        }
+        submitData.push(obj)
       })
       return submitData
     },