Skip to content
Snippets Groups Projects

Resolve "Off by one in the statistics page"

1 file
+ 8
4
Compare changes
  • Side-by-side
  • Inline
@@ -402,9 +402,11 @@ public class StatisticsService {
@@ -402,9 +402,11 @@ public class StatisticsService {
: gradeType == Grade.SchemeEnum.DUTCH_GRADE || gradeType == Grade.SchemeEnum.DUTCH_GRADE_1000
: gradeType == Grade.SchemeEnum.DUTCH_GRADE || gradeType == Grade.SchemeEnum.DUTCH_GRADE_1000
? 10
? 10
: gradeService.getMaxScore(gradeType);
: gradeService.getMaxScore(gradeType);
Integer[] distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Integer[] distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
grades.forEach(score -> distribution[((int) (score.getScore() * 10.0 / max))]++);
grades.forEach(score -> distribution[((int) (score.getScore() * 10.0 / max))]++);
return distribution;
Integer[] oneTenDist = Arrays.copyOfRange(distribution, 0, 10);
 
oneTenDist[9] += distribution[10];
 
return oneTenDist;
}
}
private Integer[] getScoreDistribution(Map<StudentGroupSummaryDTO, GradeSummaryDTO> grades,
private Integer[] getScoreDistribution(Map<StudentGroupSummaryDTO, GradeSummaryDTO> grades,
@@ -415,10 +417,12 @@ public class StatisticsService {
@@ -415,10 +417,12 @@ public class StatisticsService {
? grades.values().stream().max(Comparator.comparing(GradeSummaryDTO::getScore)).get()
? grades.values().stream().max(Comparator.comparing(GradeSummaryDTO::getScore)).get()
.getScore()
.getScore()
: gradeService.getMaxScore(gradeType);
: gradeService.getMaxScore(gradeType);
Integer[] distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Integer[] distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
grades.forEach((group, score) -> distribution[((int) (score.getScore() * 10.0 / max))] += group
grades.forEach((group, score) -> distribution[((int) (score.getScore() * 10.0 / max))] += group
.getMemberUsernames().size());
.getMemberUsernames().size());
return distribution;
Integer[] oneTenDist = Arrays.copyOfRange(distribution, 0, 10);
 
oneTenDist[9] += distribution[10];
 
return oneTenDist;
}
}
}
}
Loading