|
@@ -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
|