use of org.olat.modules.lecture.model.LectureParticipantSummaryImpl in project OpenOLAT by OpenOLAT.
the class LectureParticipantSummaryDAO method createSummary.
public LectureParticipantSummary createSummary(RepositoryEntry entry, Identity identity, Date firstAdmissionDate, LectureBlockStatistics statistics) {
LectureParticipantSummaryImpl summary = new LectureParticipantSummaryImpl();
summary.setCreationDate(new Date());
summary.setLastModified(summary.getCreationDate());
summary.setFirstAdmissionDate(firstAdmissionDate);
if (statistics == null) {
summary.setAbsentLectures(0);
summary.setAttendedLectures(0);
summary.setExcusedLectures(0);
summary.setPlannedLectures(0);
} else {
summary.setAbsentLectures(statistics.getTotalAbsentLectures());
summary.setAttendedLectures(statistics.getTotalAttendedLectures());
summary.setExcusedLectures(0);
summary.setPlannedLectures(statistics.getTotalPersonalPlannedLectures());
if (statistics.isCalculateRate()) {
summary.setAttendanceRate(statistics.getAttendanceRate());
}
}
summary.setIdentity(identity);
summary.setEntry(entry);
dbInstance.getCurrentEntityManager().persist(summary);
return summary;
}
use of org.olat.modules.lecture.model.LectureParticipantSummaryImpl in project OpenOLAT by OpenOLAT.
the class LectureParticipantSummaryDAOTest method createAndGetSummary.
@Test
public void createAndGetSummary() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("summary-2");
// null must be accepted
lectureParticipantSummaryDao.createSummary(entry, id, new Date());
dbInstance.commitAndCloseSession();
LectureParticipantSummary summary = lectureParticipantSummaryDao.getSummary(entry, id);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(summary);
Assert.assertNotNull(summary.getKey());
Assert.assertNotNull(summary.getCreationDate());
Assert.assertNotNull(summary.getLastModified());
Assert.assertNotNull(summary.getFirstAdmissionDate());
LectureParticipantSummaryImpl summaryImpl = (LectureParticipantSummaryImpl) summary;
Assert.assertEquals(entry, summaryImpl.getEntry());
Assert.assertEquals(id, summaryImpl.getIdentity());
}
use of org.olat.modules.lecture.model.LectureParticipantSummaryImpl in project OpenOLAT by OpenOLAT.
the class LectureParticipantSummaryDAOTest method updateSummary.
@Test
public void updateSummary() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("summary-3");
// null must be accepted
lectureParticipantSummaryDao.createSummary(entry, id, new Date());
dbInstance.commitAndCloseSession();
int numOfUpdatedRows = lectureParticipantSummaryDao.updateCalendarSynchronization(entry, id);
Assert.assertEquals(1, numOfUpdatedRows);
dbInstance.commitAndCloseSession();
LectureParticipantSummaryImpl summary = (LectureParticipantSummaryImpl) lectureParticipantSummaryDao.getSummary(entry, id);
Assert.assertNotNull(summary);
Assert.assertNotNull(summary.getKey());
Assert.assertTrue(summary.isCalendarSync());
Assert.assertNotNull(summary.getCalendarLastSyncDate());
}
use of org.olat.modules.lecture.model.LectureParticipantSummaryImpl in project openolat by klemens.
the class LectureParticipantSummaryDAOTest method createAndGetSummary.
@Test
public void createAndGetSummary() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("summary-2");
// null must be accepted
lectureParticipantSummaryDao.createSummary(entry, id, new Date());
dbInstance.commitAndCloseSession();
LectureParticipantSummary summary = lectureParticipantSummaryDao.getSummary(entry, id);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(summary);
Assert.assertNotNull(summary.getKey());
Assert.assertNotNull(summary.getCreationDate());
Assert.assertNotNull(summary.getLastModified());
Assert.assertNotNull(summary.getFirstAdmissionDate());
LectureParticipantSummaryImpl summaryImpl = (LectureParticipantSummaryImpl) summary;
Assert.assertEquals(entry, summaryImpl.getEntry());
Assert.assertEquals(id, summaryImpl.getIdentity());
}
use of org.olat.modules.lecture.model.LectureParticipantSummaryImpl in project openolat by klemens.
the class LectureParticipantSummaryDAO method createSummary.
public LectureParticipantSummary createSummary(RepositoryEntry entry, Identity identity, Date firstAdmissionDate, LectureBlockStatistics statistics) {
LectureParticipantSummaryImpl summary = new LectureParticipantSummaryImpl();
summary.setCreationDate(new Date());
summary.setLastModified(summary.getCreationDate());
summary.setFirstAdmissionDate(firstAdmissionDate);
if (statistics == null) {
summary.setAbsentLectures(0);
summary.setAttendedLectures(0);
summary.setExcusedLectures(0);
summary.setPlannedLectures(0);
} else {
summary.setAbsentLectures(statistics.getTotalAbsentLectures());
summary.setAttendedLectures(statistics.getTotalAttendedLectures());
summary.setExcusedLectures(0);
summary.setPlannedLectures(statistics.getTotalPersonalPlannedLectures());
if (statistics.isCalculateRate()) {
summary.setAttendanceRate(statistics.getAttendanceRate());
}
}
summary.setIdentity(identity);
summary.setEntry(entry);
dbInstance.getCurrentEntityManager().persist(summary);
return summary;
}
Aggregations