Skip to content

Commit

Permalink
Merge pull request sakaiproject#1437 from steveswinsburg/bug/1436
Browse files Browse the repository at this point in the history
#1436 fix NPE condition in percentage calculation
  • Loading branch information
payten committed Dec 10, 2015
2 parents c6a16af + 74d5232 commit 14aa3ba
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void onSubmit(AjaxRequestTarget target, Form<?> form) {
item.add(remove);
}
};
//categoriesView.setReuseItems(true);
categoriesView.setReuseItems(true);
categoriesWrap.add(categoriesView);
categoriesWrap.setOutputMarkupId(true);
add(categoriesWrap);
Expand All @@ -245,8 +245,9 @@ public void onSubmit(AjaxRequestTarget target, Form<?> form) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> f) {

//add a new category to the model
//add a new empty category to the model
CategoryDefinition cd = new CategoryDefinition();
cd.setExtraCredit(false);
cd.setAssignmentList(Collections.<Assignment> emptyList());

model.getObject().getGradebookInformation().getCategories().add(cd);
Expand All @@ -262,8 +263,14 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> f) {
private Double calculateCategoryWeightTotal(List<CategoryDefinition> categories) {
Double total = new Double(0);
for (CategoryDefinition categoryDefinition : categories) {

Double weight = categoryDefinition.getWeight();
if(weight == null) {
weight = new Double(0);
}

if (!categoryDefinition.isExtraCredit()) {
total += categoryDefinition.getWeight();
total += weight;
}
}
return total;
Expand Down

0 comments on commit 14aa3ba

Please sign in to comment.