Search in sources :

Example 36 with GroupStatEntry

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());
}
Also used : EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry) RepositoryEntry(org.olat.repository.RepositoryEntry) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry) CourseStatEntry(org.olat.modules.coach.model.CourseStatEntry) GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry)

Aggregations

GroupStatEntry (org.olat.modules.coach.model.GroupStatEntry)36 Test (org.junit.Test)14 CourseStatEntry (org.olat.modules.coach.model.CourseStatEntry)14 StudentStatEntry (org.olat.modules.coach.model.StudentStatEntry)14 RepositoryEntry (org.olat.repository.RepositoryEntry)14 File (java.io.File)12 URL (java.net.URL)12 Identity (org.olat.core.id.Identity)12 BusinessGroup (org.olat.group.BusinessGroup)12 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)12 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)12 NativeQueryBuilder (org.olat.core.commons.persistence.NativeQueryBuilder)10 Date (java.util.Date)8 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 ContextEntry (org.olat.core.id.context.ContextEntry)2 ICourse (org.olat.course.ICourse)2