Skip to content

Commit

Permalink
SAK-42535 - Format the grade input before attempting to validate sinc…
Browse files Browse the repository at this point in the history
…e a double with no leading 0 fails validation (sakaiproject#7605)
  • Loading branch information
maurercw authored and ern committed Dec 2, 2019
1 parent 2e44b8b commit 387aeee
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,16 @@ public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget

final String rawOldGrade = params.get("oldScore").textValue();
final String rawNewGrade = params.get("newScore").textValue();
final String oldGrade = FormatHelper.formatGradeFromUserLocale(rawOldGrade);
final String newGrade = FormatHelper.formatGradeFromUserLocale(rawNewGrade);

if (StringUtils.isNotBlank(rawNewGrade)
&& (!NumberUtil.isValidLocaleDouble(rawNewGrade) || FormatHelper.validateDouble(rawNewGrade) < 0)) {
if (StringUtils.isNotBlank(newGrade)
&& (!NumberUtil.isValidLocaleDouble(newGrade) || FormatHelper.validateDouble(newGrade) < 0)) {
target.add(page.updateLiveGradingMessage(page.getString("feedback.error")));

return new ArgumentErrorResponse("Grade not valid");
}

final String oldGrade = FormatHelper.formatGradeFromUserLocale(rawOldGrade);
final String newGrade = FormatHelper.formatGradeFromUserLocale(rawNewGrade);

final String assignmentId = params.get("assignmentId").asText();
final String studentUuid = params.get("studentId").asText();
final String categoryId = params.has("categoryId") ? params.get("categoryId").asText() : null;
Expand Down

0 comments on commit 387aeee

Please sign in to comment.