use of org.olat.modules.lecture.model.LectureBlockStatistics in project OpenOLAT by OpenOLAT.
the class LectureServiceTest method getParticipantLecturesStatistics.
@Test
public void getParticipantLecturesStatistics() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-2");
// a closed lecture block in the past
LectureBlock lectureBlock1 = createClosedLectureBlockInPast(entry);
LectureBlock lectureBlock2 = createClosedLectureBlockInPast(entry);
LectureBlock lectureBlock3 = createClosedLectureBlockInPast(entry);
// create summary in the past
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -4);
lectureParticipantSummaryDao.createSummary(entry, participant1, cal.getTime());
lectureParticipantSummaryDao.createSummary(entry, participant2, cal.getTime());
// add participants to the "course"
repositoryEntryRelationDAO.addRole(participant1, entry, GroupRole.participant.name());
repositoryEntryRelationDAO.addRole(participant2, entry, GroupRole.participant.name());
dbInstance.commitAndCloseSession();
RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
config.setLectureEnabled(true);
lectureService.updateRepositoryEntryLectureConfiguration(config);
// add the course to the lectures
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock1 = lectureService.save(lectureBlock1, Collections.singletonList(defGroup));
lectureBlock2 = lectureService.save(lectureBlock2, Collections.singletonList(defGroup));
lectureBlock3 = lectureService.save(lectureBlock3, Collections.singletonList(defGroup));
dbInstance.commitAndCloseSession();
lectureService.addRollCall(participant1, lectureBlock1, null, toList(1, 2));
lectureService.addRollCall(participant1, lectureBlock2, null, toList(1, 2, 3, 4));
lectureService.addRollCall(participant2, lectureBlock1, null, toList(1, 2, 3, 4));
lectureService.addRollCall(participant2, lectureBlock3, null, toList(2, 3, 4));
dbInstance.commitAndCloseSession();
// check first participant
List<LectureBlockStatistics> statistics_1 = lectureService.getParticipantLecturesStatistics(participant1);
Assert.assertNotNull(statistics_1);
Assert.assertEquals(1, statistics_1.size());
LectureBlockStatistics statistic_1 = statistics_1.get(0);
Assert.assertEquals(12, statistic_1.getTotalPersonalPlannedLectures());
Assert.assertEquals(2, statistic_1.getTotalAttendedLectures());
Assert.assertEquals(6, statistic_1.getTotalAbsentLectures());
// check second participant
List<LectureBlockStatistics> statistics_2 = lectureService.getParticipantLecturesStatistics(participant2);
Assert.assertNotNull(statistics_2);
Assert.assertEquals(1, statistics_2.size());
LectureBlockStatistics statistic_2 = statistics_2.get(0);
Assert.assertEquals(12, statistic_2.getTotalPersonalPlannedLectures());
Assert.assertEquals(1, statistic_2.getTotalAttendedLectures());
Assert.assertEquals(7, statistic_2.getTotalAbsentLectures());
}
use of org.olat.modules.lecture.model.LectureBlockStatistics in project openolat by klemens.
the class LectureServiceTest method getParticipantLecturesStatistics.
@Test
public void getParticipantLecturesStatistics() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-2");
// a closed lecture block in the past
LectureBlock lectureBlock1 = createClosedLectureBlockInPast(entry);
LectureBlock lectureBlock2 = createClosedLectureBlockInPast(entry);
LectureBlock lectureBlock3 = createClosedLectureBlockInPast(entry);
// create summary in the past
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -4);
lectureParticipantSummaryDao.createSummary(entry, participant1, cal.getTime());
lectureParticipantSummaryDao.createSummary(entry, participant2, cal.getTime());
// add participants to the "course"
repositoryEntryRelationDAO.addRole(participant1, entry, GroupRole.participant.name());
repositoryEntryRelationDAO.addRole(participant2, entry, GroupRole.participant.name());
dbInstance.commitAndCloseSession();
RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
config.setLectureEnabled(true);
lectureService.updateRepositoryEntryLectureConfiguration(config);
// add the course to the lectures
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock1 = lectureService.save(lectureBlock1, Collections.singletonList(defGroup));
lectureBlock2 = lectureService.save(lectureBlock2, Collections.singletonList(defGroup));
lectureBlock3 = lectureService.save(lectureBlock3, Collections.singletonList(defGroup));
dbInstance.commitAndCloseSession();
lectureService.addRollCall(participant1, lectureBlock1, null, toList(1, 2));
lectureService.addRollCall(participant1, lectureBlock2, null, toList(1, 2, 3, 4));
lectureService.addRollCall(participant2, lectureBlock1, null, toList(1, 2, 3, 4));
lectureService.addRollCall(participant2, lectureBlock3, null, toList(2, 3, 4));
dbInstance.commitAndCloseSession();
// check first participant
List<LectureBlockStatistics> statistics_1 = lectureService.getParticipantLecturesStatistics(participant1);
Assert.assertNotNull(statistics_1);
Assert.assertEquals(1, statistics_1.size());
LectureBlockStatistics statistic_1 = statistics_1.get(0);
Assert.assertEquals(12, statistic_1.getTotalPersonalPlannedLectures());
Assert.assertEquals(2, statistic_1.getTotalAttendedLectures());
Assert.assertEquals(6, statistic_1.getTotalAbsentLectures());
// check second participant
List<LectureBlockStatistics> statistics_2 = lectureService.getParticipantLecturesStatistics(participant2);
Assert.assertNotNull(statistics_2);
Assert.assertEquals(1, statistics_2.size());
LectureBlockStatistics statistic_2 = statistics_2.get(0);
Assert.assertEquals(12, statistic_2.getTotalPersonalPlannedLectures());
Assert.assertEquals(1, statistic_2.getTotalAttendedLectures());
Assert.assertEquals(7, statistic_2.getTotalAbsentLectures());
}
use of org.olat.modules.lecture.model.LectureBlockStatistics in project openolat by klemens.
the class LectureServiceTest method getLectureStatistics_checkQuerySyntax.
@Test
public void getLectureStatistics_checkQuerySyntax() {
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-5-1");
// a lecture block
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
// add participant to the "course"
repositoryEntryRelationDAO.addRole(participant, entry, GroupRole.participant.name());
dbInstance.commitAndCloseSession();
// enable lectures
RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
config.setLectureEnabled(true);
lectureService.updateRepositoryEntryLectureConfiguration(config);
// add the course to the lecture
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
dbInstance.commitAndCloseSession();
lectureService.addRollCall(participant, lectureBlock, null, Collections.singletonList(3));
dbInstance.commitAndCloseSession();
// add
List<LectureBlockStatistics> statistics = lectureService.getParticipantLecturesStatistics(participant);
Assert.assertNotNull(statistics);
Assert.assertEquals(1, statistics.size());
}
use of org.olat.modules.lecture.model.LectureBlockStatistics in project openolat by klemens.
the class LectureBlockRollCallDAO method aggregatedStatistics.
public AggregatedLectureBlocksStatistics aggregatedStatistics(List<? extends LectureBlockStatistics> statisticsList, boolean countAuthorizedAbsenceAsAttendant) {
long totalPersonalPlannedLectures = 0;
long totalAttendedLectures = 0;
long totalAuthorizedAbsentLectures = 0;
long totalAbsentLectures = 0;
long attendedForRate = 0;
long absentForRate = 0;
for (LectureBlockStatistics statistics : statisticsList) {
totalPersonalPlannedLectures += statistics.getTotalPersonalPlannedLectures();
totalAuthorizedAbsentLectures += statistics.getTotalAuthorizedAbsentLectures();
totalAttendedLectures += statistics.getTotalAttendedLectures();
totalAbsentLectures += statistics.getTotalAbsentLectures();
attendedForRate += statistics.getTotalAttendedLectures();
absentForRate += statistics.getTotalAbsentLectures();
if (countAuthorizedAbsenceAsAttendant) {
attendedForRate += statistics.getTotalAuthorizedAbsentLectures();
} else {
absentForRate += statistics.getTotalAuthorizedAbsentLectures();
}
}
long totalLectures = attendedForRate + absentForRate;
double rate;
if (totalLectures == 0 || attendedForRate == 0) {
rate = 0.0d;
} else {
rate = (double) attendedForRate / (double) totalLectures;
}
double currentRate;
if (attendedForRate == 0) {
currentRate = 0.0d;
} else {
currentRate = attendedForRate / ((double) attendedForRate + (double) absentForRate);
}
return new AggregatedLectureBlocksStatistics(totalPersonalPlannedLectures, totalAttendedLectures, totalAuthorizedAbsentLectures, totalAbsentLectures, rate, currentRate);
}
use of org.olat.modules.lecture.model.LectureBlockStatistics in project openolat by klemens.
the class ParticipantLecturesOverviewController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
LectureBlockStatistics row = tableModel.getObject(se.getIndex());
if ("details".equals(cmd)) {
doSelect(ureq, row);
} else if ("open.course".equals(cmd)) {
doOpenCourse(ureq, row);
}
}
} else if (logButton == source) {
doExportLog(ureq);
}
super.formInnerEvent(ureq, source, event);
}
Aggregations