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

OO-4542: check daily recording of absences option in cockpit

parent a1864316
No related branches found
No related tags found
No related merge requests found
......@@ -105,6 +105,7 @@ public class DailyLectureBlockOverviewController extends FormBasicController {
private final Formatter formatter;
private final boolean isAdministrativeUser;
private final boolean authorizedAbsenceEnabled;
private final boolean dailyRecordingEnabled;
private final Identity profiledIdentity;
private final LecturesSecurityCallback secCallback;
private final RollCallSecurityCallback rollCallSecCallback;
......@@ -134,6 +135,7 @@ public class DailyLectureBlockOverviewController extends FormBasicController {
Roles roles = ureq.getUserSession().getRoles();
isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled();
dailyRecordingEnabled = lectureModule.getDailyRollCall() == DailyRollCall.daily;
initForm(ureq);
loadModel();
......@@ -187,7 +189,7 @@ public class DailyLectureBlockOverviewController extends FormBasicController {
toolsCol.setSortable(false);
columnsModel.addFlexiColumnModel(toolsCol);
tableModel = new DailyLectureBlockTableModel(columnsModel, getLocale());
tableModel = new DailyLectureBlockTableModel(columnsModel, getLocale(), dailyRecordingEnabled);
tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
sortOptions.setDefaultOrderBy(new SortKey(BlockCols.times.name(), true));
......
......@@ -46,10 +46,12 @@ public class DailyLectureBlockTableModel extends DefaultFlexiTreeTableDataModel<
implements SortableFlexiTableDataModel<DailyLectureBlockRow> {
private final Locale locale;
private final boolean dailyRecordingEnabled;
public DailyLectureBlockTableModel(FlexiTableColumnModel columnModel, Locale locale) {
public DailyLectureBlockTableModel(FlexiTableColumnModel columnModel, Locale locale, boolean dailyRecordingEnabled) {
super(columnModel);
this.locale = locale;
this.dailyRecordingEnabled = dailyRecordingEnabled;
}
@Override
......@@ -114,7 +116,7 @@ implements SortableFlexiTableDataModel<DailyLectureBlockRow> {
switch(BlockCols.values()[col]) {
case times: return row.getLectureBlock();
case tools: return row.getTools();
case details: return Boolean.TRUE;
case details: return Boolean.valueOf(dailyRecordingEnabled);
default: return null;
}
}
......@@ -130,20 +132,22 @@ implements SortableFlexiTableDataModel<DailyLectureBlockRow> {
case numOfAbsences: return row.getNumOfAbsences();
case warnings:
case alerts: return row.getLectureBlockBlockStatistics();
case details: {
Date end = row.getLectureBlock().getEndDate();
Date start = row.getLectureBlock().getStartDate();
Date now = new Date();
return end.before(new Date()) || (row.isIamTeacher() && start.compareTo(now) <= 0);
}
case details: return allowDetails(row);
case tools: return row.getTools();
default: return "ERROR";
}
}
private boolean allowDetails(DailyLectureBlockRow row) {
Date end = row.getLectureBlock().getEndDate();
Date start = row.getLectureBlock().getStartDate();
Date now = new Date();
return end.before(new Date()) || (row.isIamTeacher() && start.compareTo(now) <= 0);
}
@Override
public DefaultFlexiTableDataModel<DailyLectureBlockRow> createCopyWithEmptyList() {
return new DailyLectureBlockTableModel(getTableColumnModel(), locale);
return new DailyLectureBlockTableModel(getTableColumnModel(), locale, dailyRecordingEnabled);
}
public enum BlockCols implements FlexiSortableColumnDef {
......
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