Skip to content

Commit

Permalink
SAK-40603 limit cells that get redrawn after each score item save.
Browse files Browse the repository at this point in the history
Big performance boost in course with many categories and items.
  • Loading branch information
marktriggs authored and ottenhoff committed Sep 17, 2018
1 parent 10490ad commit b1c75e1
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions gradebookng/tool/src/webapp/scripts/gradebook-gbgrade-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1554,12 +1554,22 @@ GbGradeTable.hasExcuse = function(student, assignmentId) {
};

GbGradeTable.redrawCell = function(row, col) {
var $cell = $(GbGradeTable.instance.getCell(row, col));
$cell.removeData('cell-initialised');
GbGradeTable.redrawCells([[row, col]])
};

GbGradeTable.redrawCells = function(cells) {
cells.forEach(function(cell) {
var row = cell[0];
var col = cell[1];
var $cell = $(GbGradeTable.instance.getCell(row, col));
$cell.removeData('cell-initialised');
});

GbGradeTable.instance.render();
GbGradeTable.instance.render();
};



GbGradeTable.formatCategoryAverage = function(value) {
if (value != null && (value+"").length > 0 && value != "-") {
var valueAsLocaleString = GbGradeTable.localizeNumber(value);
Expand Down Expand Up @@ -3020,13 +3030,16 @@ GbGradeTable.syncCategoryAverage = function(studentId, categoryId, categoryScore

// update dropped status of all items in this category
var categoryItems = GbGradeTable.itemsInCategory(categoryId);
var cellsToRedraw = [];
categoryItems.forEach(function(col) {
var dropped = droppedItems.indexOf(col.assignmentId) > -1;
var columnIndex = GbGradeTable.colForAssignment(col.assignmentId);
var student = GbGradeTable.modelForStudent(studentId);
GbGradeTable.updateHasDroppedScores(student, columnIndex - GbGradeTable.FIXED_COLUMN_OFFSET, dropped);
GbGradeTable.redrawCell(tableRow, columnIndex);
cellsToRedraw.push([tableRow, columnIndex]);
});

GbGradeTable.redrawCells(cellsToRedraw);
};


Expand Down Expand Up @@ -3072,12 +3085,16 @@ GbGradeTable.setScore = function(studentId, assignmentId, oldScore, newScore) {

// update the course grade cell
if (data.courseGrade) {
GbGradeTable.syncCourseGrade(studentId, data.courseGrade);
setTimeout(function () {
GbGradeTable.syncCourseGrade(studentId, data.courseGrade);
}, 0);
}

// update the category average cell
if (assignment.categoryId) {
GbGradeTable.syncCategoryAverage(studentId, assignment.categoryId, data.categoryScore, data.categoryDroppedItems);
setTimeout(function () {
GbGradeTable.syncCategoryAverage(studentId, assignment.categoryId, data.categoryScore, data.categoryDroppedItems);
}, 0);
}

GbGradeTable.syncScore(studentId, assignmentId, newScore);
Expand Down

0 comments on commit b1c75e1

Please sign in to comment.