Search in sources :

Example 6 with LectureBlockAuditLog

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

the class LectureBlockAuditLogDAOTest method getAuditLog_byRepositoryEntry.

@Test
public void getAuditLog_byRepositoryEntry() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("audit-4-");
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("audit-5-");
    lectureBlockAuditLogDao.auditLog(LectureBlockAuditLog.Action.updateAuthorizedAbsence, "Before", "After", "Update absence of course", null, null, entry, identity, author);
    dbInstance.commitAndCloseSession();
    // load the audit log
    List<LectureBlockAuditLog> auditLog = lectureBlockAuditLogDao.getAuditLog(entry);
    Assert.assertNotNull(auditLog);
    Assert.assertEquals(1, auditLog.size());
    // check the entry
    LectureBlockAuditLog logEntry = auditLog.get(0);
    Assert.assertEquals(identity.getKey(), logEntry.getIdentityKey());
    Assert.assertEquals(author.getKey(), logEntry.getAuthorKey());
    Assert.assertEquals(entry.getKey(), logEntry.getEntryKey());
    Assert.assertEquals("Before", logEntry.getBefore());
    Assert.assertEquals("After", logEntry.getAfter());
    Assert.assertEquals("Update absence of course", logEntry.getMessage());
    Assert.assertEquals(LectureBlockAuditLog.Action.updateAuthorizedAbsence.name(), logEntry.getAction());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 7 with LectureBlockAuditLog

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

the class LectureRepositoryAdminController method doExportLog.

private void doExportLog(UserRequest ureq) {
    List<LectureBlockAuditLog> auditLog = lectureService.getAuditLog(entry);
    RepositoryEntryAuditLogExport archive = new RepositoryEntryAuditLogExport(entry, auditLog, authorizedAbsenceEnabled, getTranslator());
    ureq.getDispatchResult().setResultingMediaResource(archive);
}
Also used : RepositoryEntryAuditLogExport(org.olat.modules.lecture.ui.export.RepositoryEntryAuditLogExport) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog)

Example 8 with LectureBlockAuditLog

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

the class AbstractLectureBlockAuditLogExport method addContent.

private void addContent(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    for (LectureBlockAuditLog logEntry : auditLog) {
        int pos = 0;
        Row row = exportSheet.newRow();
        Date creationDate = logEntry.getCreationDate();
        row.addCell(pos++, creationDate, workbook.getStyles().getDateTimeStyle());
        row.addCell(pos++, logEntry.getAction());
        // repo entry title
        row.addCell(pos++, getRepositoryEntryDisplayName(logEntry.getEntryKey()), null);
        // lecture block
        row.addCell(pos++, getLectureBlockTitle(logEntry.getLectureBlockKey()), null);
        // date start / end
        // planned / effective
        LectureBlock auditBlock = null;
        LectureBlockRollCall auditRollCall = null;
        LectureParticipantSummary auditSummary = null;
        if (logEntry.getRollCallKey() != null) {
            auditRollCall = getAuditRollCall(logEntry.getAfter());
        }
        if (auditRollCall == null) {
            if (logEntry.getLectureBlockKey() != null) {
                auditBlock = getAuditLectureBlock(logEntry.getAfter());
            } else {
                auditSummary = getAuditLectureParticipantSummary(logEntry.getAfter());
            }
        }
        if (auditBlock != null) {
            if (auditBlock.getStatus() == null) {
                pos++;
            } else {
                row.addCell(pos++, auditBlock.getStatus().name(), null);
            }
            row.addCell(pos++, auditBlock.getPlannedLecturesNumber(), null);
            row.addCell(pos++, auditBlock.getEffectiveLecturesNumber(), null);
            row.addCell(pos++, auditBlock.getEffectiveEndDate(), workbook.getStyles().getDateTimeStyle());
        } else {
            pos += 4;
        }
        if (auditRollCall != null) {
            Long assessedIdentityKey = logEntry.getIdentityKey();
            String fullname = userManager.getUserDisplayName(assessedIdentityKey);
            row.addCell(pos++, fullname);
            row.addCell(pos++, auditRollCall.getLecturesAttendedNumber(), null);
            row.addCell(pos++, auditRollCall.getLecturesAbsentNumber(), null);
            if (authorizedAbsenceEnabled) {
                if (auditRollCall.getAbsenceAuthorized() != null && auditRollCall.getAbsenceAuthorized().booleanValue()) {
                    row.addCell(pos++, "x");
                } else {
                    pos++;
                }
                row.addCell(pos++, auditRollCall.getAbsenceReason(), null);
            }
            row.addCell(pos++, auditRollCall.getComment(), null);
        } else if (auditSummary != null) {
            Long assessedIdentityKey = logEntry.getIdentityKey();
            String fullname = userManager.getUserDisplayName(assessedIdentityKey);
            row.addCell(pos++, fullname);
            pos += 2;
            if (authorizedAbsenceEnabled) {
                pos += 2;
            }
            String summaryComment = getSummaryComment(getAuditLectureParticipantSummary(logEntry.getBefore()), auditSummary);
            row.addCell(pos++, summaryComment, null);
        } else {
            pos += 4;
            if (authorizedAbsenceEnabled) {
                pos += 2;
            }
        }
        Long authorKey = logEntry.getAuthorKey();
        if (authorKey != null) {
            String fullname = userManager.getUserDisplayName(authorKey);
            row.addCell(pos++, fullname);
        }
    }
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Date(java.util.Date)

Example 9 with LectureBlockAuditLog

use of org.olat.modules.lecture.LectureBlockAuditLog in project OpenOLAT by OpenOLAT.

the class LectureBlockAuditLogDAOTest method getAuditLog_byRepositoryEntry.

@Test
public void getAuditLog_byRepositoryEntry() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("audit-4-");
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("audit-5-");
    lectureBlockAuditLogDao.auditLog(LectureBlockAuditLog.Action.updateAuthorizedAbsence, "Before", "After", "Update absence of course", null, null, entry, identity, author);
    dbInstance.commitAndCloseSession();
    // load the audit log
    List<LectureBlockAuditLog> auditLog = lectureBlockAuditLogDao.getAuditLog(entry);
    Assert.assertNotNull(auditLog);
    Assert.assertEquals(1, auditLog.size());
    // check the entry
    LectureBlockAuditLog logEntry = auditLog.get(0);
    Assert.assertEquals(identity.getKey(), logEntry.getIdentityKey());
    Assert.assertEquals(author.getKey(), logEntry.getAuthorKey());
    Assert.assertEquals(entry.getKey(), logEntry.getEntryKey());
    Assert.assertEquals("Before", logEntry.getBefore());
    Assert.assertEquals("After", logEntry.getAfter());
    Assert.assertEquals("Update absence of course", logEntry.getMessage());
    Assert.assertEquals(LectureBlockAuditLog.Action.updateAuthorizedAbsence.name(), logEntry.getAction());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 10 with LectureBlockAuditLog

use of org.olat.modules.lecture.LectureBlockAuditLog in project OpenOLAT by OpenOLAT.

the class LectureBlockAuditLogDAOTest method getAuditLog_byLectureBlock.

@Test
public void getAuditLog_byLectureBlock() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
    lectureBlock.setStartDate(new Date());
    lectureBlock.setEndDate(new Date());
    lectureBlock.setTitle("I will be loged");
    lectureBlock = lectureBlockDao.update(lectureBlock);
    lectureBlockAuditLogDao.auditLog(LectureBlockAuditLog.Action.autoclose, "Before", "After", "Close the absence of course", lectureBlock, null, entry, null, null);
    dbInstance.commitAndCloseSession();
    // load the audit log
    List<LectureBlockAuditLog> auditLog = lectureBlockAuditLogDao.getAuditLog(lectureBlock);
    Assert.assertNotNull(auditLog);
    Assert.assertEquals(1, auditLog.size());
    // check the entry
    LectureBlockAuditLog logEntry = auditLog.get(0);
    Assert.assertEquals(entry.getKey(), logEntry.getEntryKey());
    Assert.assertEquals("Before", logEntry.getBefore());
    Assert.assertEquals("After", logEntry.getAfter());
    Assert.assertEquals("Close the absence of course", logEntry.getMessage());
    Assert.assertEquals(LectureBlockAuditLog.Action.autoclose.name(), logEntry.getAction());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) Date(java.util.Date) Test(org.junit.Test)

Aggregations

LectureBlockAuditLog (org.olat.modules.lecture.LectureBlockAuditLog)16 Date (java.util.Date)6 Test (org.junit.Test)6 LectureBlock (org.olat.modules.lecture.LectureBlock)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 Identity (org.olat.core.id.Identity)4 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 HashMap (java.util.HashMap)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 Formatter (org.olat.core.util.Formatter)2 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)2 LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)2 LectureParticipantSummary (org.olat.modules.lecture.LectureParticipantSummary)2 LectureBlockAndRollCall (org.olat.modules.lecture.model.LectureBlockAndRollCall)2 IdentityAuditLogExport (org.olat.modules.lecture.ui.export.IdentityAuditLogExport)2 LectureBlockAuditLogExport (org.olat.modules.lecture.ui.export.LectureBlockAuditLogExport)2 RepositoryEntryAuditLogExport (org.olat.modules.lecture.ui.export.RepositoryEntryAuditLogExport)2