Selaa lähdekoodia

多媒体阅卷:统一格式

Michael Wang 4 vuotta sitten
vanhempi
commit
7f6eb3dc4b
3 muutettua tiedostoa jossa 33 lisäystä ja 7 poistoa
  1. 5 3
      src/features/mark/Mark.vue
  2. 27 3
      src/features/mark/MultiMediaMarkBody.vue
  3. 1 1
      src/types/index.ts

+ 5 - 3
src/features/mark/Mark.vue

@@ -108,21 +108,22 @@ async function getPaper() {
         unionOrder: q.mainNumber + "-" + q.subNumber,
         body: q.body,
         parentBody: q.parentBody,
-        answer: q.answer,
+        answer: [q.answer],
       } as RichTextQuestion;
       store.setting.subject.questions.push(tempQuestion);
     }
   } else {
     const details = res.data.details;
     for (let order1 of details) {
-      for (let order2 of order1) {
+      for (let order2 of order1.questions) {
         if (order2.subQuestions) {
-          for (let order3 of order2) {
+          for (let order3 of order2.subQuestions) {
             const tempQuestion = {
               unionOrder:
                 order1.number + "-" + order2.number + "-" + order3.number,
               body: order3.body,
               parentBody: order2.body,
+              answer: order3.answer,
             } as RichTextQuestion;
             store.setting.subject.questions.push(tempQuestion);
           }
@@ -131,6 +132,7 @@ async function getPaper() {
             unionOrder: order1.number + "-" + order2.number,
             body: order2.body,
             parentBody: null,
+            answer: order2.answer,
           } as RichTextQuestion;
           store.setting.subject.questions.push(tempQuestion);
         }

+ 27 - 3
src/features/mark/MultiMediaMarkBody.vue

@@ -21,6 +21,11 @@ watch(
   async () => {
     const res = await updateStudentAnswerJSON();
     const questions = res.data; // TODO: add type
+    for (const q of questions) {
+      if (q.answer && !Array.isArray(q.answer)) {
+        q.answer = [q.answer];
+      }
+    }
     // TODO: 最好变成有结构的v-for渲染
     for (const q of questions) {
       const questionBody = store.setting.subject.questions.find(
@@ -44,9 +49,14 @@ watch(
       questionBody?.body && appendRichText(questionBody?.body);
 
       const studentAnswerNode = document.createElement("div");
+      let tempNode = document.createElement("div");
+      for (const an of q.answer) {
+        // allAnswer += renderRichText(an);
+        tempNode.appendChild(renderRichText(an));
+      }
       studentAnswerNode.innerHTML = `考生答案:(字数统计:${
-        renderRichText(q.answer)?.innerHTML?.length ?? 0
-      })`;
+        tempNode?.innerText?.length ?? 0
+      })${tempNode?.innerHTML}`;
       rendered.value.appendChild(studentAnswerNode);
 
       q.answer && appendRichText(q.answer);
@@ -55,7 +65,15 @@ watch(
       standardAnswerNode.innerHTML = `标准答案:`;
       rendered.value.appendChild(standardAnswerNode);
 
-      questionBody?.answer && appendRichText(questionBody.answer);
+      // questionBody?.answer && appendRichText(questionBody.answer);
+      // console.log(questionBody.answer, renderRichText(questionBody.answer));
+      if (questionBody?.answer) {
+        // let allAnswer = "";
+        for (const an of questionBody?.answer) {
+          // allAnswer += renderRichText(an);
+          rendered.value.appendChild(renderRichText(an));
+        }
+      }
 
       const questionSeperatorNode = document.createElement("hr");
       questionSeperatorNode.style.margin = "20px";
@@ -75,3 +93,9 @@ hr {
   margin: 20px;
 }
 </style>
+
+<style>
+.rich-text-question-container img.inline {
+  display: inline;
+}
+</style>

+ 1 - 1
src/types/index.ts

@@ -229,7 +229,7 @@ export interface RichTextQuestion {
   unionOrder: string; // 题目的综合题号 1-2-4
   body: RichTextJSON;
   parentBody: RichTextJSON | null;
-  answer: RichTextJSON | null;
+  answer: Array<RichTextJSON> | null;
 }
 export interface RichTextJSON {
   sections: RichTextSectionJSON[];