소스 검색

feat: 修复考试流程bug

huangziyang 1 주 전
부모
커밋
37f12c75c4
4개의 변경된 파일22개의 추가작업 그리고 18개의 파일을 삭제
  1. 18 14
      components/Topic/TopicExam.vue
  2. 2 2
      pages.json
  3. 0 0
      pages/index/index.vue
  4. 2 2
      pages/regulations/index.vue

+ 18 - 14
components/Topic/TopicExam.vue

@@ -98,9 +98,7 @@
                 </view>
                 <view class="answer-item">
                   我的答案:
-                  <text class="answer-text">{{
-                    item.selectAns.map((i) => i.value).join("")
-                  }}</text>
+                  <text class="answer-text">{{ item.selectAns.join("") }}</text>
                 </view>
                 <view
                   class="tip"
@@ -139,7 +137,7 @@
             >
               下一题
             </button>
-            <button v-if="parindex + 1 === total" @click="submit">交卷</button>
+            <button v-if="parindex + 1 === total" @click="examEnd">交卷</button>
           </view>
         </template>
       </template>
@@ -296,17 +294,22 @@ const onBack = () =>
     r = resolve;
   });
 
+const examEnd = () => {
+  data.value = data.value.map((item) => {
+    return {
+      ...item,
+      showResult: true,
+      isRight: isRight(
+        item.selectAns,
+        item.ansList.map((q) => q.label)
+      ),
+    };
+  });
+  emit("lookReport", data.value, submitter.value);
+};
 const onClose = () => {
   if (submitter.value.closeText !== "提交试卷") return r(true);
-  data.value = data.value.map((item) => ({
-    ...item,
-    showResult: true,
-    isRight: isRight(
-      item.selectAns.map((q) => q.value),
-      item.ansList.map((q) => q.label)
-    ),
-  }));
-  emit("lookReport", data.value, submitter.value);
+  examEnd();
 };
 const onSubmit = () =>
   new Promise((res) => {
@@ -317,7 +320,8 @@ const nowIndex = ref(0);
 
 // 判断答案是否正确
 const isRight = (selectAns, rightAns) => {
-  return rightAns.every((item) => selectAns.includes(item));
+  if (!selectAns.length) return;
+  return selectAns.every((item) => rightAns.includes(item));
 };
 
 const handleSelect = ({ pid, checked, index, style }) => {

+ 2 - 2
pages.json

@@ -1,7 +1,7 @@
 {
   "pages": [
     {
-      "path": "pages/home/index",
+      "path": "pages/index/index",
       "style": {
         "navigationStyle": "custom",
         "navigationBarTitleText": "首页"
@@ -113,7 +113,7 @@
     "backgroundColor": "#ffffff",
     "list": [
       {
-        "pagePath": "pages/home/index",
+        "pagePath": "pages/index/index",
         "iconPath": "static/icons/home.png",
         "selectedIconPath": "static/icons/home_select.png",
         "text": "首页"

+ 0 - 0
pages/home/index.vue → pages/index/index.vue


+ 2 - 2
pages/regulations/index.vue

@@ -150,10 +150,10 @@ const onSafeAreaChange = (s) => {
 
 const onChnage = () => {
   resolveHeight();
-};
+}
 
 const onClickMask = () => {
-  showContainer.value = false;
+  showContainer.value = true;
 };
 
 onMounted(async () => {