Search in sources :

Example 1 with LectureBlockAuditLog

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

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 2 with LectureBlockAuditLog

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

the class ParticipantLectureBlocksController method loadModel.

private void loadModel() {
    Date now = new Date();
    Formatter formatter = Formatter.getInstance(getLocale());
    String separator = translate("user.fullname.separator");
    List<LectureBlockAndRollCall> rollCalls = lectureService.getParticipantLectureBlocks(entry, assessedIdentity, separator);
    List<LectureBlockAuditLog> sendAppealLogs = lectureService.getAuditLog(entry, assessedIdentity, LectureBlockAuditLog.Action.sendAppeal);
    Map<Long, Date> appealDates = new HashMap<>();
    for (LectureBlockAuditLog sendAppealLog : sendAppealLogs) {
        if (sendAppealLog.getRollCallKey() != null) {
            appealDates.put(sendAppealLog.getRollCallKey(), sendAppealLog.getCreationDate());
        }
    }
    List<LectureBlockAndRollCallRow> rows = new ArrayList<>(rollCalls.size());
    for (LectureBlockAndRollCall rollCall : rollCalls) {
        LectureBlockAndRollCallRow row = new LectureBlockAndRollCallRow(rollCall);
        if (appealEnabled && !LectureBlockStatus.cancelled.equals(row.getRow().getStatus()) && rollCall.isCompulsory()) {
            int lectures = row.getRow().getEffectiveLecturesNumber();
            if (lectures <= 0) {
                lectures = row.getRow().getPlannedLecturesNumber();
            }
            int attended = row.getRow().getLecturesAttendedNumber();
            if (attended < lectures) {
                Date date = row.getRow().getDate();
                Calendar cal = Calendar.getInstance();
                cal.setTime(date);
                cal = CalendarUtils.getEndOfDay(cal);
                cal.add(Calendar.DATE, appealOffset);
                Date beginAppeal = CalendarUtils.removeTime(cal.getTime());
                cal.add(Calendar.DATE, appealPeriod);
                Date endAppeal = CalendarUtils.getEndOfDay(cal).getTime();
                Date sendAppealDate = null;
                if (row.getRow().getRollCallRef() != null) {
                    sendAppealDate = appealDates.get(row.getRow().getRollCallRef().getKey());
                }
                FormLink appealLink = null;
                if (sendAppealDate != null) {
                    String appealFrom = translate("appeal.sent", new String[] { formatter.formatDate(sendAppealDate) });
                    appealLink = uifactory.addFormLink("appeal_" + count++, "appealsend", appealFrom, null, flc, Link.LINK | Link.NONTRANSLATED);
                    appealLink.setTitle(translate("appeal.sent.tooltip", new String[] { formatter.formatDate(sendAppealDate), formatter.formatDate(beginAppeal), formatter.formatDate(endAppeal) }));
                    appealLink.setEnabled(false);
                    appealLink.setDomReplacementWrapperRequired(false);
                } else if (now.compareTo(beginAppeal) >= 0 && now.compareTo(endAppeal) <= 0) {
                    appealLink = uifactory.addFormLink("appeal_" + count++, "appeal", translate("appeal"), null, flc, Link.LINK | Link.NONTRANSLATED);
                    appealLink.setTitle(translate("appeal.tooltip", new String[] { formatter.formatDate(beginAppeal), formatter.formatDate(endAppeal) }));
                    appealLink.setUserObject(row);
                // appeal
                } else if (now.compareTo(endAppeal) > 0) {
                    // appeal closed
                    appealLink = uifactory.addFormLink("appeal_" + count++, "aclosed", "appeal.closed", null, flc, Link.LINK);
                    appealLink.setEnabled(false);
                    appealLink.setDomReplacementWrapperRequired(false);
                } else if (now.compareTo(date) >= 0) {
                    // appeal at
                    String appealFrom = translate("appeal.from", new String[] { formatter.formatDate(beginAppeal) });
                    appealLink = uifactory.addFormLink("appeal_" + count++, "appealat", appealFrom, null, flc, Link.LINK | Link.NONTRANSLATED);
                    appealLink.setEnabled(false);
                    appealLink.setDomReplacementWrapperRequired(false);
                }
                row.setAppealButton(appealLink);
            }
        }
        rows.add(row);
    }
    tableModel.setObjects(rows);
    tableEl.reset(true, true, true);
}
Also used : LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) HashMap(java.util.HashMap) Formatter(org.olat.core.util.Formatter) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Date(java.util.Date)

Example 3 with LectureBlockAuditLog

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

the class LectureBlockAuditLogDAOTest method getAuditLog_byIdentity.

@Test
public void getAuditLog_byIdentity() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("audit-2-");
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("audit-3-");
    lectureBlockAuditLogDao.auditLog(LectureBlockAuditLog.Action.createLectureBlock, "3", "4", "Update absence", null, null, entry, identity, author);
    dbInstance.commitAndCloseSession();
    // load the audit log
    List<LectureBlockAuditLog> auditLog = lectureBlockAuditLogDao.getAuditLog(identity);
    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("3", logEntry.getBefore());
    Assert.assertEquals("4", logEntry.getAfter());
    Assert.assertEquals(LectureBlockAuditLog.Action.createLectureBlock.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 4 with LectureBlockAuditLog

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

the class LectureBlockAuditLogDAOTest method getAuditLog_byIdentity.

@Test
public void getAuditLog_byIdentity() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("audit-2-");
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("audit-3-");
    lectureBlockAuditLogDao.auditLog(LectureBlockAuditLog.Action.createLectureBlock, "3", "4", "Update absence", null, null, entry, identity, author);
    dbInstance.commitAndCloseSession();
    // load the audit log
    List<LectureBlockAuditLog> auditLog = lectureBlockAuditLogDao.getAuditLog(identity);
    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("3", logEntry.getBefore());
    Assert.assertEquals("4", logEntry.getAfter());
    Assert.assertEquals(LectureBlockAuditLog.Action.createLectureBlock.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 5 with LectureBlockAuditLog

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

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