Search in sources :

Example 41 with StudentStatEntry

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

the class UserListController method nextStudent.

protected void nextStudent(UserRequest ureq) {
    StudentStatEntry currentEntry = studentCtrl.getEntry();
    int nextIndex = model.getObjects().indexOf(currentEntry) + 1;
    if (nextIndex < 0 || nextIndex >= model.getRowCount()) {
        nextIndex = 0;
    }
    StudentStatEntry nextEntry = model.getObject(nextIndex);
    selectStudent(ureq, nextEntry);
}
Also used : StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 42 with StudentStatEntry

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

the class UserListController method selectUniqueStudent.

protected void selectUniqueStudent(UserRequest ureq) {
    if (model.getRowCount() > 0) {
        StudentStatEntry studentStat = model.getObject(0);
        selectStudent(ureq, studentStat);
    }
}
Also used : StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 43 with StudentStatEntry

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

the class CoachingDAO method getStudentsStatisticsNative.

protected List<StudentStatEntry> getStudentsStatisticsNative(Identity coach, List<UserPropertyHandler> userPropertyHandlers) {
    Map<Long, StudentStatEntry> map = new HashMap<>();
    // long start1 = System.nanoTime();
    boolean hasCoachedStudents = getStudentsStastisticInfosForCoach(coach, map, userPropertyHandlers);
    // CodeHelper.printNanoTime(start1, "Coached infos");
    // long start2 = System.nanoTime();
    boolean hasOwnedStudents = getStudentsStastisticInfosForOwner(coach, map, userPropertyHandlers);
    // CodeHelper.printNanoTime(start2, "Owned infos");
    if (hasOwnedStudents || hasCoachedStudents) {
        for (StudentStatEntry entry : map.values()) {
            entry.setCountRepo(entry.getRepoIds().size());
            entry.setRepoIds(null);
            entry.setInitialLaunch(entry.getLaunchIds().size());
            entry.setLaunchIds(null);
        }
        // long start3 = System.nanoTime();
        getStudentsStatisticStatement(coach, hasCoachedStudents, hasOwnedStudents, map);
        // CodeHelper.printNanoTime(start3, "Statistics students");
        for (StudentStatEntry entry : map.values()) {
            int notAttempted = entry.getCountRepo() - entry.getCountPassed() - entry.getCountFailed();
            entry.setCountNotAttempted(notAttempted);
        }
    }
    return new ArrayList<>(map.values());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 44 with StudentStatEntry

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

the class CoachingDAO method getStudentsStatisticStatement.

private boolean getStudentsStatisticStatement(IdentityRef coach, boolean hasCoached, boolean hasOwned, Map<Long, StudentStatEntry> stats) {
    NativeQueryBuilder sb = new NativeQueryBuilder(1024, dbInstance);
    sb.append("select ").append(" fin_statement.fk_identity, ").append("  count(fin_statement.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(" from o_as_eff_statement fin_statement ").append(" where ");
    if (hasCoached) {
        sb.append(" fin_statement.id in ( select ").append("   distinct sg_statement.id as st_id ").append("  from o_repositoryentry sg_re ").append("  inner join o_re_to_group togroup on (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").append("   and sg_coach.fk_identity_id=:coachKey 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 ").append("    on (sg_statement.fk_identity = sg_participant.fk_identity_id and sg_statement.fk_resource_id = sg_re.fk_olatresource) ").append("  where  ( ").append("    (sg_re.accesscode>2) ").append("    or ").append("    (sg_re.accesscode=1 and sg_re.membersonly=").appendTrue().append(")) ").append(" )");
    }
    if (hasOwned) {
        if (hasCoached) {
            sb.append(" or ");
        }
        sb.append("  fin_statement.id in ( select  ").append("    distinct sg_statement.id as st_id ").append("  from o_repositoryentry sg_re ").append("  inner join o_re_to_group owngroup on (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").append("    and sg_owner.g_role='owner' and sg_owner.fk_identity_id=:coachKey and owngroup.r_defgroup=").appendTrue().append(")").append("  inner join o_re_to_group togroup on (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("  inner join o_as_eff_statement sg_statement ").append("    on (sg_statement.fk_identity = sg_participant.fk_identity_id and sg_statement.fk_resource_id = sg_re.fk_olatresource) ").append("  where sg_re.accesscode>=").append(RepositoryEntry.ACC_OWNERS).append(") ");
    }
    sb.append(" group by fin_statement.fk_identity");
    List<?> rawList = dbInstance.getCurrentEntityManager().createNativeQuery(sb.toString()).setParameter("coachKey", coach.getKey()).getResultList();
    for (Object rawObject : rawList) {
        Object[] rawStat = (Object[]) rawObject;
        Long identityKey = ((Number) rawStat[0]).longValue();
        StudentStatEntry entry = stats.get(identityKey);
        if (entry != null) {
            int passed = ((Number) rawStat[2]).intValue();
            int failed = ((Number) rawStat[3]).intValue();
            entry.setCountPassed(passed);
            entry.setCountFailed(failed);
        }
    }
    return rawList.size() > 0;
}
Also used : NativeQueryBuilder(org.olat.core.commons.persistence.NativeQueryBuilder) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Example 45 with StudentStatEntry

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

the class CoachingDAO method getStudentsStastisticInfosForCoach.

private boolean getStudentsStastisticInfosForCoach(IdentityRef coach, Map<Long, StudentStatEntry> map, List<UserPropertyHandler> userPropertyHandlers) {
    NativeQueryBuilder sb = new NativeQueryBuilder(1024, dbInstance);
    sb.append("select").append("  sg_participant_id.id as part_id,").append("  sg_participant_id.name as part_name,").append("  sg_participant_user.user_id as part_user_id,");
    writeUserProperties("sg_participant_user", sb, userPropertyHandlers);
    sb.append("  ").appendToArray("sg_re.repositoryentry_id").append(" as re_ids,").append("  ").appendToArray("pg_initial_launch.id").append(" as pg_ids").append(" from o_repositoryentry sg_re").append(" inner join o_olatresource sg_res on (sg_res.resource_id = sg_re.fk_olatresource and sg_res.resname = 'CourseModule') ").append(" inner join o_re_to_group togroup on (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_bs_identity sg_participant_id on (sg_participant_id.id=sg_participant.fk_identity_id)").append(" inner join o_user sg_participant_user on (sg_participant_user.fk_identity=sg_participant_id.id)").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_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(" group by sg_participant_id.id, sg_participant_user.user_id");
    if (dbInstance.isOracle()) {
        sb.append(", sg_participant_id.name");
        writeUserPropertiesGroupBy("sg_participant_user", sb, userPropertyHandlers);
    }
    List<?> rawList = dbInstance.getCurrentEntityManager().createNativeQuery(sb.toString()).setParameter("coachKey", coach.getKey()).getResultList();
    int numOfProperties = userPropertyHandlers.size();
    for (Object rawObject : rawList) {
        Object[] rawStat = (Object[]) rawObject;
        int pos = 0;
        Long identityKey = ((Number) rawStat[pos++]).longValue();
        String identityName = (String) rawStat[pos++];
        // user key
        ((Number) rawStat[pos++]).longValue();
        String[] userProperties = new String[numOfProperties];
        for (int i = 0; i < numOfProperties; i++) {
            userProperties[i] = (String) rawStat[pos++];
        }
        StudentStatEntry entry = new StudentStatEntry(identityKey, identityName, userProperties);
        appendArrayToSet(rawStat[pos++], entry.getRepoIds());
        appendArrayToSet(rawStat[pos++], entry.getLaunchIds());
        map.put(entry.getIdentityKey(), entry);
    }
    return rawList.size() > 0;
}
Also used : NativeQueryBuilder(org.olat.core.commons.persistence.NativeQueryBuilder) StudentStatEntry(org.olat.modules.coach.model.StudentStatEntry)

Aggregations

StudentStatEntry (org.olat.modules.coach.model.StudentStatEntry)46 Test (org.junit.Test)16 File (java.io.File)14 URL (java.net.URL)14 Identity (org.olat.core.id.Identity)14 BusinessGroup (org.olat.group.BusinessGroup)14 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)14 RepositoryEntry (org.olat.repository.RepositoryEntry)14 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)14 CourseStatEntry (org.olat.modules.coach.model.CourseStatEntry)12 GroupStatEntry (org.olat.modules.coach.model.GroupStatEntry)12 Date (java.util.Date)10 HashMap (java.util.HashMap)10 NativeQueryBuilder (org.olat.core.commons.persistence.NativeQueryBuilder)10 Map (java.util.Map)4 Query (javax.persistence.Query)4 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)4 SearchCoachedIdentityParams (org.olat.modules.coach.model.SearchCoachedIdentityParams)4 ArrayList (java.util.ArrayList)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2