Search in sources :

Example 31 with GroupStatEntry

use of org.olat.modules.coach.model.GroupStatEntry in project openolat by klemens.

the class GroupListController method nextGroup.

protected void nextGroup(UserRequest ureq) {
    GroupStatEntry currentEntry = groupCtrl.getEntry();
    int nextIndex = tableCtr.getIndexOfSortedObject(currentEntry) + 1;
    if (nextIndex < 0 || nextIndex >= tableCtr.getRowCount()) {
        nextIndex = 0;
    }
    GroupStatEntry nextEntry = (GroupStatEntry) tableCtr.getSortedObjectAt(nextIndex);
    selectGroup(ureq, nextEntry);
}
Also used : GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry)

Example 32 with GroupStatEntry

use of org.olat.modules.coach.model.GroupStatEntry in project openolat by klemens.

the class GroupListController method previousGroup.

protected void previousGroup(UserRequest ureq) {
    GroupStatEntry currentEntry = groupCtrl.getEntry();
    int previousIndex = tableCtr.getIndexOfSortedObject(currentEntry) - 1;
    if (previousIndex < 0 || previousIndex >= tableCtr.getRowCount()) {
        previousIndex = tableCtr.getRowCount() - 1;
    }
    GroupStatEntry previousEntry = (GroupStatEntry) tableCtr.getSortedObjectAt(previousIndex);
    selectGroup(ureq, previousEntry);
}
Also used : GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry)

Example 33 with GroupStatEntry

use of org.olat.modules.coach.model.GroupStatEntry in project openolat by klemens.

the class GroupsTableDataModel method getValueAt.

@Override
public Object getValueAt(int row, int col) {
    GroupStatEntry g = groups.get(row);
    int numOfStudents = g.getCountStudents();
    switch(Columns.getValueAt(col)) {
        case name:
            {
                return g.getGroupName();
            }
        case countCourses:
            {
                return new Integer(g.getCountCourses());
            }
        case countStudents:
            {
                return new Integer(numOfStudents);
            }
        case initialLaunch:
            {
                int count = g.getCountCourses() * g.getCountStudents();
                if (count == 0) {
                    return new LightedValue(null, Light.grey);
                }
                int launch = g.getInitialLaunch();
                Light light = Light.yellow;
                if (launch == count) {
                    light = Light.green;
                } else if (launch == 0) {
                    light = Light.red;
                }
                return new LightedValue(launch, light);
            }
        case countPassed:
            {
                if (numOfStudents == 0) {
                    return numOfStudents;
                }
                ProgressValue val = new ProgressValue();
                val.setTotal(numOfStudents);
                val.setGreen(g.getCountPassed());
                return val;
            }
        case countPassedLight:
            {
                if (numOfStudents == 0) {
                    return new LightedValue(null, Light.grey);
                }
                int passed = g.getCountPassed();
                Light light = Light.yellow;
                if (passed == numOfStudents) {
                    light = Light.green;
                } else if (passed == 0) {
                    light = Light.red;
                }
                return new LightedValue(passed, light);
            }
        case averageScore:
            return g.getAverageScore();
        case statistics:
            {
                return g;
            }
    }
    return null;
}
Also used : ProgressValue(org.olat.modules.coach.ui.ProgressValue) Light(org.olat.modules.coach.ui.LightedValue.Light) GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry)

Example 34 with GroupStatEntry

use of org.olat.modules.coach.model.GroupStatEntry in project openolat by klemens.

the class CoachingDAO method getGroupsStatisticsStatementForCoach.

private boolean getGroupsStatisticsStatementForCoach(Identity coach, Map<Long, GroupStatEntry> map) {
    NativeQueryBuilder sb = new NativeQueryBuilder(1024, dbInstance);
    sb.append("select").append(" fin_statement.bgp_id,").append(" fin_statement.re_id,").append(" sum(case when fin_statement.passed=").appendTrue().append(" then 1 else 0 end) as num_of_passed,").append(" sum(case when fin_statement.passed=").appendFalse().append(" then 1 else 0 end) as num_of_failed,").append(" sum(fin_statement.score) as avg_score ").append("from ( select ").append("  distinct sg_statement.id as id,").append("  togroup.fk_group_id as bgp_id,").append("  togroup.fk_entry_id as re_id,").append("  sg_statement.passed as passed,").append("  sg_statement.score as score ").append(" from o_repositoryentry sg_re ").append(" inner join o_re_to_group togroup on (togroup.r_defgroup=").appendFalse().append(" and togroup.fk_entry_id = sg_re.repositoryentry_id) ").append(" inner join o_bs_group_member sg_coach on (sg_coach.fk_group_id=togroup.fk_group_id and sg_coach.g_role = 'coach') ").append(" inner join o_bs_group_member sg_participant on (sg_participant.fk_group_id=sg_coach.fk_group_id and sg_participant.g_role='participant') ").append(" inner join o_as_eff_statement sg_statement on (sg_statement.fk_identity = sg_participant.fk_identity_id and sg_statement.fk_resource_id = sg_re.fk_olatresource) ").append(" where sg_coach.fk_identity_id=:coachKey and ( ").append("   (sg_re.accesscode >= ").append(RepositoryEntry.ACC_USERS).append(// BAR
    " and sg_coach.g_role = 'coach') ").append("   or ").append("   (sg_re.accesscode = ").append(RepositoryEntry.ACC_OWNERS).append(" and sg_re.membersonly=").appendTrue().append(")) ").append(") ").appendAs().append(" fin_statement ").append("group by fin_statement.bgp_id, fin_statement.re_id ");
    List<?> rawList = dbInstance.getCurrentEntityManager().createNativeQuery(sb.toString()).setParameter("coachKey", coach.getKey()).getResultList();
    for (Object rawObject : rawList) {
        Object[] rawStats = (Object[]) rawObject;
        Long baseGroupKey = ((Number) rawStats[0]).longValue();
        Long repoKey = ((Number) rawStats[1]).longValue();
        GroupStatEntry entry = map.get(baseGroupKey);
        if (entry != null && !entry.getRepoIds().contains(repoKey)) {
            int passed = ((Number) rawStats[2]).intValue();
            int failed = ((Number) rawStats[3]).intValue();
            entry.setCountFailed(failed + entry.getCountFailed());
            entry.setCountPassed(passed + entry.getCountPassed());
            if (rawStats[4] != null) {
                entry.setSumScore(entry.getSumScore() + ((Number) rawStats[4]).floatValue());
            }
            entry.getRepoIds().add(repoKey);
        }
    }
    return rawList.size() > 0;
}
Also used : NativeQueryBuilder(org.olat.core.commons.persistence.NativeQueryBuilder) GroupStatEntry(org.olat.modules.coach.model.GroupStatEntry)

Example 35 with GroupStatEntry

use of org.olat.modules.coach.model.GroupStatEntry in project openolat by klemens.

the class CoachingDAO method getGroupsStatisticsInfosForOwner.

private boolean getGroupsStatisticsInfosForOwner(Identity coach, Map<Long, GroupStatEntry> map) {
    NativeQueryBuilder sb = new NativeQueryBuilder(1024, dbInstance);
    sb.append("select ").append("  togroup.fk_group_id as basegr_id, ").append("  togroup.fk_entry_id as re_id, ").append("  count(distinct pg_initial_launch.id) as pg_id ").append(" from o_repositoryentry sg_re  ").append(" inner join o_re_to_group owngroup on (owngroup.r_defgroup=").appendTrue().append(" and owngroup.fk_entry_id = sg_re.repositoryentry_id) ").append(" inner join o_bs_group_member sg_owner on (sg_owner.fk_group_id=owngroup.fk_group_id and sg_owner.g_role = 'owner') ").append(" inner join o_re_to_group togroup on (togroup.r_defgroup=").appendFalse().append(" and togroup.fk_entry_id = sg_re.repositoryentry_id) ").append(" inner join o_bs_group_member sg_participant on (sg_participant.fk_group_id=togroup.fk_group_id and sg_participant.g_role='participant') ").append(" left join o_as_user_course_infos pg_initial_launch ").append("   on (pg_initial_launch.fk_resource_id = sg_re.fk_olatresource and pg_initial_launch.fk_identity = sg_participant.fk_identity_id) ").append(" where sg_owner.fk_identity_id=:coachKey and sg_re.accesscode >= ").append(RepositoryEntry.ACC_OWNERS).append(" group by togroup.fk_group_id, togroup.fk_entry_id ");
    List<?> rawList = dbInstance.getCurrentEntityManager().createNativeQuery(sb.toString()).setParameter("coachKey", coach.getKey()).getResultList();
    for (Object rawObject : rawList) {
        Object[] rawStats = (Object[]) rawObject;
        Long baseGroupKey = ((Number) rawStats[0]).longValue();
        GroupStatEntry entry = map.get(baseGroupKey);
        if (entry != null) {
            Long repoKey = ((Number) rawStats[1]).longValue();
            if (!entry.getRepoIds().contains(repoKey)) {
                int initalLaunch = ((Number) rawStats[2]).intValue();
                entry.setInitialLaunch(initalLaunch + entry.getInitialLaunch());
                entry.setCountCourses(entry.getCountCourses() + 1);
                entry.getRepoIds().add(repoKey);
            }
        }
    }
    return rawList.size() > 0;
}
Also used : NativeQueryBuilder(org.olat.core.commons.persistence.NativeQueryBuilder) 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