Skip to content

Commit

Permalink
SAK-31861 Validation error entering a grade (spanish language) (sakai…
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrogj authored and juanjmerono committed Oct 17, 2016
1 parent b3c4993 commit d3b2a2c
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 @@ -1975,17 +1975,18 @@ private boolean isGradeValid(String grade, int gradeEntryType, LetterGradePercen
try {
NumberFormat nbFormat = NumberFormat.getInstance(new ResourceLoader().getLocale());
Double gradeAsDouble = new Double (nbFormat.parse(grade).doubleValue());
String decSeparator =((DecimalFormat)nbFormat).getDecimalFormatSymbols().getDecimalSeparator()+"";
// grade must be greater than or equal to 0
if (gradeAsDouble.doubleValue() >= 0) {
String[] splitOnDecimal = grade.split("\\.");
String[] splitOnDecimal = grade.split("\\"+decSeparator);
// check that there are no more than 2 decimal places
if (splitOnDecimal == null) {
gradeIsValid = true;

// check for a valid score matching ##########.##
// where integer is maximum of 10 integers in length
// and maximum of 2 decimal places
} else if (grade.matches("[0-9]{0,10}(\\.[0-9]{0,2})?")) {
} else if (grade.matches("[0-9]{0,10}(\\"+decSeparator+"[0-9]{0,2})?")) {
gradeIsValid = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4501,7 +4501,8 @@ private void setUpGradeInformation(String gradebookUid, String selAssignmentName
GradeDefinition gradeDef = gradebookService.getGradeDefinitionForStudentForItem(gradebookUid, assign.getId(), studentId);

if (gradeDef.getGrade() != null) {
gbItemScore = gradeDef.getGrade();
String decSeparator = FormattedText.getDecimalSeparator();
gbItemScore = StringUtils.replace(gradeDef.getGrade(), (",".equals(decSeparator)?".":","), decSeparator);
}

if (gradeDef.getGradeComment() != null) {
Expand Down

0 comments on commit d3b2a2c

Please sign in to comment.