1
0
Quellcode durchsuchen

检验报告展示修改

zhangjie vor 6 Jahren
Ursprung
Commit
40d7352f47

+ 170 - 65
stmms-web/src/main/webapp/static/report-pdf/js/data-parse.js

@@ -1,64 +1,60 @@
-var cover = {
-  examName: dataStatic.examName,
-  schoolName: dataStatic.schoolName,
-  subjectName: dataStatic.subjectName
-};
-var basic_question_objective = dataStatic.basic_question_objective;
-var basic_question_subjective = dataStatic.basic_question_subjective;
-var basic_class = dataStatic.basic_class;
-var basic_teacher = dataStatic.basic_teacher;
-var basic_college = dataStatic.basic_college;
-var basic_main_question = dataStatic.basic_main_question;
-var basic_question = basic_question_objective.concat(basic_question_subjective);
-var basic_sub_question = basic_question.map(function(item, index) {
-  return {
-    name: item.name,
-    number: index + 1,
-    difficulty: item.difficulty
-  };
-});
-var discrimination_level = dataStatic.discrimination_level.map(function(item) {
-  item.groups.map(function(elem) {
-    elem.levels.excellent.questionRate = (
-      (100 * elem.levels.excellent.questionCount) /
-      elem.questionCount
-    ).toFixed(2);
-    elem.levels.good.questionRate = (
-      (100 * elem.levels.good.questionCount) /
-      elem.questionCount
-    ).toFixed(2);
-    elem.levels.general.questionRate = (
-      (100 * elem.levels.general.questionCount) /
-      elem.questionCount
-    ).toFixed(2);
-    elem.levels.bad.questionRate = (
-      (100 * elem.levels.bad.questionCount) /
-      elem.questionCount
-    ).toFixed(2);
+function tofixed(num, precision) {
+  if (!num && num !== 0) return num;
+  if (precision) {
+    return parseFloat(num.toFixed(precision));
+  } else {
+    return Math.round(num);
+  }
+}
+// paser functions
+function parseBaseQuestion(datas) {
+  return datas.map(function (item) {
+    item.name = item.name + item.number;
+    item.avgScore = tofixed(item.avgScore, 2);
+    item.stdevScore = tofixed(item.stdevScore, 2);
+    item.coefficient = tofixed(item.coefficient, 2);
+    item.difficulty = tofixed(item.difficulty, 2);
+    item.discrimination = tofixed(item.discrimination, 2);
+    item.fullRate = tofixed(item.fullRate, 2);
+    item.scoreRate = tofixed(item.scoreRate, 2);
+    return item;
   });
-
-  return item;
-});
-var difficulty_level = dataStatic.difficulty_level.map(function(item) {
-  item.groups.map(function(elem) {
-    elem.levels.high.questionRate = (
-      (100 * elem.levels.high.questionCount) /
-      elem.questionCount
-    ).toFixed(2);
-    elem.levels.middle.questionRate = (
-      (100 * elem.levels.middle.questionCount) /
-      elem.questionCount
-    ).toFixed(2);
-    elem.levels.low.questionRate = (
-      (100 * elem.levels.low.questionCount) /
-      elem.questionCount
-    ).toFixed(2);
+}
+function parseBaseClass(datas) {
+  return datas.map(function (item) {
+    item.avgScore = tofixed(item.avgScore, 2);
+    item.stdevScore = tofixed(item.stdevScore, 2);
+    item.excellentRate = tofixed(item.excellentRate, 2);
+    item.passRate = tofixed(item.passRate, 2);
+    return item;
   });
-
-  return item;
-});
-dataStatic.basic_question_option.questions = dataStatic.basic_question_option.questions.map(
-  function(item) {
+}
+function parseBaseTeacher(datas) {
+  return datas.map(function (item) {
+    item.avgScore = tofixed(item.avgScore, 2);
+    item.excellentRate = tofixed(item.excellentRate, 2);
+    item.excellentRate100 = tofixed(item.excellentRate * 100, 2);
+    item.passRate = tofixed(item.passRate, 2);
+    item.passRate100 = tofixed(item.passRate * 100, 2);
+    item.relativeAvgScore = tofixed(item.relativeAvgScore, 2);
+    if (item.classes && item.classes.length) {
+      item.classes = parseBaseTeacher(item.classes);
+    }
+    return item;
+  });
+}
+function parseBaseMainQuestion(datas) {
+  return datas.map(function (item) {
+    item.avgScore = tofixed(item.avgScore, 2);
+    item.stdevScore = tofixed(item.stdevScore, 2);
+    item.coefficient = tofixed(item.coefficient, 2);
+    item.difficulty = tofixed(item.difficulty, 2);
+    item.discrimination = tofixed(item.discrimination, 2);
+    return item;
+  });
+}
+function parseBaseQuestionOption(datas) {
+  datas.questions = datas.questions.map(function (item) {
     item.optionsRate = {};
     for (key in item.options) {
       item.optionsRate[key] = (
@@ -66,12 +62,121 @@ dataStatic.basic_question_option.questions = dataStatic.basic_question_option.qu
         item.totalCount
       ).toFixed(2);
     }
+    item.difficulty = tofixed(item.difficulty, 2);
+    item.discrimination = tofixed(item.discrimination, 2);
     return item;
-  }
+  });
+  return datas;
+}
+
+function parseDiscriminationLevel(datas) {
+  return datas.map(function (item) {
+    item.groups = item.groups.map(function (elem) {
+      elem.levels.excellent.questionRate = (
+        (100 * elem.levels.excellent.questionCount) /
+        elem.questionCount
+      ).toFixed(2);
+      elem.levels.good.questionRate = (
+        (100 * elem.levels.good.questionCount) /
+        elem.questionCount
+      ).toFixed(2);
+      elem.levels.general.questionRate = (
+        (100 * elem.levels.general.questionCount) /
+        elem.questionCount
+      ).toFixed(2);
+      elem.levels.bad.questionRate = (
+        (100 * elem.levels.bad.questionCount) /
+        elem.questionCount
+      ).toFixed(2);
+      elem.coefficient = tofixed(elem.coefficient, 2);
+
+      return elem;
+    });
+
+    return item;
+  });
+}
+function parseDifficultyLevel(datas) {
+  return datas.map(function (item) {
+    item.groups = item.groups.map(function (elem) {
+      elem.levels.high.questionRate = (
+        (100 * elem.levels.high.questionCount) /
+        elem.questionCount
+      ).toFixed(2);
+      elem.levels.middle.questionRate = (
+        (100 * elem.levels.middle.questionCount) /
+        elem.questionCount
+      ).toFixed(2);
+      elem.levels.low.questionRate = (
+        (100 * elem.levels.low.questionCount) /
+        elem.questionCount
+      ).toFixed(2);
+
+      elem.difficulty = tofixed(elem.difficulty, 2);
+      return elem;
+    });
+
+    return item;
+  });
+}
+function parseRangeScoreLevel(datas) {
+  return datas.map(function (item) {
+    item.rangeRate = tofixed(item.rangeRate, 2);
+    item.sumRate = tofixed(item.sumRate, 2);
+    return item;
+  });
+}
+function parseRangeTotalScore(datas) {
+  return {
+    total: parseRangeScoreLevel(datas.total),
+    classes: datas.classes.map(function (item) {
+      return {
+        name: item.name,
+        ranges: parseRangeScoreLevel(item.ranges)
+      };
+    })
+  };
+}
+function parseRangeSegment(datas) {
+  return datas.map(function (item) {
+    return {
+      name: item.name,
+      groups: item.groups.map(function (elem) {
+        return {
+          name: elem.name,
+          segments: parseRangeScoreLevel(elem.segments)
+        };
+      })
+    };
+  });
+}
+
+// data-parse
+var cover = {
+  examName: dataStatic.examName,
+  schoolName: dataStatic.schoolName,
+  subjectName: dataStatic.subjectName
+};
+var basic_question_objective = parseBaseQuestion(
+  dataStatic.basic_question_objective
+);
+var basic_question_subjective = parseBaseQuestion(
+  dataStatic.basic_question_subjective
+);
+var basic_class = parseBaseClass(dataStatic.basic_class);
+var basic_teacher = parseBaseTeacher(dataStatic.basic_teacher);
+var basic_college = parseBaseClass(dataStatic.basic_college);
+var basic_main_question = parseBaseMainQuestion(dataStatic.basic_main_question);
+var basic_question = basic_question_objective.concat(basic_question_subjective);
+
+var discrimination_level = parseDiscriminationLevel(
+  dataStatic.discrimination_level
+);
+var difficulty_level = parseDifficultyLevel(dataStatic.difficulty_level);
+var basic_question_option = parseBaseQuestionOption(
+  dataStatic.basic_question_option
 );
-var basic_question_option = dataStatic.basic_question_option;
-// s bli
 var range_level = dataStatic.range_level;
-var range_10_totalScore = dataStatic.range_10_totalScore;
-var range_1_totalScore = dataStatic.range_1_totalScore;
-var range_segment_6 = dataStatic.range_segment_6;
+ var range_10_totalScore = parseRangeTotalScore(dataStatic.range_10_totalScore);
+ var range_1_totalScore = parseRangeTotalScore(dataStatic.range_1_totalScore);
+ var range_segment_6 = parseRangeSegment(dataStatic.range_segment_6);

+ 26 - 25
stmms-web/src/main/webapp/static/report-pdf/js/teaching.js

@@ -25,26 +25,27 @@ function build() {
   createTeacherGrade(basic_teacher);
   createBarPointChart(basic_college, 22, "学院成绩分析", "barPointGrade");
   createLineChart(basic_main_question);
-  createLineReverseChart(basic_sub_question);
+  createLineReverseChart(basic_question); // basic_sub_question
   createDiscriminationDifficultyLevel(discrimination_level, "discrimination");
   createDiscriminationDifficultyLevel(difficulty_level, "difficulty");
   createBasicQuestion(basic_question);
   createBasicMainQuestion(basic_main_question);
   createBasicQuestionOption(basic_question_option);
   createRangeLevel(range_level);
-  createRange10TotalScore(range_10_totalScore);
-  createRangeTotalScore(range_1_totalScore);
-  createRangeSegment(range_segment_6);
+
+   createRange10TotalScore(range_10_totalScore);
+   createRangeTotalScore(range_1_totalScore);
+   createRangeSegment(range_segment_6);
   createEchart();
   fillCatalogNum();
 }
 
 function publishReady() {
-  var eventEmitInterval = setInterval(function() {
+  var eventEmitInterval = setInterval(function () {
     document.body.dispatchEvent(new Event("view-ready"));
   }, 25);
 
-  document.body.addEventListener("view-ready-acknowledged", function() {
+  document.body.addEventListener("view-ready-acknowledged", function () {
     clearInterval(eventEmitInterval);
   });
 }
@@ -58,7 +59,7 @@ function createCover() {
 function createBarPointChart(dataList, splitRange, title, chartType) {
   var hTmpl = $("#page-chart").html();
   var labelHeight = Math.round(1170 / splitRange);
-  sectionArr(dataList, splitRange).forEach(function(item) {
+  sectionArr(dataList, splitRange).forEach(function (item) {
     var chartId = getEchartId();
     var $dom = tmpl(hTmpl, {
       title: title,
@@ -78,7 +79,7 @@ function createBarPointChart(dataList, splitRange, title, chartType) {
 function createTeacherScore(dataList) {
   var hTmpl = $("#teacher-score").html();
   var splitList = sectionArr(dataList, 6);
-  splitList.forEach(function(item) {
+  splitList.forEach(function (item) {
     var chartId = getEchartId();
     var $dom = tmpl(hTmpl, {
       chartId: chartId,
@@ -95,7 +96,7 @@ function createTeacherScore(dataList) {
   // 总明细表
   if (splitList.length > 1) {
     var hTmpl2 = $("#teacher-score-table").html();
-    sectionArr(dataList, 26).forEach(function(item) {
+    sectionArr(dataList, 26).forEach(function (item) {
       var $dom = tmpl(hTmpl2, {
         dataList: item,
         pageTableClass: "teacher-table"
@@ -107,8 +108,8 @@ function createTeacherScore(dataList) {
 // 任课老师班级成绩分析
 function createTeacherGrade(dataList) {
   var hTmpl = $("#teacher-grade").html();
-  sectionArr(dataList, 3).forEach(function(item) {
-    var chartList = item.map(function(elem) {
+  sectionArr(dataList, 3).forEach(function (item) {
+    var chartList = item.map(function (elem) {
       var chartId = getEchartId();
       addEchart({
         chartId: chartId,
@@ -143,7 +144,7 @@ function createLineChart(dataList) {
 // 小题难度分析
 function createLineReverseChart(dataList) {
   var hTmpl = $("#page-chart").html();
-  sectionArr(dataList, 46).forEach(function(item) {
+  sectionArr(dataList, 46).forEach(function (item) {
     var chartId = getEchartId();
     var $dom = tmpl(hTmpl, {
       title: "小题难度分析",
@@ -161,7 +162,7 @@ function createLineReverseChart(dataList) {
 // 区分度等级分布,难度等级分布
 function createDiscriminationDifficultyLevel(dataList, type) {
   var hTmpl = $("#" + type + "-level-table").html();
-  sectionArr(dataList, 4).forEach(function(item) {
+  sectionArr(dataList, 4).forEach(function (item) {
     var $dom = tmpl(hTmpl, {
       dataList: item
     });
@@ -171,7 +172,7 @@ function createDiscriminationDifficultyLevel(dataList, type) {
 // 题目统计特征
 function createBasicQuestion(dataList) {
   var hTmpl = $("#basic-question-table").html();
-  sectionArr(dataList, 33).forEach(function(item) {
+  sectionArr(dataList, 33).forEach(function (item) {
     var $dom = tmpl(hTmpl, {
       dataList: item
     });
@@ -189,7 +190,7 @@ function createBasicMainQuestion(dataList) {
 // 选项分析
 function createBasicQuestionOption(data) {
   var hTmpl = $("#basic-question-option-table").html();
-  sectionArr(data.questions, 32).forEach(function(item) {
+  sectionArr(data.questions, 32).forEach(function (item) {
     var $dom = tmpl(hTmpl, {
       options: data.options,
       questions: item
@@ -200,7 +201,7 @@ function createBasicQuestionOption(data) {
 // 考生分段比例
 function createRangeLevel(dataList) {
   var hTmpl = $("#range-level-table").html();
-  sectionArr(dataList, 31).forEach(function(item) {
+  sectionArr(dataList, 31).forEach(function (item) {
     var $dom = tmpl(hTmpl, {
       dataList: item
     });
@@ -216,7 +217,7 @@ function createRange10TotalScore(datas) {
     }
   ];
   pageList = pageList.concat(
-    datas.classes.map(function(item) {
+    datas.classes.map(function (item) {
       return {
         title: item.name + " 总分频率分布",
         dataList: item.ranges
@@ -224,7 +225,7 @@ function createRange10TotalScore(datas) {
     })
   );
   var hTmpl = $("#range-totalScore").html();
-  pageList.forEach(function(item, index) {
+  pageList.forEach(function (item, index) {
     var chartId = getEchartId();
     addEchart({
       chartId: chartId,
@@ -252,7 +253,7 @@ function createRangeTotalScore(datas) {
     }
   ];
   pageList = pageList.concat(
-    datas.classes.map(function(item) {
+    datas.classes.map(function (item) {
       return {
         title: item.name + " 总分一分一段表",
         dataList: item.ranges
@@ -260,8 +261,8 @@ function createRangeTotalScore(datas) {
     })
   );
   var hTmpl = $("#range-totalScore").html();
-  pageList.forEach(function(item, index) {
-    sectionArr(item.dataList, 28).forEach(function(elem) {
+  pageList.forEach(function (item, index) {
+    sectionArr(item.dataList, 28).forEach(function (elem) {
       var $dom = tmpl(hTmpl, {
         title: item.title,
         pageTableClass: "table-ave-5 page-table-pad",
@@ -275,8 +276,8 @@ function createRangeTotalScore(datas) {
 // 六段频率统计
 function createRangeSegment(dataList) {
   var hTmpl = $("#range-segment-table").html();
-  dataList.map(function(item) {
-    sectionArr(item.groups, 4).map(function(elem) {
+  dataList.map(function (item) {
+    sectionArr(item.groups, 4).map(function (elem) {
       var $dom = tmpl(hTmpl, {
         title: item.name + " 六段频率统计",
         dataList: elem
@@ -316,7 +317,7 @@ function createNewBox(bodyDom, boxType) {
  *
  */
 function createEchart() {
-  echartList.forEach(function(elem) {
+  echartList.forEach(function (elem) {
     var charts = new Charts(
       document.getElementById(elem.chartId),
       elem.datas,
@@ -331,7 +332,7 @@ function createEchart() {
  */
 function fillCatalogNum() {
   var hTmpl = $("#page-foot").html();
-  $(".report-box").each(function(index) {
+  $(".report-box").each(function (index) {
     var page = index + 1;
     var dom = tmpl(hTmpl, {
       name: cover.name,