Search in sources :

Example 11 with LectureBlockAuditLog

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

the class ParticipantLecturesOverviewController method doExportLog.

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

Example 12 with LectureBlockAuditLog

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

the class LectureListRepositoryController method doExportLog.

private void doExportLog(UserRequest ureq, LectureBlockRow row) {
    LectureBlock lectureBlock = lectureService.getLectureBlock(row);
    List<LectureBlockAuditLog> auditLog = lectureService.getAuditLog(row);
    boolean authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled();
    LectureBlockAuditLogExport export = new LectureBlockAuditLogExport(entry, lectureBlock, auditLog, authorizedAbsenceEnabled, getTranslator());
    ureq.getDispatchResult().setResultingMediaResource(export);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockAuditLogExport(org.olat.modules.lecture.ui.export.LectureBlockAuditLogExport) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog)

Example 13 with LectureBlockAuditLog

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

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

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

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

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

the class ParticipantLecturesOverviewController method doExportLog.

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

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