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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations