Skip to content
Snippets Groups Projects
Commit d544dcb2 authored by srosse's avatar srosse
Browse files

OO-3101: authorized feature appears in Excel download of the audit log

parent b316188b
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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
......@@ -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);
}
}
......@@ -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();
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment