Search in sources :

Example 16 with LectureBlockStatistics

use of org.olat.modules.lecture.model.LectureBlockStatistics in project OpenOLAT by OpenOLAT.

the class LectureBlockRollCallDAO method getStatistics.

public List<LectureBlockStatistics> getStatistics(RepositoryEntry entry, RepositoryEntryLectureConfiguration config, boolean authorizedAbsenceEnabled, boolean absenceDefaultAuthorized, boolean countAuthorizedAbsenceAsAttendant, boolean calculateAttendanceRate, double requiredAttendanceRateDefault) {
    StringBuilder sb = new StringBuilder();
    sb.append("select ident.key as participantKey, ").append("  call.lecturesAttendedNumber as attendedLectures,").append("  call.lecturesAbsentNumber as absentLectures,").append("  call.absenceAuthorized as absenceAuthorized,").append("  block.key as blockKey,").append("  block.compulsory as compulsory,").append("  block.plannedLecturesNumber as blockPlanned,").append("  block.effectiveLecturesNumber as blockEffective,").append("  block.statusString as status,").append("  block.rollCallStatusString as rollCallStatus,").append("  block.endDate as rollCallEndDate,").append("  summary.firstAdmissionDate as firstAdmissionDate,").append("  summary.requiredAttendanceRate as summaryRate").append(" from lectureblock block").append(" inner join block.groups blockToGroup").append(" inner join blockToGroup.group bGroup").append(" inner join bGroup.members membership").append(" inner join membership.identity ident").append(" left join lectureblockrollcall as call on (call.identity.key=membership.identity.key and call.lectureBlock.key=block.key)").append(" left join lectureparticipantsummary as summary on (summary.identity.key=membership.identity.key and summary.entry.key=block.entry.key)").append(" where block.entry.key=:entryKey and membership.role='").append(GroupRoles.participant.name()).append("'");
    Date now = new Date();
    Boolean repoCalculateRate = null;
    Double repoRequiredRate = null;
    if (config != null && config.isOverrideModuleDefault()) {
        repoCalculateRate = config.getCalculateAttendanceRate();
        repoRequiredRate = config.getRequiredAttendanceRate();
    }
    List<Object[]> rawObjects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("entryKey", entry.getKey()).getResultList();
    Map<Long, LectureBlockStatistics> stats = new HashMap<>();
    for (Object[] rawObject : rawObjects) {
        // jump roll call key
        int pos = 0;
        Long identityKey = (Long) rawObject[pos++];
        Long lecturesAttended = PersistenceHelper.extractLong(rawObject, pos++);
        Long lecturesAbsent = PersistenceHelper.extractLong(rawObject, pos++);
        Boolean absenceAuthorized;
        if (authorizedAbsenceEnabled) {
            absenceAuthorized = (Boolean) rawObject[pos++];
        } else {
            absenceAuthorized = null;
            pos++;
        }
        // jump block key
        pos++;
        boolean compulsory = PersistenceHelper.extractBoolean(rawObject, pos++, true);
        Long plannedLecturesNumber = PersistenceHelper.extractLong(rawObject, pos++);
        Long effectiveLecturesNumber = PersistenceHelper.extractLong(rawObject, pos++);
        if (effectiveLecturesNumber == null) {
            effectiveLecturesNumber = plannedLecturesNumber;
        }
        String status = (String) rawObject[pos++];
        String rollCallStatus = (String) rawObject[pos++];
        Date rollCallEndDate = (Date) rawObject[pos++];
        Date firstAdmissionDate = (Date) rawObject[pos++];
        Double persoRequiredRate = (Double) rawObject[pos++];
        LectureBlockStatistics entryStatistics;
        if (stats.containsKey(identityKey)) {
            entryStatistics = stats.get(identityKey);
        } else {
            entryStatistics = create(identityKey, entry.getKey(), entry.getDisplayname(), entry.getExternalRef(), config.isOverrideModuleDefault(), repoCalculateRate, repoRequiredRate, persoRequiredRate, calculateAttendanceRate, requiredAttendanceRateDefault);
            stats.put(identityKey, entryStatistics);
        }
        appendStatistics(entryStatistics, compulsory, status, rollCallEndDate, rollCallStatus, lecturesAttended, lecturesAbsent, absenceAuthorized, absenceDefaultAuthorized, plannedLecturesNumber, effectiveLecturesNumber, firstAdmissionDate, now);
    }
    List<LectureBlockStatistics> statisticsList = new ArrayList<>(stats.values());
    calculateAttendanceRate(statisticsList, countAuthorizedAbsenceAsAttendant);
    return statisticsList;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) Date(java.util.Date)

Example 17 with LectureBlockStatistics

use of org.olat.modules.lecture.model.LectureBlockStatistics in project OpenOLAT by OpenOLAT.

the class StudentCoursesController method loadModel.

private List<EfficiencyStatementEntry> loadModel() {
    List<RepositoryEntry> courses = fullAccess ? coachingService.getUserCourses(student) : coachingService.getStudentsCourses(getIdentity(), student);
    List<EfficiencyStatementEntry> statements = coachingService.getEfficencyStatements(student, courses, userPropertyHandlers, getLocale());
    List<CertificateLight> certificates = certificatesManager.getLastCertificates(student);
    ConcurrentMap<IdentityResourceKey, CertificateLight> certificateMap = new ConcurrentHashMap<>();
    for (CertificateLight certificate : certificates) {
        IdentityResourceKey key = new IdentityResourceKey(student.getKey(), certificate.getOlatResourceKey());
        certificateMap.put(key, certificate);
    }
    ConcurrentMap<IdentityRepositoryEntryKey, LectureBlockStatistics> lecturesMap = new ConcurrentHashMap<>();
    if (lectureModule.isEnabled()) {
        List<LectureBlockStatistics> lectureStats = lectureService.getParticipantLecturesStatistics(student);
        for (LectureBlockStatistics lectureStat : lectureStats) {
            IdentityRepositoryEntryKey key = new IdentityRepositoryEntryKey(student.getKey(), lectureStat.getRepoKey());
            lecturesMap.put(key, lectureStat);
        }
    }
    model.setObjects(statements, certificateMap, lecturesMap);
    tableEl.reset();
    tableEl.reloadData();
    return statements;
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) CertificateLight(org.olat.course.certificate.CertificateLight) IdentityResourceKey(org.olat.modules.coach.model.IdentityResourceKey) IdentityRepositoryEntryKey(org.olat.modules.coach.model.IdentityRepositoryEntryKey) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 18 with LectureBlockStatistics

use of org.olat.modules.lecture.model.LectureBlockStatistics in project OpenOLAT by OpenOLAT.

the class ParticipantLecturesOverviewController method loadModel.

private void loadModel() {
    List<LectureBlockStatistics> statistics = lectureService.getParticipantLecturesStatistics(assessedIdentity);
    AggregatedLectureBlocksStatistics total = lectureService.aggregatedStatistics(statistics);
    tableModel.setObjects(statistics, total);
    tableEl.reset(true, true, true);
}
Also used : AggregatedLectureBlocksStatistics(org.olat.modules.lecture.model.AggregatedLectureBlocksStatistics) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics)

Example 19 with LectureBlockStatistics

use of org.olat.modules.lecture.model.LectureBlockStatistics in project OpenOLAT by OpenOLAT.

the class LectureStatisticsCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
    if (cellValue instanceof LectureBlockStatistics) {
        LectureBlockStatistics stats = (LectureBlockStatistics) cellValue;
        long total = stats.getTotalPersonalPlannedLectures();
        long attended = stats.getTotalAttendedLectures();
        long absent = stats.getTotalAbsentLectures();
        long authorizedAbsent = stats.getTotalAuthorizedAbsentLectures();
        render(target, total, attended, absent, authorizedAbsent);
    }
}
Also used : LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics)

Example 20 with LectureBlockStatistics

use of org.olat.modules.lecture.model.LectureBlockStatistics in project openolat by klemens.

the class LectureBlockRollCallDAO method getStatistics.

public List<LectureBlockStatistics> getStatistics(RepositoryEntry entry, RepositoryEntryLectureConfiguration config, boolean authorizedAbsenceEnabled, boolean absenceDefaultAuthorized, boolean countAuthorizedAbsenceAsAttendant, boolean calculateAttendanceRate, double requiredAttendanceRateDefault) {
    StringBuilder sb = new StringBuilder();
    sb.append("select ident.key as participantKey, ").append("  call.lecturesAttendedNumber as attendedLectures,").append("  call.lecturesAbsentNumber as absentLectures,").append("  call.absenceAuthorized as absenceAuthorized,").append("  block.key as blockKey,").append("  block.compulsory as compulsory,").append("  block.plannedLecturesNumber as blockPlanned,").append("  block.effectiveLecturesNumber as blockEffective,").append("  block.statusString as status,").append("  block.rollCallStatusString as rollCallStatus,").append("  block.endDate as rollCallEndDate,").append("  summary.firstAdmissionDate as firstAdmissionDate,").append("  summary.requiredAttendanceRate as summaryRate").append(" from lectureblock block").append(" inner join block.groups blockToGroup").append(" inner join blockToGroup.group bGroup").append(" inner join bGroup.members membership").append(" inner join membership.identity ident").append(" left join lectureblockrollcall as call on (call.identity.key=membership.identity.key and call.lectureBlock.key=block.key)").append(" left join lectureparticipantsummary as summary on (summary.identity.key=membership.identity.key and summary.entry.key=block.entry.key)").append(" where block.entry.key=:entryKey and membership.role='").append(GroupRoles.participant.name()).append("'");
    Date now = new Date();
    Boolean repoCalculateRate = null;
    Double repoRequiredRate = null;
    if (config != null && config.isOverrideModuleDefault()) {
        repoCalculateRate = config.getCalculateAttendanceRate();
        repoRequiredRate = config.getRequiredAttendanceRate();
    }
    List<Object[]> rawObjects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("entryKey", entry.getKey()).getResultList();
    Map<Long, LectureBlockStatistics> stats = new HashMap<>();
    for (Object[] rawObject : rawObjects) {
        // jump roll call key
        int pos = 0;
        Long identityKey = (Long) rawObject[pos++];
        Long lecturesAttended = PersistenceHelper.extractLong(rawObject, pos++);
        Long lecturesAbsent = PersistenceHelper.extractLong(rawObject, pos++);
        Boolean absenceAuthorized;
        if (authorizedAbsenceEnabled) {
            absenceAuthorized = (Boolean) rawObject[pos++];
        } else {
            absenceAuthorized = null;
            pos++;
        }
        // jump block key
        pos++;
        boolean compulsory = PersistenceHelper.extractBoolean(rawObject, pos++, true);
        Long plannedLecturesNumber = PersistenceHelper.extractLong(rawObject, pos++);
        Long effectiveLecturesNumber = PersistenceHelper.extractLong(rawObject, pos++);
        if (effectiveLecturesNumber == null) {
            effectiveLecturesNumber = plannedLecturesNumber;
        }
        String status = (String) rawObject[pos++];
        String rollCallStatus = (String) rawObject[pos++];
        Date rollCallEndDate = (Date) rawObject[pos++];
        Date firstAdmissionDate = (Date) rawObject[pos++];
        Double persoRequiredRate = (Double) rawObject[pos++];
        LectureBlockStatistics entryStatistics;
        if (stats.containsKey(identityKey)) {
            entryStatistics = stats.get(identityKey);
        } else {
            entryStatistics = create(identityKey, entry.getKey(), entry.getDisplayname(), entry.getExternalRef(), config.isOverrideModuleDefault(), repoCalculateRate, repoRequiredRate, persoRequiredRate, calculateAttendanceRate, requiredAttendanceRateDefault);
            stats.put(identityKey, entryStatistics);
        }
        appendStatistics(entryStatistics, compulsory, status, rollCallEndDate, rollCallStatus, lecturesAttended, lecturesAbsent, absenceAuthorized, absenceDefaultAuthorized, plannedLecturesNumber, effectiveLecturesNumber, firstAdmissionDate, now);
    }
    List<LectureBlockStatistics> statisticsList = new ArrayList<>(stats.values());
    calculateAttendanceRate(statisticsList, countAuthorizedAbsenceAsAttendant);
    return statisticsList;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) Date(java.util.Date)

Aggregations

LectureBlockStatistics (org.olat.modules.lecture.model.LectureBlockStatistics)24 Identity (org.olat.core.id.Identity)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 RepositoryEntryLectureConfiguration (org.olat.modules.lecture.RepositoryEntryLectureConfiguration)6 Test (org.junit.Test)4 Group (org.olat.basesecurity.Group)4 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)4 BusinessGroup (org.olat.group.BusinessGroup)4 LectureBlock (org.olat.modules.lecture.LectureBlock)4 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)4 AggregatedLectureBlocksStatistics (org.olat.modules.lecture.model.AggregatedLectureBlocksStatistics)4 HashMap (java.util.HashMap)3 Calendar (java.util.Calendar)2 List (java.util.List)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Collectors (java.util.stream.Collectors)2 BaseSecurity (org.olat.basesecurity.BaseSecurity)2