Browse Source

试卷预览bugfix

zhangjie 3 years ago
parent
commit
1e8a85b1e5

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

@@ -118,13 +118,11 @@ export default {
       const studentAnsMap = {};
       examStudentAnswerJson.forEach((question) => {
         const k = `${question.mainNumber}-${question.subNumber}`;
-        if (question.subQuestions) {
-          question.subQuestions.forEach((sq) => {
-            studentAnsMap[`${k}-${sq.number}`] = {
-              answer: JSON.parse(sq.answer),
-              score: sq.score,
-            };
-          });
+        if (question.subIndex !== null) {
+          studentAnsMap[`${k}-${question.subIndex}`] = {
+            answer: JSON.parse(question.answer),
+            score: question.score,
+          };
         } else {
           studentAnsMap[k] = {
             answer: JSON.parse(question.answer),
@@ -139,9 +137,12 @@ export default {
           let k = `${detail.number}-${question.number}`;
           if (question.subQuestions) {
             question.subQuestions.forEach((sq) => {
-              k += `-${sq.number}`;
-              sq.answer = answerMap[k];
-              const stdAns = studentAnsMap[k] || { answer: null, score: null };
+              const sqk = `${k}-${sq.number}`;
+              sq.answer = answerMap[sqk];
+              const stdAns = studentAnsMap[sqk] || {
+                answer: null,
+                score: null,
+              };
               sq.studentAnswer = stdAns.answer;
               sq.studentScore = stdAns.score;
             });
@@ -263,6 +264,7 @@ export default {
             });
           });
         } else {
+          // console.log(question.studentAnswer);
           contents.push({
             cls: "topic-answer std-answer",
             type: "json",

+ 4 - 2
src/features/examwork/StudentExamDetail/spins/renderJSON.js

@@ -65,7 +65,10 @@ function renderBlock(block, inline) {
     //         }
     //     })
     // }
-    if (block.param) {
+    if (
+      block.param &&
+      ["underline", "bold", "italic"].some((item) => block.param[item])
+    ) {
       let uNode, bNode, iNode;
       if (block.param.underline) {
         uNode = document.createElement("u");
@@ -91,7 +94,6 @@ function renderBlock(block, inline) {
           childNode = childNode.childNodes[0];
         }
       }
-
       childNode.textContent = block.value;
     } else {
       node = document.createTextNode(block.value);