Răsfoiți Sursa

feat: 试卷结构分析接口调整

zhangjie 6 luni în urmă
părinte
comite
94ef0cc875

+ 12 - 10
src/modules/paper/api.js

@@ -117,19 +117,21 @@ export const paperAuditInfoApi = ({ paperId, curPage, pageSize }) => {
     }
   );
 };
-export const paperBlueInfoApi = ({ paperId, courseId, rootOrgId }) => {
-  return $httpWithMsg.get(`${QUESTION_API}/paper/blue`, {
-    params: {
-      id: paperId,
-      // coursePropertyId,
-      courseId,
-      rootOrgId,
-    },
-  });
+export const paperBlueInfoApi = ({ paperId, rootOrgId }) => {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/paper/statistic/property_distribution`,
+    {},
+    {
+      params: {
+        id: paperId,
+        rootOrgId,
+      },
+    }
+  );
 };
 export const paperQuestionTypeInfoApi = ({ paperId, rootOrgId }) => {
   return $httpWithMsg.post(
-    `${QUESTION_API}/paper/statistic/paper_detail`,
+    `${QUESTION_API}/paper/statistic/question_type`,
     {},
     {
       params: {

+ 96 - 40
src/modules/paper/components/PaperStructInfo.vue

@@ -37,7 +37,7 @@
         <div class="statistics-body stat-type-body">
           <div class="stat-type-table">
             <el-table :data="paperQuestionData" border>
-              <el-table-column label="题型" prop="paperDetailName" width="120">
+              <el-table-column label="题型" prop="sourceDetailName" width="120">
               </el-table-column>
               <el-table-column label="试题数量">
                 <template slot-scope="scope">
@@ -79,10 +79,10 @@
                   <span>
                     {{ scope.row.questionCount }} (
                     {{
-                      scope.row.paperDetailInfo
+                      scope.row.questionTypeInfo
                         .map(
                           (item) =>
-                            `${item.paperDetailName}:${item.questionCount}`
+                            `${item.sourceDetailName}:${item.questionCount}`
                         )
                         .join(",")
                     }})
@@ -105,34 +105,23 @@
           <h2>按知识点统计</h2>
         </div>
         <div class="statistics-body">
-          <el-table
-            :data="paperData3.data"
-            style="width: 100%"
-            border
-            :span-method="objectSpanMethod3"
-          >
+          <el-table :data="blueData" border :span-method="objectSpanMethod">
             <el-table-column
-              v-for="(colval, colIndex) in headFirst3"
-              :key="`first${colIndex}`"
-            >
-              <template slot="header">
-                <span style="margin-left: 10px">{{ colval }}</span>
-              </template>
-              <template slot-scope="scope">
-                <span style="margin-left: 10px">{{ scope.row[colIndex] }}</span>
-              </template>
-            </el-table-column>
+              label="一级知识点"
+              prop="firstProperty"
+            ></el-table-column>
+            <el-table-column
+              label="二级知识点"
+              prop="secondProperty"
+            ></el-table-column>
             <el-table-column
-              v-for="(colval, colIndex) in headSecond3"
-              :key="`second${colIndex}`"
+              v-for="(colval, colIndex) in questionTypeList"
+              :key="`${colval}${colIndex}`"
+              :prop="colval"
+              :label="colval"
             >
-              <template slot="header">
-                <span style="margin-left: 10px">{{ colval }}</span>
-              </template>
               <template slot-scope="scope">
-                <span style="margin-left: 10px">{{
-                  scope.row[colIndex + 2]
-                }}</span>
+                <span>{{ scope.row[colval] || "--" }}</span>
               </template>
             </el-table-column>
           </el-table>
@@ -173,9 +162,9 @@ export default {
       paperQuestionChartOption: null,
       paperDifficultData: [],
       paperDifficultChartOption: null,
-      paperData3: { head: [], data: [] },
-      headFirst3: [],
-      headSecond3: [],
+      blueData: [],
+      questionTypeList: [],
+      rowspans: [],
     };
   },
   methods: {
@@ -189,7 +178,7 @@ export default {
       const res = await paperBaseInfoApi(this.paperId);
       this.paperData = res.data;
       this.getPaperData();
-      this.getPaperData3();
+      this.getBlueData();
     },
     async getPaperData() {
       const qres = await paperQuestionTypeInfoApi({
@@ -200,7 +189,7 @@ export default {
       const qData = this.paperQuestionData.map((item) => {
         return {
           value: item.questionCount,
-          name: item.paperDetailName,
+          name: item.sourceDetailName,
         };
       });
       this.paperQuestionChartOption = this.getChartOption(qData);
@@ -264,21 +253,88 @@ export default {
 
       return option;
     },
-    async getPaperData3() {
+    async getBlueData() {
       // if (!this.coursePropertyId) return;
       const res = await paperBlueInfoApi({
         paperId: this.paperId,
-        courseId: this.courseId,
-        // coursePropertyId: this.coursePropertyId,
         rootOrgId: this.$store.state.user.rootOrgId,
       });
-      this.paperData3 = res.data;
-      this.headFirst3 = this.paperData3.head.slice(0, 2);
-      this.headSecond3 = this.paperData3.head.slice(2);
+      const datas = res.data[0].distributeInfo || [];
+
+      const tableData = [];
+      let questionTypeList = [];
+      const rowspans = [];
+      let curRowIndex = 0;
+      datas.forEach((item) => {
+        const rowCount =
+          item.children && item.children.length ? item.children.length : 1;
+        rowspans.push([curRowIndex, curRowIndex + rowCount - 1]);
+        curRowIndex += rowCount;
+
+        if (item.children && item.children.length) {
+          item.children.forEach((elem) => {
+            const row = {
+              id: `${item.propertyId}_${elem.propertyId}`,
+              firstProperty: item.propertyName,
+              secondProperty: elem.propertyName,
+            };
+
+            if (
+              elem.distributeByQuestionTypeList &&
+              elem.distributeByQuestionTypeList.length
+            ) {
+              elem.distributeByQuestionTypeList.forEach((source) => {
+                row[source.sourceDetailName] = source.questionDifficultInfo
+                  .map(
+                    (item) => `${item.difficultLevel}:${item.questionCount}`
+                  )
+                  .join(",");
+              });
+
+              if (!questionTypeList.length) {
+                questionTypeList = elem.distributeByQuestionTypeList.map(
+                  (source) => source.sourceDetailName
+                );
+              }
+            }
+
+            tableData.push(row);
+          });
+          return;
+        }
+
+        const row = {
+          id: `${item.propertyId}`,
+          firstProperty: item.propertyName,
+          secondProperty: "",
+        };
+
+        if (
+          item.distributeByQuestionTypeList &&
+          item.distributeByQuestionTypeList.length
+        ) {
+          item.distributeByQuestionTypeList.forEach((source) => {
+            row[source.sourceDetailName] = source.questionDifficultInfo
+              .map((item) => `${item.difficultLevel}:${item.questionCount}`)
+              .join(",");
+          });
+
+          if (!questionTypeList.length) {
+            questionTypeList = item.distributeByQuestionTypeList.map(
+              (source) => source.sourceDetailName
+            );
+          }
+        }
+        tableData.push(row);
+      });
+
+      this.questionTypeList = questionTypeList;
+      this.blueData = tableData;
+      this.rowspans = rowspans;
     },
-    objectSpanMethod3({ rowIndex, columnIndex }) {
+    objectSpanMethod({ rowIndex, columnIndex }) {
       if (columnIndex === 0) {
-        for (let span of this.paperData3.rowspan) {
+        for (let span of this.rowspans) {
           if (span[0] == rowIndex) {
             return {
               rowspan: span[1] - span[0] + 1,

+ 1 - 0
src/modules/statistics/components/StatisticsQuestionDialog.vue

@@ -97,6 +97,7 @@
               v-for="(colval, colIndex) in questionTypeList"
               :key="`${colval}${colIndex}`"
               :prop="colval"
+              :label="colval"
             >
               <template slot-scope="scope">
                 <span>{{ scope.row[colval] || "--" }}</span>