浏览代码

报告极端情况修改

zhangjie 6 年之前
父节点
当前提交
91e27cfd58

+ 3 - 3
stmms-web/src/main/webapp/WEB-INF/views/modules/report/pdf.jsp

@@ -20,7 +20,6 @@
   </div>
 
 
-
   <!-- template -->
   <!-- page-box -->
   <script id="page-box" type="text/html">
@@ -152,7 +151,7 @@
         <# for (var j = 0;j < groups.length; j++) {#>
         <tr>
           <# if (j == 0) { #>
-          <td rowspan="<#:=groups.length#>"><#:=dataList[i].name#></td>
+          <td rowspan="<#:=groups.length#>"><#:=groups.length > 3 ? dataList[i].name : ''#></td>
           <# } #>
           <# var levels = groups[j].levels; #>
           <td class="td-name"><p><#:=groups[j].name#></p></td>
@@ -212,7 +211,7 @@
         <# for (var j = 0;j < groups.length; j++) {#>
         <tr>
           <# if (j == 0) { #>
-          <td rowspan="<#:=groups.length#>"><#:=dataList[i].name#></td>
+          <td rowspan="<#:=groups.length#>"><#:=groups.length > 3 ? dataList[i].name : ''#></td>
           <# } #>
           <# var levels = groups[j].levels #>
           <td class="td-name"><p><#:=groups[j].name#></p></td>
@@ -443,6 +442,7 @@
     </div>
   </script>
 
+
   <!-- js -->
   <script src="${ctxStatic}/report-pdf/libs/jquery-2.1.4.min.js"></script>
   <script src="${ctxStatic}/report-pdf/libs/echarts.min.4.2.0-rc2.js"></script>

+ 13 - 3
stmms-web/src/main/webapp/static/report-pdf/css/teaching.css

@@ -215,11 +215,21 @@ img {
 
 .cover-footer {
   position: absolute;
-  width: 450px;
-  height: 175px;
-  left: 156px;
+  width: 1000px;
+  left: 58px;
   bottom: 156px;
+  padding-left: 98px;
   line-height: 58px; }
+  .cover-footer p {
+    overflow: hidden; }
+    .cover-footer p span:first-child {
+      float: left; }
+    .cover-footer p span:last-child {
+      display: block;
+      margin-left: 87px; }
+    .cover-footer p:first-child span:last-child {
+      display: block;
+      margin-left: 145px; }
 
 .chart-teachers {
   height: 550px; }

+ 7 - 2
stmms-web/src/main/webapp/static/report-pdf/js/chart-render.js

@@ -954,8 +954,13 @@
           interval: 0,
           formatter: function (value) {
             var str = value.split('#');
-            if (str[0].length > 10) str[0] = str[0].substr(0, 10) + '...';
-            return [str[0], str[1]].join(' ')
+            if (str[1]) {
+              if (str[0].length > 10) str[0] = str[0].substr(0, 10) + '...';
+              return [str[0], str[1]].join(' ')
+            } else {
+              if (str[0].length > 13) str[0] = str[0].substr(0, 13) + '...';
+              return str[0]
+            }
           }
         },
         axisLine: {

+ 87 - 9
stmms-web/src/main/webapp/static/report-pdf/js/teaching.js

@@ -107,7 +107,21 @@ function createTeacherScore(dataList) {
 // 任课老师班级成绩分析
 function createTeacherGrade(dataList) {
   var hTmpl = $("#teacher-grade").html();
-  sectionArr(dataList, 3).forEach(function (item) {
+  var sectionDataList = [];
+  dataList.map(function (item) {
+    if (item.classes.length <= 8) {
+      sectionDataList.push(item)
+    } else {
+      sectionArr(item.classes, 7).forEach(function (elem) {
+        sectionDataList.push({
+          name: item.name,
+          classes: elem
+        })
+      });
+    }
+  });
+
+  sectionArr(sectionDataList, 3).forEach(function (item) {
     var chartList = item.map(function (elem) {
       var chartId = getEchartId();
       addEchart({
@@ -126,6 +140,11 @@ function createTeacherGrade(dataList) {
 
 // 大题难度分析
 function createLineChart(dataList) {
+  if (dataList.length > 6) {
+    createLineReverseChart(dataList, '大题难度分析');
+    return
+  }
+
   var hTmpl = $("#page-chart").html();
   var chartId = getEchartId();
   var $dom = tmpl(hTmpl, {
@@ -141,12 +160,12 @@ function createLineChart(dataList) {
   });
 }
 // 小题难度分析
-function createLineReverseChart(dataList) {
+function createLineReverseChart(dataList, tableName) {
   var hTmpl = $("#page-chart").html();
   sectionArr(dataList, 46).forEach(function (item) {
     var chartId = getEchartId();
     var $dom = tmpl(hTmpl, {
-      title: "小题难度分析",
+      title: tableName || "小题难度分析",
       chartId: chartId,
       height: 200 + 26 * item.length + "px"
     });
@@ -161,7 +180,7 @@ function createLineReverseChart(dataList) {
 // 区分度等级分布,难度等级分布
 function createDiscriminationDifficultyLevel(dataList, type) {
   var hTmpl = $("#" + type + "-level-table").html();
-  sectionArrDynamic(dataList, 30, 'groups').forEach(function (item) {
+  groupSectionArrDynamic(dataList, 30).forEach(function (item) {
     var $dom = tmpl(hTmpl, {
       dataList: item
     });
@@ -189,12 +208,16 @@ function createBasicMainQuestion(dataList) {
 // 选项分析
 function createBasicQuestionOption(data) {
   var hTmpl = $("#basic-question-option-table").html();
+  // 选项多余7个会分组
+  var options = sectionArr(data.options, 8);
   sectionArr(data.questions, 32).forEach(function (item) {
-    var $dom = tmpl(hTmpl, {
-      options: data.options,
-      questions: item
+    options.map(function (elem) {
+      var $dom = tmpl(hTmpl, {
+        options: elem,
+        questions: item
+      });
+      $bodyMain.append(createNewBox($dom));
     });
-    $bodyMain.append(createNewBox($dom));
   });
 }
 // 考生分段比例
@@ -360,7 +383,27 @@ function sectionArr(arrayList, sectionLength) {
 }
 
 /**
- * 
+ *
+ * @param {Array} arrayList 要分段的数组
+ * @param {Number} sectionLength 每段的长度
+ * @param {Number} firstPageNum 第一段的长度
+ */
+function sectionArrFirstPage(arrayList, sectionLength, firstPageNum) {
+  var splitArr = [];
+  var currentSectionLength = 0;
+  for (var i = 0, len = arrayList.length; i < len; i += currentSectionLength) {
+    if (i === 0) {
+      currentSectionLength = firstPageNum;
+    } else {
+      currentSectionLength = sectionLength;
+    }
+    splitArr.push(arrayList.slice(i, i + currentSectionLength));
+  }
+  return splitArr;
+}
+
+/**
+ * 组元素个数少于10个时,此法更方便
  * @param {Array} arrayList 要分段的数组
  * @param {Number} sectionMaxItemLength 最大分段元素个数
  */
@@ -380,6 +423,41 @@ function sectionArrDynamic(arrayList, sectionMaxItemLength, childrenName) {
   splitArr.push(splitSectionArr);
   return splitArr;
 }
+/**
+ * 组元素过多,且无规律时,使用此方法更合理
+ * @param {*} arrayList 
+ * @param {*} sectionMaxItemLength 
+ * @param {*} childrenName 
+ */
+function groupSectionArrDynamic(arrayList, sectionMaxItemLength) {
+  var splitArr = [];
+  var splitSectionItemLen = 0;
+  var splitSectionArr = [];
+  arrayList.map(function (item) {
+    var groupsList = [];
+    item.groups.map(function (elem) {
+      splitSectionItemLen++;
+      groupsList.push(elem);
+
+      if (splitSectionItemLen >= sectionMaxItemLength) {
+        splitSectionArr.push({
+          name: item.name,
+          groups: groupsList
+        });
+        splitArr.push(splitSectionArr);
+        splitSectionItemLen = 0;
+        splitSectionArr = [];
+        groupsList = []
+      }
+
+    });
+    splitSectionArr.push({
+      name: item.name,
+      groups: groupsList
+    })
+  });
+  return splitArr;
+}
 
 /**
  * 获取chartId