lex 2 years ago
parent
commit
c365100cc7

+ 2 - 1
src/components/o-sticky/index.tsx

@@ -24,7 +24,8 @@ export default defineComponent({
       divStyle: {} as any,
       sectionStyle: {
         width: '100%',
-        height: 'auto'
+        height: 'auto',
+        left: '0'
       }
     }
   },

+ 42 - 41
src/school/companion-teacher/companion-teacher-register.tsx

@@ -44,7 +44,7 @@ export default defineComponent({
       id: route.query.id,
       name: route.query.name,
       t: route.query.t as any, // 过期时间
-      qrCodeStatus: false, // 二维码是否失效
+      // qrCodeStatus: false, // 二维码是否失效
       pattern: /^1(3|4|5|6|7|8|9)\d{9}$/,
       columns: [] as any,
       pickerType: null, // 下拉类型
@@ -77,15 +77,15 @@ export default defineComponent({
     })
 
     const onSubmit = async () => {
-      if (state.qrCodeStatus) {
-        showDialog({
-          title: '提示',
-          message: '二维码已失效',
-          theme: 'round-button',
-          confirmButtonColor: '#ff8057'
-        })
-        return
-      }
+      // if (state.qrCodeStatus) {
+      //   showDialog({
+      //     title: '提示',
+      //     message: '二维码已失效',
+      //     theme: 'round-button',
+      //     confirmButtonColor: '#ff8057'
+      //   })
+      //   return
+      // }
       if (!state.checked) {
         showToast('请阅读并同意协议')
         return
@@ -198,37 +198,6 @@ export default defineComponent({
       //   return
       // }
 
-      // t: route.query.t, // 过期时间
-      try {
-        // await request.post('/api-school/open/schoolTeacherStudent/queryQrCodeStatus', {
-        //   data: {
-        //     schoolId: state.id,
-        //     qrCodeEffectiveStartTime: state.t ? dayjs(state.t).format('YYYY-MM-DD HH:mm:ss') : null
-        //   }
-        // })
-        if (state.t) {
-          const { data } = await request.get('/api-school/open/paramConfig/queryByParamName', {
-            requestType: 'form',
-            params: {
-              paramName: 'qr_code_expire_hours'
-            }
-          })
-          if (dayjs(Number(state.t)).add(data.paramValue, 'hour').isBefore(dayjs())) {
-            showDialog({
-              title: '提示',
-              message: '二维码已失效',
-              theme: 'round-button',
-              confirmButtonColor: '#ff8057'
-            })
-            state.qrCodeStatus = true
-          } else {
-            state.qrCodeStatus = false
-          }
-        }
-      } catch {
-        //
-      }
-
       try {
         const tempareas: any = []
         areas.forEach((item) => {
@@ -272,6 +241,38 @@ export default defineComponent({
           confirmButtonColor: '#ff8057'
         })
       }
+
+      // t: route.query.t, // 过期时间
+      try {
+        await request.post('/api-school/open/schoolTeacherStudent/queryQrCodeStatus', {
+          data: {
+            schoolId: state.id
+            // qrCodeEffectiveStartTime: state.t ? dayjs(state.t).format('YYYY-MM-DD HH:mm:ss') : null
+          }
+        })
+        // if (state.t) {
+        //   const { data } = await request.get('/api-school/open/paramConfig/queryByParamName', {
+        //     requestType: 'form',
+        //     params: {
+        //       paramName: 'qr_code_expire_hours'
+        //     }
+        //   })
+        //   if (dayjs(Number(state.t)).add(data.paramValue, 'hour').isBefore(dayjs())) {
+        // showDialog({
+        //   title: '提示',
+        //   message: '二维码已失效',
+        //   theme: 'round-button',
+        //   confirmButtonColor: '#ff8057'
+        // })
+        //     state.qrCodeStatus = true
+        //   } else {
+        //     state.qrCodeStatus = false
+        //   }
+        // }
+      } catch (e: any) {
+        //
+        console.log(e)
+      }
     })
 
     const onPreview = () => {

+ 7 - 3
src/school/manage-teacher/manage-detail.tsx

@@ -8,6 +8,7 @@ import styles from './manage-detail.module.less'
 import MenuFunction from './menu-function'
 import iconTeacher from '@common/images/icon_teacher.png'
 import OSticky from '@/components/o-sticky'
+import { state as baseState } from '@/state'
 
 export default defineComponent({
   name: 'manage-detail',
@@ -120,9 +121,12 @@ export default defineComponent({
             class={['btnGroup', 'btnMore']}
             style={{ paddingLeft: '13px', paddingRight: '13px' }}
           >
-            <Button type="primary" round onClick={() => (state.menuStatus = true)}>
-              修改权限
-            </Button>
+            {baseState.user.data.manageAdmin && (
+              <Button type="primary" round onClick={() => (state.menuStatus = true)}>
+                修改权限
+              </Button>
+            )}
+
             <Button
               type="primary"
               round

+ 66 - 44
src/views/unit-test/examination-mode/index.tsx

@@ -123,9 +123,7 @@ export default defineComponent({
       try {
         const questionList = state.questionList || []
         const userAnswerList: any = [] // 所有题目的答案
-
-        let currentResult = false // 当前题目是否已经答题
-
+        // let currentResult = false // 当前题目是否已经答题
         questionList.forEach((question: any, index: number) => {
           // 格式化所有题目的答案
           if (question.userAnswer && question.userAnswer.length > 0) {
@@ -135,61 +133,84 @@ export default defineComponent({
             })
           }
 
-          if (index === state.currentIndex) {
-            currentResult = question.userAnswer && question.userAnswer.length > 0 ? true : false
-          }
+          // if (index === state.currentIndex) {
+          //   currentResult = question.userAnswer && question.userAnswer.length > 0 ? true : false
+          // }
         })
 
-        // 判断是否答题了
-        if (!currentResult) {
-          swipeRef.value?.next()
+        // 判断是否是最后一题
+        console.log(state.questionList.length, state.currentIndex)
+        if (state.questionList.length === state.currentIndex + 1) {
+          state.visiableSure = true
           return
         }
 
+        // 判断是否答题了 - 由于连线题
+        // if (!currentResult) {
+        //   swipeRef.value?.next()
+        //   return
+        // }
+
         state.nextStatus = true
-        // 判断是否是最后一题
-        if (state.questionList.length === state.currentIndex + 1) {
-          // api-student/studentUnitExamination/completionExamination
-          const { data } = await request.post(
-            '/api-student/studentUnitExamination/completionExamination',
-            {
-              data: {
-                answers: userAnswerList,
-                studentUnitExaminationId: state.id
-              }
-            }
-          )
-          if (data.score >= state.examDetail.passScore) {
-            state.resultStatusType = 'SUCCESS'
-            state.resultInfo = {
-              tips: '恭喜你,测验通过!',
-              score: data.score,
-              examName: data.unitExaminationName
-            }
-          } else {
-            state.resultStatusType = 'FAIL'
-            state.resultInfo = {
-              tips: '本次测验不合格!',
-              score: data.score,
-              examName: data.unitExaminationName
-            }
+        await request.post('/api-student/studentUnitExamination/submitAnswer', {
+          hideLoading: true,
+          data: {
+            answers: userAnswerList,
+            studentUnitExaminationId: state.id
           }
-          state.visiableResult = true
-        } else {
-          await request.post('/api-student/studentUnitExamination/submitAnswer', {
-            hideLoading: true,
+        })
+        swipeRef.value?.next()
+
+        state.nextStatus = false
+      } catch {
+        //
+        state.nextStatus = false
+      }
+    }
+
+    /**
+     * @description 提交最终答案
+     */
+    const onConfirmExam = async () => {
+      try {
+        const questionList = state.questionList || []
+        const userAnswerList: any = [] // 所有题目的答案
+        questionList.forEach((question: any) => {
+          // 格式化所有题目的答案
+          if (question.userAnswer && question.userAnswer.length > 0) {
+            userAnswerList.push({
+              questionId: question.id,
+              details: question.userAnswer
+            })
+          }
+        })
+        const { data } = await request.post(
+          '/api-student/studentUnitExamination/completionExamination',
+          {
             data: {
               answers: userAnswerList,
               studentUnitExaminationId: state.id
             }
-          })
-          swipeRef.value?.next()
+          }
+        )
+        if (data.status === 'A_PASS') {
+          state.resultStatusType = 'SUCCESS'
+          state.resultInfo = {
+            tips: '恭喜你,测验通过!',
+            score: data.score,
+            examName: state.examDetail.unitExaminationName
+          }
+        } else {
+          state.resultStatusType = 'FAIL'
+          state.resultInfo = {
+            tips: '本次测验不合格!',
+            score: data.score,
+            examName: state.examDetail.unitExaminationName
+          }
         }
-
-        state.nextStatus = false
+        state.visiableResult = true
       } catch {
         //
-        state.nextStatus = false
       }
     }
 
@@ -348,6 +369,7 @@ export default defineComponent({
           showCancelButton
           cancelButtonText="再等等"
           confirmButtonText="确认完成"
+          onConfirm={onConfirmExam}
         />
 
         <ODialog

+ 23 - 0
src/views/unit-test/index.module.less

@@ -58,6 +58,29 @@
       font-size: 13px;
       color: #777777;
     }
+
+    .unitInformation {
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+
+      & > span {
+        flex: 0 auto;
+        flex-shrink: 0;
+        font-family: 'DINA';
+        font-size: 26px;
+        font-weight: bold;
+        color: #f44541;
+        line-height: 30px;
+        i {
+          padding-left: 2px;
+          font-style: normal;
+          font-size: 14px;
+          color: #333333;
+          line-height: 20px;
+        }
+      }
+    }
   }
 
   .unitBtnGroup {

+ 39 - 17
src/views/unit-test/index.tsx

@@ -102,6 +102,11 @@ export default defineComponent({
       }
     }
 
+    // 查看测验
+    const onUnitTestLook = (item: any) => {
+      //
+    }
+
     const onExamStart = async () => {
       try {
         await request.post('/api-student/studentUnitExamination/startExamination', {
@@ -210,34 +215,51 @@ export default defineComponent({
                     {{
                       title: () => (
                         <div class={styles.unitInformation}>
-                          <div class={styles.name}>{item.orchestraName}</div>
-                          <div class={styles.endTime}>
-                            截止时间:
-                            {dayjs(item.expiryDate || new Date()).format('YYYY-MM-DD HH:mm')}
+                          <div>
+                            <div class={styles.name}>{item.orchestraName}</div>
+                            <div class={styles.endTime}>
+                              截止时间:
+                              {dayjs(item.expiryDate || new Date()).format('YYYY-MM-DD HH:mm')}
+                            </div>
                           </div>
+                          {item.status === 'A_PASS' || item.status === 'B_NO_PASS' ? (
+                            <span>
+                              {item.score || 0}
+                              <i>分</i>
+                            </span>
+                          ) : (
+                            ''
+                          )}
+                        </div>
+                      ),
 
-                          <div class={styles.unitBtnGroup}>
-                            <Button
-                              color="#FFF0E6"
-                              round
-                              block
-                              style={{ color: '#F67146' }}
-                              onClick={() => {
-                                router.push('/test-exercise')
-                              }}
-                            >
-                              练习模式
+                      label: () => (
+                        <div class={styles.unitBtnGroup}>
+                          <Button
+                            color="#FFF0E6"
+                            round
+                            block
+                            style={{ color: '#F67146' }}
+                            onClick={() => {
+                              router.push('/test-exercise')
+                            }}
+                          >
+                            练习模式
+                          </Button>
+                          {item.status === 'A_PASS' || item.status === 'B_NO_PASS' ? (
+                            <Button type="primary" round block onClick={() => onUnitTestLook(item)}>
+                              查看测验
                             </Button>
+                          ) : (
                             <Button
                               type="primary"
                               round
                               block
-                              disabled={item.status === 'A_PASS' || item.status === 'B_NO_PASS'}
                               onClick={() => onUnitTestStart(item)}
                             >
                               {item.status === 'C_ING' ? '继续测验' : '开始测验'}
                             </Button>
-                          </div>
+                          )}
                         </div>
                       )
                     }}

+ 57 - 8
src/views/unit-test/model/keep-look-question/index.tsx

@@ -282,15 +282,16 @@ export default defineComponent({
 
     const initOptions = () => {
       const answers = props.data.answers || []
+      const userAnswer = props.data.userAnswer || [] // 用户填写的答案
       answers.forEach((answer: any) => {
         const tmp = {
-          index: answer.examinationQuestionAnswerId,
-          leftValue: answer.questionAnswer,
-          rightValue: answer.questionExtra,
-          leftType: answer.questionAnswerTypeCode || 'TXT',
-          rightType: answer.questionExtraTypeCode || 'TXT',
-          left: false,
-          right: false,
+          index: answer.examinationQuestionAnswerId, // 左边的值
+          leftValue: answer.questionAnswer, // 左边的值
+          rightValue: answer.questionExtra, // 右边的值
+          leftType: answer.questionAnswerTypeCode || 'TXT', // 左边类型
+          rightType: answer.questionExtraTypeCode || 'TXT', // 右边类型
+          left: false, // 左边是否选中
+          right: false, // 右边是否选中
           leftLocked: false, // 是否已经连线
           rightLocked: false // 是否已经连线
         }
@@ -298,7 +299,53 @@ export default defineComponent({
         state.options.push(tmp)
       })
 
-      console.log(state.options)
+      // 反显答案-初始化数据
+      userAnswer.forEach((user: any) => {
+        console.log(user)
+        const temps: any = {
+          startPoint: { x: 0, y: 0 },
+          endPoint: { x: 0, y: 0 },
+          leftIndex: 0,
+          rightIndex: 0
+        }
+        state.options.forEach((option: any) => {
+          // 左边状态
+          if (option.index === user.answerId) {
+            option.left = true
+            option.leftLocked = true
+            temps.leftIndex = option.index
+          }
+          // 右边状态
+          if (option.rightValue === user.extra) {
+            option.right = true
+            option.leftLocked = true
+            temps.rightIndex = option.index
+          }
+        })
+        state.drawLineList.push(temps)
+      })
+
+      console.log(state.drawLineList, state.options)
+      // 反显答案-连线
+      nextTick(() => {
+        state.drawLineList.forEach((draw: any) => {
+          state.selectItem = []
+          const leftObj: any = useRect(document.getElementById(draw.leftIndex + '-left') as any)
+          leftObj.index = draw.leftIndex
+          state.selectItem[0] = leftObj
+          const rightObj: any = useRect(document.getElementById(draw.leftIndex + '-right') as any)
+          rightObj.index = draw.rightIndex
+          state.selectItem[1] = rightObj
+
+          const postion = calcPoint()
+          draw.endPoint = postion.endPoint
+          draw.startPoint = postion.startPoint
+          state.selectItem = []
+        })
+        setTimeout(() => {
+          renderDrawLine(canvasRef.value)
+        }, 60)
+      })
     }
 
     onMounted(() => {
@@ -335,6 +382,7 @@ export default defineComponent({
             <div class={styles.answerItem}>
               <div
                 class={[styles.unitItem, item.left && styles.active]}
+                id={item.index + '-left'}
                 onClick={(e: any) => onLeftClick(e, item)}
               >
                 {item.leftType === 'TXT' && item.leftValue}
@@ -342,6 +390,7 @@ export default defineComponent({
               </div>
               <div
                 class={[styles.unitItem, item.right && styles.active]}
+                id={item.index + '-right'}
                 onClick={(e: any) => onRightClick(e, item)}
               >
                 {item.rightType === 'TXT' && item.rightValue}

+ 9 - 9
src/views/unit-test/unit-list/models/unit-student-list.tsx

@@ -52,15 +52,15 @@ export default defineComponent({
       },
       oldValue: ''
     })
-    const gotoMsg = () => {
-      postMessage({
-        api: 'joinChatGroup',
-        content: {
-          type: 'multi', // single 单人 multi 多人
-          id: props.item?.imGroupId
-        }
-      })
-    }
+    // const gotoMsg = () => {
+    //   postMessage({
+    //     api: 'joinChatGroup',
+    //     content: {
+    //       type: 'multi', // single 单人 multi 多人
+    //       id: props.item?.imGroupId
+    //     }
+    //   })
+    // }
     onMounted(() => {
       getList()
     })

+ 22 - 1
src/views/unit-test/unit-list/unitDetail.tsx

@@ -2,7 +2,7 @@ import OEmpty from '@/components/o-empty'
 import OHeader from '@/components/o-header'
 import OSearch from '@/components/o-search'
 import OSticky from '@/components/o-sticky'
-import { Dialog, Icon, Tab, Tabs } from 'vant'
+import { Button, Dialog, Icon, Tab, Tabs } from 'vant'
 import { defineComponent, onMounted, reactive, ref } from 'vue'
 import questIcon from '@/school/images/quest-icon.png'
 import styles from './index.module.less'
@@ -72,6 +72,27 @@ export default defineComponent({
             </Tab>
           </Tabs>
         </div>
+
+        <OSticky position="bottom">
+          <div class={['btnGroup']}>
+            <Button
+              block
+              round
+              type="primary"
+              onClick={() => {
+                router.push({
+                  path: '/unit-detail',
+                  query: {
+                    id: route.query.id
+                  }
+                })
+              }}
+            >
+              测试报告
+            </Button>
+          </div>
+        </OSticky>
+
         <Dialog
           class="exercisDetailDialog"
           v-model:show={showTip.value}