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

OO-2636: enhance search in coaching tool with different views if a single user...

OO-2636: enhance search in coaching tool with different views if a single user is found or multiple, implement excel export with 2 sheets
parent 4552b251
No related branches found
No related tags found
No related merge requests found
Showing
with 463 additions and 33 deletions
......@@ -44,7 +44,7 @@ import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
import org.olat.core.util.resource.OresHelper;
import org.olat.core.util.tree.TreeHelper;
import org.olat.modules.lecture.LectureModule;
import org.olat.modules.lecture.ui.LecturesSearchController;
import org.olat.modules.lecture.ui.coach.LecturesSearchController;
import org.olat.util.logging.activity.LoggingResourceable;
import org.springframework.beans.factory.annotation.Autowired;
......
......@@ -354,7 +354,7 @@ public class LectureBlockRollCallDAO {
boolean calculateAttendanceRate, double requiredAttendanceRateDefault) {
StringBuilder sb = new StringBuilder(2048);
sb.append("select ident.key as participantKey, ")
sb.append("select ident.key as participantKey, ident.name as participantName,")
.append(" call.lecturesAttendedNumber as attendedLectures,")
.append(" call.lecturesAbsentNumber as absentLectures,")
.append(" call.absenceAuthorized as absenceAuthorized,")
......@@ -452,6 +452,7 @@ public class LectureBlockRollCallDAO {
for(Object[] rawObject:rawObjects) {
int pos = 0;//jump roll call key
Long identityKey = (Long)rawObject[pos++];
String identityName = (String)rawObject[pos++];
Long lecturesAttended = PersistenceHelper.extractLong(rawObject, pos++);
Long lecturesAbsent = PersistenceHelper.extractLong(rawObject, pos++);
Boolean absenceAuthorized = (Boolean)rawObject[pos++];
......@@ -493,7 +494,7 @@ public class LectureBlockRollCallDAO {
identityProps[i] = (String)rawObject[pos++];
}
entryStatistics = createIdentityStatistics(identityKey, identityProps,
entryStatistics = createIdentityStatistics(identityKey, identityName, identityProps,
repoKey, repoDisplayname, repoExternalRef,
overrideDefault, repoCalculateRate, repoRequiredRate,
persoRequiredRate, calculateAttendanceRate, requiredAttendanceRateDefault);
......@@ -670,14 +671,14 @@ public class LectureBlockRollCallDAO {
return new LectureBlockStatistics(identityKey, entryKey, displayName, externalRef, requiredRate.isCalculateRate(), requiredRate.getRequiredRate());
}
private LectureBlockIdentityStatistics createIdentityStatistics(Long identityKey, String[] identityProps,
private LectureBlockIdentityStatistics createIdentityStatistics(Long identityKey, String identityName, String[] identityProps,
Long entryKey, String displayName, String externalRef,
Boolean overrideDefault, Boolean repoCalculateRate, Double repoRequiredRate,
Double persoRequiredRate, boolean calculateAttendanceRate, double requiredAttendanceRateDefault) {
RequiredRate requiredRate = calculateRequiredRate(overrideDefault, repoCalculateRate, repoRequiredRate,
persoRequiredRate, calculateAttendanceRate, requiredAttendanceRateDefault);
return new LectureBlockIdentityStatistics(identityKey, identityProps,
return new LectureBlockIdentityStatistics(identityKey, identityName, identityProps,
entryKey, displayName, externalRef, requiredRate.isCalculateRate(), requiredRate.getRequiredRate());
}
......
......@@ -28,20 +28,51 @@ package org.olat.modules.lecture.model;
*/
public class LectureBlockIdentityStatistics extends LectureBlockStatistics {
private final String identityName;
private final String[] identityProps;
public LectureBlockIdentityStatistics(Long identityKey, String[] identityProps,
public LectureBlockIdentityStatistics(Long identityKey, String identityName, String[] identityProps,
Long repoKey, String displayName, String externalRef, boolean calculateRate, double requiredRate) {
super(identityKey, repoKey, displayName, externalRef, calculateRate, requiredRate);
this.identityName = identityName;
this.identityProps = identityProps;
}
public String getIdentityName() {
return identityName;
}
public String[] getIdentityProps() {
return identityProps;
}
public String getIdentityProp(int pos) {
return identityProps[pos];
if(identityProps != null && pos >= 0 && pos < identityProps.length) {
return identityProps[pos];
}
return null;
}
public LectureBlockIdentityStatistics cloneForAggregation() {
LectureBlockIdentityStatistics clone
= new LectureBlockIdentityStatistics(getIdentityKey(), identityName, identityProps, null, null, null, false, 0.0d);
clone.addTotalAbsentLectures(getTotalAbsentLectures());
clone.addTotalAttendedLectures(getTotalAttendedLectures());
clone.addTotalAuthorizedAbsentLectures(getTotalAuthorizedAbsentLectures());
clone.addTotalPlannedLectures(getTotalPlannedLectures());
clone.addTotalEffectiveLectures(getTotalEffectiveLectures());
clone.addTotalLectureBlocks(getTotalLectureBlocks());
clone.addTotalPersonalPlannedLectures(getTotalPersonalPlannedLectures());
return clone;
}
public void aggregate(LectureBlockIdentityStatistics statistics) {
addTotalAbsentLectures(statistics.getTotalAbsentLectures());
addTotalAttendedLectures(statistics.getTotalAttendedLectures());
addTotalAuthorizedAbsentLectures(statistics.getTotalAuthorizedAbsentLectures());
addTotalPlannedLectures(statistics.getTotalPlannedLectures());
addTotalEffectiveLectures(statistics.getTotalEffectiveLectures());
addTotalLectureBlocks(statistics.getTotalLectureBlocks());
addTotalPersonalPlannedLectures(statistics.getTotalPersonalPlannedLectures());
}
}
......@@ -82,7 +82,9 @@ public class LectureBlockStatistics {
}
public void addTotalPlannedLectures(long lectures) {
totalPlannedLectures += lectures;
if(lectures > 0) {
totalPlannedLectures += lectures;
}
}
public long getTotalPersonalPlannedLectures() {
......@@ -90,7 +92,9 @@ public class LectureBlockStatistics {
}
public void addTotalPersonalPlannedLectures(long lectures) {
totalPersonalPlannedLectures += lectures;
if(lectures > 0) {
totalPersonalPlannedLectures += lectures;
}
}
public long getTotalEffectiveLectures() {
......@@ -98,7 +102,9 @@ public class LectureBlockStatistics {
}
public void addTotalEffectiveLectures(long lectures) {
totalEffectiveLectures += lectures;
if(lectures > 0) {
totalEffectiveLectures += lectures;
}
}
public long getTotalAttendedLectures() {
......@@ -106,7 +112,9 @@ public class LectureBlockStatistics {
}
public void addTotalAttendedLectures(long lectures) {
totalAttendedLectures += lectures;
if(lectures > 0) {
totalAttendedLectures += lectures;
}
}
public long getTotalAbsentLectures() {
......@@ -122,7 +130,9 @@ public class LectureBlockStatistics {
}
public void addTotalAuthorizedAbsentLectures(long lectures) {
totalAuthorizedAbsentLectures += lectures;
if(lectures > 0) {
totalAuthorizedAbsentLectures += lectures;
}
}
public long getTotalLectureBlocks() {
......@@ -130,7 +140,9 @@ public class LectureBlockStatistics {
}
public void addTotalLectureBlocks(long lectures) {
totalLectureBlocks += lectures;
if(lectures > 0) {
totalLectureBlocks += lectures;
}
}
public double getAttendanceRate() {
......
$r.render("table")
\ No newline at end of file
......@@ -6,6 +6,8 @@ admin.menu.title=Lektionen
admin.menu.title.alt=Lektionen und Absenzmanagement
all=Alle
all.teachers.switch=Alle Dozenten
aggregated.list=Aggregierte Liste
detailled.list=Detaillierte Liste
appeal=Rekurs
appeal.contact.list=Lehrer
appeal.subject=Rekurs Lektionenblock "{0}"
......
......@@ -14,6 +14,8 @@ authorized.absence=Authorized
authorized.absence.reason=Reason
autoclosed=Auto-closed
attendance.list=Attendance list
aggregated.list=Aggregated list
detailled.list=Detailled list
bulk=Bulk Email
cancelled=Cancelled
cancel.lecture.blocks=Cancel lectures
......
......@@ -17,22 +17,30 @@
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.lecture.ui;
package org.olat.modules.lecture.ui.coach;
import java.util.List;
import org.olat.basesecurity.BaseSecurityModule;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItem;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.FlexiTableElement;
import org.olat.core.gui.components.form.flexible.elements.FormLink;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormEvent;
import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.Roles;
import org.olat.core.util.Util;
import org.olat.modules.lecture.LectureModule;
import org.olat.modules.lecture.model.LectureBlockIdentityStatistics;
import org.olat.modules.lecture.ui.LecturesListDataModel.StatsCols;
import org.olat.modules.lecture.ui.LectureRepositoryAdminController;
import org.olat.modules.lecture.ui.coach.LecturesListDataModel.StatsCols;
import org.olat.user.UserManager;
import org.olat.user.propertyhandlers.UserPropertyHandler;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -47,10 +55,15 @@ public class LecturesListController extends FormBasicController {
public static final int USER_PROPS_OFFSET = 500;
private FormLink exportButton;
private FlexiTableElement tableEl;
private LecturesListDataModel tableModel;
private final boolean showExport;
private final boolean showRepositoryEntry;
private final String propsIdentifier;
private final boolean isAdministrativeUser;
private final boolean authorizedAbsenceEnabled;
private final List<UserPropertyHandler> userPropertyHandlers;
private final List<LectureBlockIdentityStatistics> statistics;
......@@ -59,24 +72,40 @@ public class LecturesListController extends FormBasicController {
private UserManager userManager;
@Autowired
private LectureModule lectureModule;
@Autowired
private BaseSecurityModule securityModule;
public LecturesListController(UserRequest ureq, WindowControl wControl,
List<LectureBlockIdentityStatistics> statistics,
List<UserPropertyHandler> userPropertyHandlers, String propsIdentifier) {
super(ureq, wControl, "lectures_coaching");
List<UserPropertyHandler> userPropertyHandlers, String propsIdentifier,
boolean showRepositoryEntry, boolean showExport) {
super(ureq, wControl, "lectures_coaching", Util.createPackageTranslator(LectureRepositoryAdminController.class, ureq.getLocale()));
setTranslator(userManager.getPropertyHandlerTranslator(getTranslator()));
this.statistics = statistics;
this.propsIdentifier = propsIdentifier;
this.showExport = showExport;
this.showRepositoryEntry = showRepositoryEntry;
this.userPropertyHandlers = userPropertyHandlers;
authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled();
Roles roles = ureq.getUserSession().getRoles();
isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
initForm(ureq);
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if(showExport) {
exportButton = uifactory.addFormLink("export", formLayout, Link.BUTTON);
exportButton.setIconLeftCSS("o_icon o_icon_download");
}
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, StatsCols.id));
if(isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(StatsCols.username));
}
int colIndex = USER_PROPS_OFFSET;
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
......@@ -85,7 +114,9 @@ public class LecturesListController extends FormBasicController {
true, userPropertyHandler.i18nColumnDescriptorLabelKey()));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(StatsCols.entry));
if(showRepositoryEntry) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(StatsCols.entry));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(StatsCols.plannedLectures));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(StatsCols.attendedLectures));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(StatsCols.absentLectures));
......@@ -108,4 +139,17 @@ public class LecturesListController extends FormBasicController {
protected void formOK(UserRequest ureq) {
//
}
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if(source == exportButton) {
doExportStatistics(ureq);
}
super.formInnerEvent(ureq, source, event);
}
private void doExportStatistics(UserRequest ureq) {
LecturesStatisticsExport export = new LecturesStatisticsExport(statistics, userPropertyHandlers, isAdministrativeUser, getTranslator());
ureq.getDispatchResult().setResultingMediaResource(export);
}
}
......@@ -17,7 +17,7 @@
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.lecture.ui;
package org.olat.modules.lecture.ui.coach;
import java.util.List;
......@@ -61,6 +61,8 @@ implements SortableFlexiTableDataModel<LectureBlockIdentityStatistics>{
if(col >= 0 && col < StatsCols.values().length) {
switch(StatsCols.values()[col]) {
case id: return row.getIdentityKey();
case username: return row.getIdentityName();
case externalRef: return row.getExternalRef();
case entry: return row.getDisplayName();
case plannedLectures: return positive(row.getTotalPersonalPlannedLectures());
case attendedLectures: return positive(row.getTotalAttendedLectures());
......@@ -84,6 +86,8 @@ implements SortableFlexiTableDataModel<LectureBlockIdentityStatistics>{
public enum StatsCols implements FlexiSortableColumnDef {
id("table.header.id"),
username("table.header.username"),
externalRef("table.header.entry"),
entry("table.header.entry"),
plannedLectures("table.header.planned.lectures"),
attendedLectures("table.header.attended.lectures"),
......
package org.olat.modules.lecture.ui.coach;
import java.util.List;
import org.olat.basesecurity.BaseSecurityModule;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.segmentedview.SegmentViewComponent;
import org.olat.core.gui.components.segmentedview.SegmentViewEvent;
import org.olat.core.gui.components.segmentedview.SegmentViewFactory;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.id.Roles;
import org.olat.core.util.Util;
import org.olat.modules.lecture.model.LectureBlockIdentityStatistics;
import org.olat.modules.lecture.ui.LectureRepositoryAdminController;
import org.olat.user.UserManager;
import org.olat.user.propertyhandlers.UserPropertyHandler;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* Initial date: 21 juin 2017<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class LecturesListSegmentController extends BasicController {
private final VelocityContainer mainVC;
private SegmentViewComponent segmentView;
private Link exportLink, aggregatedListLink, detailledListLink;
private LecturesListController detailledListCtrl;
private LecturesListController aggregatedListCtrl;
private final String propsIdentifier;
private final boolean isAdministrativeUser;
private final List<UserPropertyHandler> userPropertyHandlers;
private final List<LectureBlockIdentityStatistics> statistics;
@Autowired
private UserManager userManager;
@Autowired
private BaseSecurityModule securityModule;
public LecturesListSegmentController(UserRequest ureq, WindowControl wControl,
List<LectureBlockIdentityStatistics> statistics,
List<UserPropertyHandler> userPropertyHandlers, String propsIdentifier) {
super(ureq, wControl, Util.createPackageTranslator(LectureRepositoryAdminController.class, ureq.getLocale()));
setTranslator(userManager.getPropertyHandlerTranslator(getTranslator()));
this.statistics = statistics;
this.propsIdentifier = propsIdentifier;
this.userPropertyHandlers = userPropertyHandlers;
Roles roles = ureq.getUserSession().getRoles();
isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
mainVC = createVelocityContainer("segmented_list");
exportLink = LinkFactory.createButton("export", mainVC, this);
exportLink.setIconLeftCSS("o_icon o_icon_download");
segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this);
aggregatedListLink = LinkFactory.createLink("aggregated.list", mainVC, this);
segmentView.addSegment(aggregatedListLink, true);
doOpenAggregatedListController(ureq);
detailledListLink = LinkFactory.createLink("detailled.list", mainVC, this);
segmentView.addSegment(detailledListLink, false);
putInitialPanel(mainVC);
}
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if(event instanceof SegmentViewEvent) {
SegmentViewEvent sve = (SegmentViewEvent)event;
String segmentCName = sve.getComponentName();
Component clickedLink = mainVC.getComponent(segmentCName);
if (clickedLink == aggregatedListLink) {
doOpenAggregatedListController(ureq);
} else if (clickedLink == detailledListLink) {
doOpenDetailledListController(ureq);
}
} else if(source == exportLink) {
doExportStatistics(ureq);
}
}
@Override
protected void doDispose() {
//
}
private Controller doOpenAggregatedListController(UserRequest ureq) {
if(aggregatedListCtrl == null) {
List<LectureBlockIdentityStatistics> aggregatedStatistics = LecturesSearchController.groupByIdentity(statistics);
aggregatedListCtrl = new LecturesListController(ureq, getWindowControl(),
aggregatedStatistics, userPropertyHandlers, propsIdentifier, false, false);
listenTo(aggregatedListCtrl);
}
mainVC.put("segmentCmp", aggregatedListCtrl.getInitialComponent());
return null;
}
private Controller doOpenDetailledListController(UserRequest ureq) {
if(detailledListCtrl == null) {
detailledListCtrl = new LecturesListController(ureq, getWindowControl(),
statistics, userPropertyHandlers, propsIdentifier, true, false);
listenTo(detailledListCtrl);
}
mainVC.put("segmentCmp", detailledListCtrl.getInitialComponent());
return detailledListCtrl;
}
private void doExportStatistics(UserRequest ureq) {
LecturesStatisticsExport export = new LecturesStatisticsExport(statistics, userPropertyHandlers, isAdministrativeUser, getTranslator());
ureq.getDispatchResult().setResultingMediaResource(export);
}
}
......@@ -17,9 +17,14 @@
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.lecture.ui;
package org.olat.modules.lecture.ui.coach;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
......@@ -32,9 +37,11 @@ import org.olat.core.gui.control.generic.dtabs.Activateable2;
import org.olat.core.id.Roles;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry;
import org.olat.core.util.Util;
import org.olat.modules.lecture.LectureService;
import org.olat.modules.lecture.model.LectureBlockIdentityStatistics;
import org.olat.modules.lecture.model.LectureStatisticsSearchParameters;
import org.olat.modules.lecture.ui.LectureRepositoryAdminController;
import org.olat.user.propertyhandlers.UserPropertyHandler;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -50,6 +57,7 @@ public class LecturesSearchController extends BasicController implements Activat
private LecturesListController listCtrl;
private LecturesSearchFormController searchForm;
private LecturesListSegmentController multipleUsersCtrl;
private final boolean admin;
......@@ -57,7 +65,7 @@ public class LecturesSearchController extends BasicController implements Activat
private LectureService lectureService;
public LecturesSearchController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel) {
super(ureq, wControl);
super(ureq, wControl, Util.createPackageTranslator(LectureRepositoryAdminController.class, ureq.getLocale()));
this.stackPanel = stackPanel;
Roles roles = ureq.getUserSession().getRoles();
admin = (roles.isUserManager() || roles.isOLATAdmin());
......@@ -86,21 +94,56 @@ public class LecturesSearchController extends BasicController implements Activat
protected void event(UserRequest ureq, Controller source, Event event) {
if(searchForm == source) {
if(event == Event.DONE_EVENT) {
cleanUp();
doSearch(ureq);
}
}
super.event(ureq, source, event);
}
private void cleanUp() {
removeAsListenerAndDispose(multipleUsersCtrl);
removeAsListenerAndDispose(listCtrl);
multipleUsersCtrl = null;
listCtrl = null;
}
private void doSearch(UserRequest ureq) {
LectureStatisticsSearchParameters params = searchForm.getSearchParameters();
List<UserPropertyHandler> userPropertyHandlers = searchForm.getUserPropertyHandlers();
List<LectureBlockIdentityStatistics> statistics = lectureService
.getLecturesStatistics(params, userPropertyHandlers, getIdentity(), admin);
listCtrl = new LecturesListController(ureq, getWindowControl(), statistics,
userPropertyHandlers, LecturesSearchFormController.PROPS_IDENTIFIER);
listenTo(listCtrl);
Set<Long> identities = statistics.stream().map(s -> s.getIdentityKey())
.collect(Collectors.toSet());
Controller ctrl;
if(identities.size() <= 1) {
listCtrl = new LecturesListController(ureq, getWindowControl(), statistics,
userPropertyHandlers, LecturesSearchFormController.PROPS_IDENTIFIER, true, true);
listenTo(listCtrl);
ctrl = listCtrl;
} else {
multipleUsersCtrl = new LecturesListSegmentController(ureq, getWindowControl(), statistics,
userPropertyHandlers, LecturesSearchFormController.PROPS_IDENTIFIER);
listenTo(multipleUsersCtrl);
ctrl = multipleUsersCtrl;
}
stackPanel.popUpToRootController(ureq);
stackPanel.pushController(translate("results"), listCtrl);
stackPanel.pushController(translate("results"), ctrl);
}
protected static List<LectureBlockIdentityStatistics> groupByIdentity(List<LectureBlockIdentityStatistics> statistics) {
Map<Long,LectureBlockIdentityStatistics> groupBy = new HashMap<>();
for(LectureBlockIdentityStatistics statistic:statistics) {
if(groupBy.containsKey(statistic.getIdentityKey())){
groupBy.get(statistic.getIdentityKey()).aggregate(statistic);
} else {
groupBy.put(statistic.getIdentityKey(), statistic.cloneForAggregation());
}
}
return new ArrayList<>(groupBy.values());
}
}
......@@ -17,7 +17,7 @@
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.lecture.ui;
package org.olat.modules.lecture.ui.coach;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -39,7 +39,9 @@ import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.modules.lecture.model.LectureStatisticsSearchParameters;
import org.olat.modules.lecture.ui.LectureRepositoryAdminController;
import org.olat.repository.manager.RepositoryEntryLifecycleDAO;
import org.olat.repository.model.RepositoryEntryLifecycle;
import org.olat.user.UserManager;
......@@ -77,7 +79,7 @@ public class LecturesSearchFormController extends FormBasicController {
private RepositoryEntryLifecycleDAO lifecycleDao;
public LecturesSearchFormController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl);
super(ureq, wControl, Util.createPackageTranslator(LectureRepositoryAdminController.class, ureq.getLocale()));
setTranslator(userManager.getPropertyHandlerTranslator(getTranslator()));
adminProps = securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles());
......
package org.olat.modules.lecture.ui.coach;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
import org.olat.core.gui.translator.Translator;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.Formatter;
import org.olat.core.util.openxml.OpenXMLWorkbook;
import org.olat.core.util.openxml.OpenXMLWorkbookResource;
import org.olat.core.util.openxml.OpenXMLWorksheet;
import org.olat.core.util.openxml.OpenXMLWorksheet.Row;
import org.olat.modules.lecture.model.LectureBlockIdentityStatistics;
import org.olat.user.propertyhandlers.UserPropertyHandler;
/**
*
* Initial date: 21 juin 2017<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class LecturesStatisticsExport extends OpenXMLWorkbookResource {
private static final OLog log = Tracing.createLoggerFor(LecturesStatisticsExport.class);
private final Translator translator;
private final boolean isAdministrativeUser;
private final List<UserPropertyHandler> userPropertyHandlers;
private final List<LectureBlockIdentityStatistics> statistics;
public LecturesStatisticsExport(List<LectureBlockIdentityStatistics> statistics,
List<UserPropertyHandler> userPropertyHandlers, boolean isAdministrativeUser, Translator translator) {
super(label());
this.translator = translator;
this.statistics = statistics;
this.isAdministrativeUser = isAdministrativeUser;
this.userPropertyHandlers = userPropertyHandlers;
}
private static final String label() {
return "ExportLectureStatistics_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()))
+ ".xlsx";
}
@Override
protected void generate(OutputStream out) {
try(OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 2)) {
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(1);
addHeadersAggregated(exportSheet);
addContentAggregated(exportSheet);
exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(1);
addHeadersDetailled(exportSheet);
addContentDetailled(exportSheet);
} catch (IOException e) {
log.error("", e);
}
}
private void addHeadersAggregated(OpenXMLWorksheet exportSheet) {
Row headerRow = exportSheet.newRow();
int pos = 0;
pos = addHeadersUser(headerRow, pos);
pos = addHeadersStatistics(headerRow, pos);
}
private void addHeadersDetailled(OpenXMLWorksheet exportSheet) {
Row headerRow = exportSheet.newRow();
int pos = 0;
pos = addHeadersUser(headerRow, pos);
headerRow.addCell(pos++, translator.translate("table.header.external.ref"));
headerRow.addCell(pos++, translator.translate("table.header.entry"));
pos = addHeadersStatistics(headerRow, pos);
}
private int addHeadersUser(Row headerRow, int pos) {
if(isAdministrativeUser) {
headerRow.addCell(pos++, translator.translate("table.header.username"));
}
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null) continue;
headerRow.addCell(pos++, translator.translate("form.name." + userPropertyHandler.getName()));
}
return pos;
}
private int addHeadersStatistics(Row headerRow, int pos) {
headerRow.addCell(pos++, translator.translate("table.header.planned.lectures"));
headerRow.addCell(pos++, translator.translate("table.header.attended.lectures"));
headerRow.addCell(pos++, translator.translate("table.header.absent.lectures"));
headerRow.addCell(pos++, translator.translate("table.header.authorized.absence"));
return pos;
}
private void addContentAggregated(OpenXMLWorksheet exportSheet) {
List<LectureBlockIdentityStatistics> aggregatedStatistics = LecturesSearchController.groupByIdentity(statistics);
for(LectureBlockIdentityStatistics statistic:aggregatedStatistics) {
Row row = exportSheet.newRow();
int pos = 0;
pos = addContentUser(statistic, row, pos);
pos = addContentStatistics(statistic, row, pos);
}
}
private void addContentDetailled(OpenXMLWorksheet exportSheet) {
for(LectureBlockIdentityStatistics statistic:statistics) {
Row row = exportSheet.newRow();
int pos = 0;
pos = addContentUser(statistic, row, pos);
row.addCell(pos++, statistic.getExternalRef());
row.addCell(pos++, statistic.getDisplayName());
pos = addContentStatistics(statistic, row, pos);
}
}
private int addContentUser(LectureBlockIdentityStatistics statistic, Row row, int pos) {
if(isAdministrativeUser) {
row.addCell(pos++, statistic.getIdentityName());
}
int count = 0;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null) continue;
row.addCell(pos++, statistic.getIdentityProp(count++));
}
return pos;
}
private int addContentStatistics(LectureBlockIdentityStatistics statistic, Row row, int pos) {
row.addCell(pos++, positive(statistic.getTotalPersonalPlannedLectures()), null);
row.addCell(pos++, positive(statistic.getTotalAttendedLectures()), null);
row.addCell(pos++, positive(statistic.getTotalAbsentLectures()), null);
row.addCell(pos++, positive(statistic.getTotalAuthorizedAbsentLectures()), null);
return pos;
}
private long positive(long val) {
return val < 0 ? 0 : val;
}
}
#if($r.available("export"))
<div class="o_button_group o_button_group_right">
$r.render("export")
</div>
#end
$r.render("table")
\ No newline at end of file
<div class="o_button_group o_button_group_right">
$r.render("export")
</div>
<div class="o_lectures_overviewview clearfix">
$r.render("segments")
#if($r.available("segmentCmp"))
<div class="o_segments_content">$r.render("segmentCmp")</div>
#end
</div>
\ No newline at end of file
......@@ -1346,7 +1346,7 @@
</bean>
</entry>
<entry key="org.olat.modules.lecture.ui.LecturesSearchFormController">
<entry key="org.olat.modules.lecture.ui.coach.LecturesSearchFormController">
<bean class="org.olat.user.propertyhandlers.UserPropertyUsageContext">
<property name="description" value="Properties used in the user search for lectures of the coaching tool." />
<property name="propertyHandlers">
......
......@@ -50,7 +50,7 @@ doCompile () {
UPDATE=$UPDATECMD
if [ $1 = "." ];
then
TARGET="light"
TARGET="openolat"
if [[ "--watch" == $UPDATECMD && ! -z $THEMES ]]; then UPDATE="--update"; fi
fi
echo "Compiling SASS: $TARGET $STYLE"
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
source diff could not be displayed: it is too large. Options to address this: view the blob.
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