Эх сурвалжийг харах

试卷预览,小题乱序

zhangjie 3 жил өмнө
parent
commit
6a6a47de31

+ 31 - 2
src/features/examwork/StudentExamDetail/PreviewPaperDialog.vue

@@ -101,6 +101,10 @@ export default {
       const examStudentAnswerJson = data.examStudentAnswerJson
         ? JSON.parse(data.examStudentAnswerJson)
         : [];
+      const randomPaperStructPath = data.randomPaperStructPath
+        ? JSON.parse(data.randomPaperStructPath)
+        : { details: [] };
+      // console.log(JSON.stringify(randomPaperStructPath));
       // console.log(paperStructJson);
       // console.log(answerJson);
       // console.log(examStudentAnswerJson);
@@ -161,8 +165,33 @@ export default {
           }
         });
       });
-      // console.log(JSON.stringify(paperStructJson));
-      this.paperStruct = paperStructJson;
+
+      let studentPaperStructJson = { ...paperStructJson };
+      if (randomPaperStructPath.details.length) {
+        studentPaperStructJson.details = randomPaperStructPath.details.map(
+          (detail, dindex) => {
+            const rDetail = { ...paperStructJson.details[detail.number - 1] };
+            rDetail.number = dindex + 1;
+            rDetail.questions = detail.questions.map((question, qindex) => {
+              // 试题乱序
+              const rQuestion = { ...rDetail.questions[question.number - 1] };
+              rQuestion.number = qindex + 1;
+              if (question.options) {
+                // 选项乱序
+                rQuestion.options = question.options.map((opNo, oindex) => {
+                  const rOption = { ...rQuestion.options[opNo - 1] };
+                  rOption.number = oindex + 1;
+                  return rOption;
+                });
+              }
+              return rQuestion;
+            });
+            return rDetail;
+          }
+        );
+      }
+
+      this.paperStruct = studentPaperStructJson;
     },
     parseRenderStructList() {
       let renderStructList = [];