Skip to content

Commit

Permalink
SAK-41810: Error with Extra point if there is a category 0% (sakaipro…
Browse files Browse the repository at this point in the history
  • Loading branch information
raulsv authored and Miguel Pellicer committed Jul 17, 2019
1 parent 1f839a0 commit 4155a51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3336,8 +3336,8 @@ public void updateGradebookSettings(final String gradebookUid, final GradebookIn
if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY) {
double totalWeight = 0;
for (final CategoryDefinition newDef : newCategoryDefinitions) {

if (newDef.getWeight() == null) {
BigDecimal bg = newDef.getWeight() == null ? null : new BigDecimal(newDef.getWeight());
if (bg == null || bg.compareTo(BigDecimal.ZERO) == 0) {
throw new IllegalArgumentException("No weight specified for a category, but weightings enabled");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public void onValidate() {
BigDecimal totalWeight = BigDecimal.ZERO;
for (final CategoryDefinition cat : categories) {

if (cat.getWeight() == null) {
BigDecimal catWeight = (cat.getWeight() == null) ? null : new BigDecimal(cat.getWeight());
if (catWeight == null || catWeight.compareTo(BigDecimal.ZERO) == 0) {
error(getString("settingspage.update.failure.categorymissingweight"));
} else {
// extra credit items do not participate in the weightings, so exclude from the tally
Expand Down Expand Up @@ -229,6 +230,7 @@ public void onSubmit(final AjaxRequestTarget target, final Form f) {
@Override
public void onError(final AjaxRequestTarget target, final Form<?> form) {
target.add(SettingsPage.this.feedbackPanel);
target.appendJavaScript("scroll(0,0);");// Scroll to the top to see the message error
}
};
form.add(submit);
Expand Down

0 comments on commit 4155a51

Please sign in to comment.