From d544dcb2933b0cbc578a787fdd5610a21d36fee6 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Mon, 30 Oct 2017 12:00:13 +0100 Subject: [PATCH] OO-3101: authorized feature appears in Excel download of the audit log --- .../ui/LectureListRepositoryController.java | 6 +++- .../ui/LectureRepositoryAdminController.java | 6 +++- ...ParticipantLecturesOverviewController.java | 3 +- .../AbstractLectureBlockAuditLogExport.java | 28 +++++++++++++------ .../ui/export/IdentityAuditLogExport.java | 5 ++-- .../ui/export/LectureBlockAuditLogExport.java | 5 ++-- .../export/RepositoryEntryAuditLogExport.java | 5 ++-- 7 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/olat/modules/lecture/ui/LectureListRepositoryController.java b/src/main/java/org/olat/modules/lecture/ui/LectureListRepositoryController.java index a2536937365..cc7d2284b08 100644 --- a/src/main/java/org/olat/modules/lecture/ui/LectureListRepositoryController.java +++ b/src/main/java/org/olat/modules/lecture/ui/LectureListRepositoryController.java @@ -60,6 +60,7 @@ import org.olat.core.util.StringHelper; import org.olat.modules.lecture.LectureBlock; import org.olat.modules.lecture.LectureBlockAuditLog; import org.olat.modules.lecture.LectureBlockManagedFlag; +import org.olat.modules.lecture.LectureModule; import org.olat.modules.lecture.LectureService; import org.olat.modules.lecture.model.LectureBlockRow; import org.olat.modules.lecture.model.LectureBlockWithTeachers; @@ -97,6 +98,8 @@ public class LectureListRepositoryController extends FormBasicController { @Autowired private UserManager userManager; @Autowired + private LectureModule lectureModule; + @Autowired private LectureService lectureService; public LectureListRepositoryController(UserRequest ureq, WindowControl wControl, RepositoryEntry entry) { @@ -356,7 +359,8 @@ public class LectureListRepositoryController extends FormBasicController { private void doExportLog(UserRequest ureq, LectureBlockRow row) { LectureBlock lectureBlock = lectureService.getLectureBlock(row); List<LectureBlockAuditLog> auditLog = lectureService.getAuditLog(row); - LectureBlockAuditLogExport export = new LectureBlockAuditLogExport(entry, lectureBlock, auditLog, getTranslator()); + boolean authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled(); + LectureBlockAuditLogExport export = new LectureBlockAuditLogExport(entry, lectureBlock, auditLog, authorizedAbsenceEnabled, getTranslator()); ureq.getDispatchResult().setResultingMediaResource(export); } diff --git a/src/main/java/org/olat/modules/lecture/ui/LectureRepositoryAdminController.java b/src/main/java/org/olat/modules/lecture/ui/LectureRepositoryAdminController.java index 1a2dc661502..a799cd566d5 100644 --- a/src/main/java/org/olat/modules/lecture/ui/LectureRepositoryAdminController.java +++ b/src/main/java/org/olat/modules/lecture/ui/LectureRepositoryAdminController.java @@ -42,6 +42,7 @@ import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; import org.olat.core.util.resource.OresHelper; import org.olat.modules.lecture.LectureBlockAuditLog; +import org.olat.modules.lecture.LectureModule; import org.olat.modules.lecture.LectureService; import org.olat.modules.lecture.ui.export.LecturesBlocksEntryExport; import org.olat.modules.lecture.ui.export.RepositoryEntryAuditLogExport; @@ -69,6 +70,8 @@ public class LectureRepositoryAdminController extends BasicController implements private RepositoryEntry entry; private boolean configurationChanges = false; + @Autowired + private LectureModule lectureModule; @Autowired private LectureService lectureService; @@ -230,7 +233,8 @@ public class LectureRepositoryAdminController extends BasicController implements private void doExportLog(UserRequest ureq) { List<LectureBlockAuditLog> auditLog = lectureService.getAuditLog(entry); - RepositoryEntryAuditLogExport archive = new RepositoryEntryAuditLogExport(entry, auditLog, getTranslator()); + boolean authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled(); + RepositoryEntryAuditLogExport archive = new RepositoryEntryAuditLogExport(entry, auditLog, authorizedAbsenceEnabled, getTranslator()); ureq.getDispatchResult().setResultingMediaResource(archive); } } \ No newline at end of file diff --git a/src/main/java/org/olat/modules/lecture/ui/ParticipantLecturesOverviewController.java b/src/main/java/org/olat/modules/lecture/ui/ParticipantLecturesOverviewController.java index 09dc756617b..7d340d12695 100644 --- a/src/main/java/org/olat/modules/lecture/ui/ParticipantLecturesOverviewController.java +++ b/src/main/java/org/olat/modules/lecture/ui/ParticipantLecturesOverviewController.java @@ -270,8 +270,9 @@ public class ParticipantLecturesOverviewController extends FormBasicController i } private void doExportLog(UserRequest ureq) { + boolean authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled(); List<LectureBlockAuditLog> auditLog = lectureService.getAuditLog(assessedIdentity); - IdentityAuditLogExport export = new IdentityAuditLogExport(assessedIdentity, auditLog, getTranslator()); + IdentityAuditLogExport export = new IdentityAuditLogExport(assessedIdentity, auditLog, authorizedAbsenceEnabled, getTranslator()); ureq.getDispatchResult().setResultingMediaResource(export); } } diff --git a/src/main/java/org/olat/modules/lecture/ui/export/AbstractLectureBlockAuditLogExport.java b/src/main/java/org/olat/modules/lecture/ui/export/AbstractLectureBlockAuditLogExport.java index d35a43ad974..78c56359e39 100644 --- a/src/main/java/org/olat/modules/lecture/ui/export/AbstractLectureBlockAuditLogExport.java +++ b/src/main/java/org/olat/modules/lecture/ui/export/AbstractLectureBlockAuditLogExport.java @@ -60,6 +60,7 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook protected final Translator translator; + private final boolean authorizedAbsenceEnabled; private final List<LectureBlockAuditLog> auditLog; private Map<Long,String> displayNames = new HashMap<>(); private Map<Long,String> lectureBlockTitles = new HashMap<>(); @@ -68,10 +69,12 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook protected final LectureService lectureService; protected final RepositoryManager repositoryManager; - public AbstractLectureBlockAuditLogExport(String name, List<LectureBlockAuditLog> auditLog, Translator translator) { + public AbstractLectureBlockAuditLogExport(String name, List<LectureBlockAuditLog> auditLog, + boolean authorizedAbsenceEnabled, Translator translator) { super(name); this.auditLog = auditLog; this.translator = translator; + this.authorizedAbsenceEnabled = authorizedAbsenceEnabled; userManager = CoreSpringFactory.getImpl(UserManager.class); lectureService = CoreSpringFactory.getImpl(LectureService.class); repositoryManager = CoreSpringFactory.getImpl(RepositoryManager.class); @@ -122,8 +125,10 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook headerRow.addCell(pos++, translator.translate("table.header.log.user"));//roll call user headerRow.addCell(pos++, translator.translate("table.header.attended.lectures"));//roll call attended headerRow.addCell(pos++, translator.translate("table.header.absent.lectures"));//roll call absent - headerRow.addCell(pos++, translator.translate("table.header.authorized.absence"));//roll call authorized - headerRow.addCell(pos++, translator.translate("authorized.absence.reason"));//roll call reason + if(authorizedAbsenceEnabled) { + headerRow.addCell(pos++, translator.translate("table.header.authorized.absence"));//roll call authorized + headerRow.addCell(pos++, translator.translate("authorized.absence.reason"));//roll call reason + } headerRow.addCell(pos++, translator.translate("rollcall.comment"));//roll call comment //author @@ -174,15 +179,20 @@ public abstract class AbstractLectureBlockAuditLogExport extends OpenXMLWorkbook row.addCell(pos++, fullname); row.addCell(pos++, auditRollCall.getLecturesAttendedNumber(), null); row.addCell(pos++, auditRollCall.getLecturesAbsentNumber(), null); - if(auditRollCall.getAbsenceAuthorized() != null && auditRollCall.getAbsenceAuthorized().booleanValue()) { - row.addCell(pos++, "x"); - } else { - pos++; + 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.getAbsenceReason(), null); row.addCell(pos++, auditRollCall.getComment(), null); } else { - pos += 6; + pos += 4; + if(authorizedAbsenceEnabled) { + pos += 2; + } } Long authorKey = logEntry.getAuthorKey(); diff --git a/src/main/java/org/olat/modules/lecture/ui/export/IdentityAuditLogExport.java b/src/main/java/org/olat/modules/lecture/ui/export/IdentityAuditLogExport.java index 17dfa9aa96c..6cd1b20786f 100644 --- a/src/main/java/org/olat/modules/lecture/ui/export/IdentityAuditLogExport.java +++ b/src/main/java/org/olat/modules/lecture/ui/export/IdentityAuditLogExport.java @@ -41,8 +41,9 @@ public class IdentityAuditLogExport extends AbstractLectureBlockAuditLogExport { private Identity identity; - public IdentityAuditLogExport(Identity identity, List<LectureBlockAuditLog> auditLog, Translator translator) { - super(label(identity), auditLog, translator); + public IdentityAuditLogExport(Identity identity, List<LectureBlockAuditLog> auditLog, + boolean authorizedAbsenceEnabled, Translator translator) { + super(label(identity), auditLog, authorizedAbsenceEnabled, translator); this.identity = identity; } diff --git a/src/main/java/org/olat/modules/lecture/ui/export/LectureBlockAuditLogExport.java b/src/main/java/org/olat/modules/lecture/ui/export/LectureBlockAuditLogExport.java index 8027b3813cd..a9326e37fda 100644 --- a/src/main/java/org/olat/modules/lecture/ui/export/LectureBlockAuditLogExport.java +++ b/src/main/java/org/olat/modules/lecture/ui/export/LectureBlockAuditLogExport.java @@ -42,8 +42,9 @@ public class LectureBlockAuditLogExport extends AbstractLectureBlockAuditLogExpo private RepositoryEntry entry; private LectureBlock lectureBlock; - public LectureBlockAuditLogExport(RepositoryEntry entry, LectureBlock lectureBlock, List<LectureBlockAuditLog> auditLog, Translator translator) { - super(label(lectureBlock), auditLog, translator); + public LectureBlockAuditLogExport(RepositoryEntry entry, LectureBlock lectureBlock, List<LectureBlockAuditLog> auditLog, + boolean authorizedAbsenceEnabled, Translator translator) { + super(label(lectureBlock), auditLog, authorizedAbsenceEnabled, translator); this.entry = entry; this.lectureBlock = lectureBlock; cacheLectureBlock(lectureBlock); diff --git a/src/main/java/org/olat/modules/lecture/ui/export/RepositoryEntryAuditLogExport.java b/src/main/java/org/olat/modules/lecture/ui/export/RepositoryEntryAuditLogExport.java index 69af6231e36..08ee0a0a289 100644 --- a/src/main/java/org/olat/modules/lecture/ui/export/RepositoryEntryAuditLogExport.java +++ b/src/main/java/org/olat/modules/lecture/ui/export/RepositoryEntryAuditLogExport.java @@ -40,8 +40,9 @@ public class RepositoryEntryAuditLogExport extends AbstractLectureBlockAuditLogE private RepositoryEntry entry; - public RepositoryEntryAuditLogExport(RepositoryEntry entry, List<LectureBlockAuditLog> auditLog, Translator translator) { - super(label(entry), auditLog, translator); + public RepositoryEntryAuditLogExport(RepositoryEntry entry, List<LectureBlockAuditLog> auditLog, + boolean authorizedAbsenceEnabled, Translator translator) { + super(label(entry), auditLog, authorizedAbsenceEnabled, translator); this.entry = entry; cacheRepositoryEntry(entry); } -- GitLab