Skip to content

Commit

Permalink
2471: only flash the course grade or category average if the value of…
Browse files Browse the repository at this point in the history
… the cell actually changes
  • Loading branch information
payten committed May 6, 2016
1 parent 6a2107d commit 4371043
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ public void onEvent(final IEvent<?> event) {

final String newCategoryAverage = (categoryAverage == null) ? getString("label.nocategoryscore")
: FormatHelper.formatDoubleAsPercentage(categoryAverage);
setDefaultModel(Model.of(newCategoryAverage));

getParent().add(new AttributeAppender("class", "gb-score-dynamically-updated"));
if (!newCategoryAverage.equals(getDefaultModelObject())) {
setDefaultModel(Model.of(newCategoryAverage));

scoreChangedEvent.getTarget().add(this);
scoreChangedEvent.getTarget().appendJavaScript(
getParent().add(new AttributeAppender("class", "gb-score-dynamically-updated"));

scoreChangedEvent.getTarget().add(this);
scoreChangedEvent.getTarget().appendJavaScript(
String.format("$('#%s').closest('td').addClass('gb-score-dynamically-updated');",
this.getMarkupId()));
this.getMarkupId()));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ public void onEvent(final IEvent<?> event) {

final String newCourseGradeDisplay = refreshCourseGrade(studentUuid, gradebook, role, courseGradeVisible,
showPoints, showOverride);
setDefaultModel(Model.of(newCourseGradeDisplay));

scoreChangedEvent.getTarget().add(this);
scoreChangedEvent.getTarget().appendJavaScript(
// if course grade has changed, then refresh it
if (!newCourseGradeDisplay.equals(getDefaultModelObject())) {
setDefaultModel(Model.of(newCourseGradeDisplay));

scoreChangedEvent.getTarget().add(this);
scoreChangedEvent.getTarget().appendJavaScript(
String.format("$('#%s').closest('td').addClass('gb-score-dynamically-updated');", this.getMarkupId()));
}
}
}
}
Expand Down

0 comments on commit 4371043

Please sign in to comment.