浏览代码

修复单选答案多选问题

wyling007 3 年之前
父节点
当前提交
15df3b946c
共有 1 个文件被更改,包括 11 次插入2 次删除
  1. 11 2
      src/hooks/exercise/wrong.ts

+ 11 - 2
src/hooks/exercise/wrong.ts

@@ -2,6 +2,7 @@ import { ref, watch, onBeforeMount, Ref, computed, nextTick, ComputedRef } from
 import { CollectionModel } from "@/model/collection";
 import { RouterBus } from "@/hooks";
 import { Notify } from "vant";
+import { isArrSubset } from "@/utils/utils";
 
 /**错题与收藏 */
 export const useSubjectCheck = (currentSubject: ComputedRef<any>, nextSubject: () => Promise<void>) => {
@@ -58,11 +59,19 @@ export const useSubjectCheck = (currentSubject: ComputedRef<any>, nextSubject: (
 			} else {
 				status = 0;
 			}
-			if (currentSubject.value.userAnswer.includes(val)) {
-				status += 2;
+			if (currentSubject.value.userAnswer instanceof Array) {
+				if (currentSubject.value.userAnswer.includes(val)) {
+					status += 2;
+				}
+			} else {
+				if (currentSubject.value.userAnswer === val) {
+					status += 2;
+				}
 			}
+
 			return { opt: val, status };
 		});
+
 		if (JSON.stringify(currentSubject.value.answer) == JSON.stringify(currentSubject.value.userAnswer)) {
 			//答案正确
 			currentSubject.value.isTrue = true;