use of org.olat.modules.coach.model.GroupStatEntry in project openolat by klemens.
the class CoachingDAO method getGroupsStatisticsNative.
protected List<GroupStatEntry> getGroupsStatisticsNative(Identity coach) {
Map<Long, GroupStatEntry> map = new HashMap<>();
boolean hasGroups = getGroups(coach, map);
if (hasGroups) {
boolean hasCoachedGroups = getGroupsStatisticsInfosForCoach(coach, map);
boolean hasOwnedGroups = getGroupsStatisticsInfosForOwner(coach, map);
for (GroupStatEntry entry : map.values()) {
entry.getRepoIds().clear();
entry.setCountStudents(entry.getCountDistinctStudents() * entry.getCountCourses());
}
if (hasOwnedGroups) {
getGroupsStatisticsStatementForOwner(coach, map);
}
if (hasCoachedGroups) {
getGroupsStatisticsStatementForCoach(coach, map);
}
for (Iterator<Map.Entry<Long, GroupStatEntry>> it = map.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<Long, GroupStatEntry> entry = it.next();
GroupStatEntry groupEntry = entry.getValue();
if (groupEntry.getCountStudents() == 0) {
it.remove();
} else {
groupEntry.setRepoIds(null);
int attempted = groupEntry.getCountPassed() + groupEntry.getCountFailed();
groupEntry.setCountNotAttempted(groupEntry.getCountStudents() - attempted);
if (attempted > 0) {
float averageScore = (float) groupEntry.getSumScore() / attempted;
groupEntry.setAverageScore(averageScore);
}
}
}
}
return new ArrayList<>(map.values());
}
Aggregations