瀏覽代碼

小题乱序

zhangjie 3 年之前
父節點
當前提交
88fbe61c30
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/features/examwork/StudentExamDetail/PreviewPaperDialog.vue

+ 12 - 0
src/features/examwork/StudentExamDetail/PreviewPaperDialog.vue

@@ -178,11 +178,23 @@ export default {
               rQuestion.number = qindex + 1;
               if (question.options) {
                 // 选项乱序
+                let optionMap = {};
                 rQuestion.options = question.options.map((opNo, oindex) => {
                   const rOption = { ...rQuestion.options[opNo - 1] };
                   rOption.number = oindex + 1;
+                  optionMap[opNo] = oindex + 1;
                   return rOption;
                 });
+                if (rQuestion.answer) {
+                  rQuestion.answer = rQuestion.answer.map(
+                    (ans) => optionMap[ans]
+                  );
+                }
+                if (rQuestion.studentAnswer) {
+                  rQuestion.studentAnswer = rQuestion.studentAnswer.map(
+                    (ans) => optionMap[ans]
+                  );
+                }
               }
               return rQuestion;
             });