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;
}
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;
}
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);
}
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);
}
}
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;
}
Aggregations