Search in sources :

Example 1 with LectureParticipantSummaryImpl

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;
}
Also used : LectureParticipantSummaryImpl(org.olat.modules.lecture.model.LectureParticipantSummaryImpl) Date(java.util.Date)

Example 2 with LectureParticipantSummaryImpl

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());
}
Also used : LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) LectureParticipantSummaryImpl(org.olat.modules.lecture.model.LectureParticipantSummaryImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 3 with LectureParticipantSummaryImpl

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());
}
Also used : LectureParticipantSummaryImpl(org.olat.modules.lecture.model.LectureParticipantSummaryImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 4 with LectureParticipantSummaryImpl

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());
}
Also used : LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) LectureParticipantSummaryImpl(org.olat.modules.lecture.model.LectureParticipantSummaryImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 5 with LectureParticipantSummaryImpl

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;
}
Also used : LectureParticipantSummaryImpl(org.olat.modules.lecture.model.LectureParticipantSummaryImpl) Date(java.util.Date)

Aggregations

Date (java.util.Date)6 LectureParticipantSummaryImpl (org.olat.modules.lecture.model.LectureParticipantSummaryImpl)6 Test (org.junit.Test)4 Identity (org.olat.core.id.Identity)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 LectureParticipantSummary (org.olat.modules.lecture.LectureParticipantSummary)2