diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/DefaultFlexiColumnModel.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/DefaultFlexiColumnModel.java index ef1be3a2be80b3e0d987dab898d2f743e3c77d57..518dd8cea3d6585a420022ec2e01a126227fc158 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/DefaultFlexiColumnModel.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/DefaultFlexiColumnModel.java @@ -26,7 +26,6 @@ package org.olat.core.gui.components.form.flexible.impl.elements.table; - /** * * @author Christian Guretzki @@ -243,7 +242,7 @@ public class DefaultFlexiColumnModel implements FlexiColumnModel { public void setExportable(boolean exportable) { this.exportable = exportable; } - + @Override public boolean isDefaultVisible() { return defaultVisible; diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiColumnModel.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiColumnModel.java index c7bf48963a44632d4a2a071476b5292cd1803d42..8476d9b5520db7996f8c83e6177b1d4763022d64 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiColumnModel.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiColumnModel.java @@ -26,7 +26,6 @@ package org.olat.core.gui.components.form.flexible.impl.elements.table; - /** * * @author Christian Guretzki diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/XlsFlexiTableExporter.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/XlsFlexiTableExporter.java index 25b363df716b2a1765cc65dc02b93acf180b9e84..f9b9506dc019fe71828ea37fd321b4c83e9c4c6c 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/XlsFlexiTableExporter.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/XlsFlexiTableExporter.java @@ -73,19 +73,20 @@ public class XlsFlexiTableExporter implements FlexiTableExporter { }; } - private void createHeader(List<FlexiColumnModel> columns, Translator translator, + protected void createHeader(List<FlexiColumnModel> columns, Translator translator, OpenXMLWorksheet sheet, OpenXMLWorkbook workbook) { sheet.setHeaderRows(1); Row headerRow = sheet.newRow(); for (int c=0; c<columns.size(); c++) { FlexiColumnModel cd = columns.get(c); + String headerVal = cd.getHeaderLabel() == null ? translator.translate(cd.getHeaderKey()) : cd.getHeaderLabel(); headerRow.addCell(c, headerVal, workbook.getStyles().getHeaderStyle()); } } - private void createData(FlexiTableComponent ftC, List<FlexiColumnModel> columns, Translator translator, + protected void createData(FlexiTableComponent ftC, List<FlexiColumnModel> columns, Translator translator, OpenXMLWorksheet sheet, OpenXMLWorkbook workbook) { FlexiTableDataModel<?> dataModel = ftC.getFlexiTableElement().getTableDataModel(); @@ -95,28 +96,38 @@ public class XlsFlexiTableExporter implements FlexiTableExporter { Row dataRow = sheet.newRow(); for (int c = 0; c<numOfColumns; c++) { FlexiColumnModel cd = columns.get(c); - - int colIndex = cd.getColumnIndex(); - if(colIndex >= 0) { - Object value = dataModel.getValueAt(r, colIndex); - if(value instanceof Date) { - dataRow.addCell(c, (Date)value, workbook.getStyles().getDateStyle()); - } else if(value instanceof Number) { - dataRow.addCell(c, (Number)value, null); - } else { - StringOutput so = StringOutputPool.allocStringBuilder(1000); - cd.getCellRenderer().render(null, so, value, r, ftC, ubu, translator); - String cellValue = StringOutputPool.freePop(so); - - cellValue = StringHelper.stripLineBreaks(cellValue); - cellValue = FilterFactory.getHtmlTagsFilter().filter(cellValue); - if(StringHelper.containsNonWhitespace(cellValue)) { - cellValue = StringEscapeUtils.unescapeHtml(cellValue); - } - dataRow.addCell(c, cellValue, null); + createCell(ftC, cd, dataRow, r, c, translator, workbook); + } + } + } + + protected void createCell(FlexiTableComponent ftC, FlexiColumnModel cd, Row dataRow, int row, int col, Translator translator, + OpenXMLWorkbook workbook) { + FlexiTableDataModel<?> dataModel = ftC.getFlexiTableElement().getTableDataModel(); + + try { + int colIndex = cd.getColumnIndex(); + if(colIndex >= 0) { + Object value = dataModel.getValueAt(row, colIndex); + if(value instanceof Date) { + dataRow.addCell(col, (Date)value, workbook.getStyles().getDateStyle()); + } else if(value instanceof Number) { + dataRow.addCell(col, (Number)value, null); + } else { + StringOutput so = StringOutputPool.allocStringBuilder(1000); + cd.getCellRenderer().render(null, so, value, row, ftC, ubu, translator); + String cellValue = StringOutputPool.freePop(so); + + cellValue = StringHelper.stripLineBreaks(cellValue); + cellValue = FilterFactory.getHtmlTagsFilter().filter(cellValue); + if(StringHelper.containsNonWhitespace(cellValue)) { + cellValue = StringEscapeUtils.unescapeHtml(cellValue); } + dataRow.addCell(col, cellValue, null); } } + } catch (Exception e) { + log.error("", e); } } } diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLCellType.java b/src/main/java/org/olat/core/util/openxml/OpenXMLCellType.java new file mode 100644 index 0000000000000000000000000000000000000000..b560cf026d09d61cb31f8420c72bb33aea6c21d8 --- /dev/null +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLCellType.java @@ -0,0 +1,32 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.core.util.openxml; + +/** + * + * Initial date: 10 juil. 2017<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public enum OpenXMLCellType { + number, + sharedString, + date +} diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLWorkbookStyles.java b/src/main/java/org/olat/core/util/openxml/OpenXMLWorkbookStyles.java index 3d08008f54c59df95fc67b4335b316680e84bfd7..aa86d2f0c6d8bb0d7258862687e80d71df088bc7 100644 --- a/src/main/java/org/olat/core/util/openxml/OpenXMLWorkbookStyles.java +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLWorkbookStyles.java @@ -35,7 +35,8 @@ import org.olat.core.util.openxml.workbookstyle.Font.FontStyle; * */ public class OpenXMLWorkbookStyles { - + + public static final String PERCENT_FORMAT = "10"; public static final String DATE_FORMAT = "14"; public static final String TIME_FORMAT = "21"; @@ -58,6 +59,7 @@ public class OpenXMLWorkbookStyles { private final CellStyle durationStyle; private final CellStyle headerStyle; private final CellStyle correctStyle; + private final CellStyle percentStyle; public OpenXMLWorkbookStyles() { standardFont = new Font(fonts.size(), "12", "1", "Calibri", "2", "minor", FontStyle.none); @@ -89,6 +91,8 @@ public class OpenXMLWorkbookStyles { cellXfs.add(headerStyle); correctStyle = new CellStyle(cellXfs.size(), "0", boldFont, correctFill, noBorder, null, null); cellXfs.add(correctStyle); + percentStyle = new CellStyle(cellXfs.size(), PERCENT_FORMAT, standardFont, noneFile, borderRight, null, "1"); + cellXfs.add(percentStyle); } public CellStyle getBorderRightStyle() { @@ -119,6 +123,10 @@ public class OpenXMLWorkbookStyles { return correctStyle; } + public CellStyle getPercentStyle() { + return percentStyle; + } + public List<Font> getFonts() { return fonts; } diff --git a/src/main/java/org/olat/core/util/openxml/OpenXMLWorksheet.java b/src/main/java/org/olat/core/util/openxml/OpenXMLWorksheet.java index f0cd7776bc13a1eaadb87441d97afef7321a9a00..ca39c6a2b7ad9c1500df0f15a6afc655d86acfff 100644 --- a/src/main/java/org/olat/core/util/openxml/OpenXMLWorksheet.java +++ b/src/main/java/org/olat/core/util/openxml/OpenXMLWorksheet.java @@ -135,12 +135,12 @@ public class OpenXMLWorksheet { if(style != null && style.getIndex() > 0) { writer.writeAttribute("s", Integer.toString(style.getIndex())); } - if(cell.getType() == CellType.sharedString) { + if(cell.getType() == OpenXMLCellType.sharedString) { writer.writeAttribute("t", "s"); } writer.writeStartElement("v"); - if(cell.getType() == CellType.date) { + if(cell.getType() == OpenXMLCellType.date) { cal.setTime((Date)cell.getValue()); double val = internalGetExcelDate(cal, false); writer.writeCharacters(Double.toString(val)); @@ -361,7 +361,7 @@ public class OpenXMLWorksheet { public Cell addCell(int column, String value, CellStyle style) { Cell cell = getOrCreateCell(column); cell.setStyle(style); - cell.setType(CellType.sharedString); + cell.setType(OpenXMLCellType.sharedString); if(value != null) { int sharedIndex = workbook.getSharedStrings().add(value); if(sharedIndex >= 0) { @@ -374,7 +374,22 @@ public class OpenXMLWorksheet { public Cell addCell(int column, Number value, CellStyle style) { Cell cell = getOrCreateCell(column); cell.setStyle(style); - cell.setType(CellType.number); + cell.setType(OpenXMLCellType.number); + cell.setValue(value); + return cell; + } + + /** + * The accepted types are number or percent + * @param column The index of the column + * @param value The value + * @param type The type, number or percent + * @return + */ + public Cell addCell(int column, Number value, CellStyle style, OpenXMLCellType type) { + Cell cell = getOrCreateCell(column); + cell.setStyle(style); + cell.setType(type); cell.setValue(value); return cell; } @@ -389,7 +404,7 @@ public class OpenXMLWorksheet { public Cell addCell(int column, Date value, CellStyle style) { Cell cell = getOrCreateCell(column); cell.setStyle(style); - cell.setType(CellType.date); + cell.setType(OpenXMLCellType.date); cell.setValue(value); return cell; } @@ -418,14 +433,14 @@ public class OpenXMLWorksheet { public static class Cell { private Object value; - private CellType type; + private OpenXMLCellType type; private CellStyle style; public Cell() { // } - public Cell(Object value, CellType type, CellStyle style) { + public Cell(Object value, OpenXMLCellType type, CellStyle style) { this.value = value; this.type = type; this.style = style; @@ -439,11 +454,11 @@ public class OpenXMLWorksheet { this.value = value; } - public CellType getType() { + public OpenXMLCellType getType() { return type; } - public void setType(CellType type) { + public void setType(OpenXMLCellType type) { this.type = type; } @@ -455,10 +470,4 @@ public class OpenXMLWorksheet { this.style = style; } } - - public enum CellType { - number, - sharedString, - date - } } diff --git a/src/main/java/org/olat/modules/lecture/ui/AbstractTeacherOverviewController.java b/src/main/java/org/olat/modules/lecture/ui/AbstractTeacherOverviewController.java index db47aefad2711c625c70f1df2dbf3364caaa9b24..38e2fa36e73536d4d26845000d9660385b0dff08 100644 --- a/src/main/java/org/olat/modules/lecture/ui/AbstractTeacherOverviewController.java +++ b/src/main/java/org/olat/modules/lecture/ui/AbstractTeacherOverviewController.java @@ -119,23 +119,23 @@ public abstract class AbstractTeacherOverviewController extends BasicController mainVC.put("search", searchCtrl.getInitialComponent()); currentLecturesBlockCtrl = new TeacherLecturesTableController(ureq, getWindowControl(), - admin, "empty.table.current.lectures.blocks", withRepositoryEntry, withTeachers); + admin, "empty.table.current.lectures.blocks", false, "current", withRepositoryEntry, withTeachers); listenTo(currentLecturesBlockCtrl); mainVC.put("currentLectures", currentLecturesBlockCtrl.getInitialComponent()); pendingLecturesBlockCtrl = new TeacherLecturesTableController(ureq, getWindowControl(), - admin, "empty.table.lectures.blocks", withRepositoryEntry, withTeachers); + admin, "empty.table.lectures.blocks", false, "pending", withRepositoryEntry, withTeachers); listenTo(pendingLecturesBlockCtrl); mainVC.put("pendingLectures", pendingLecturesBlockCtrl.getInitialComponent()); nextLecturesBlockCtrl = new TeacherLecturesTableController(ureq, getWindowControl(), - admin, "empty.table.lectures.blocks", withRepositoryEntry, withTeachers); + admin, "empty.table.lectures.blocks", true, "next", withRepositoryEntry, withTeachers); nextLecturesBlockCtrl.setTablePageSize(5); listenTo(nextLecturesBlockCtrl); mainVC.put("nextLectures", nextLecturesBlockCtrl.getInitialComponent()); closedLecturesBlockCtrl = new TeacherLecturesTableController(ureq, getWindowControl(), - admin, "empty.table.lectures.blocks", withRepositoryEntry, withTeachers); + admin, "empty.table.lectures.blocks", false, "closed", withRepositoryEntry, withTeachers); closedLecturesBlockCtrl.setTablePageSize(10); listenTo(closedLecturesBlockCtrl); mainVC.put("closedLectures", closedLecturesBlockCtrl.getInitialComponent()); 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 f11449483caa7551f32934082d5b1d0a0ff32b11..f42cdeea4cfab1c7c5fe8b320c069ead6ce60798 100644 --- a/src/main/java/org/olat/modules/lecture/ui/ParticipantLecturesOverviewController.java +++ b/src/main/java/org/olat/modules/lecture/ui/ParticipantLecturesOverviewController.java @@ -150,7 +150,7 @@ public class ParticipantLecturesOverviewController extends FormBasicController i tableModel = new ParticipantLecturesDataModel(columnsModel, getTranslator(), getLocale()); int paging = withPrint ? 20 : -1; tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, paging, false, getTranslator(), formLayout); - tableEl.setAndLoadPersistedPreferences(ureq, "participant-lectures"); + tableEl.setAndLoadPersistedPreferences(ureq, "participant-lectures-overview"); tableEl.setCustomizeColumns(false); tableEl.setEmtpyTableMessageKey("empty.lectures.list"); tableEl.setFooter(true); diff --git a/src/main/java/org/olat/modules/lecture/ui/ParticipantListDataModel.java b/src/main/java/org/olat/modules/lecture/ui/ParticipantListDataModel.java index a41efe91f70bbffadf73fc207f07df098442df8d..61dac7b22a547318c6b08be0464edc32e5489303 100644 --- a/src/main/java/org/olat/modules/lecture/ui/ParticipantListDataModel.java +++ b/src/main/java/org/olat/modules/lecture/ui/ParticipantListDataModel.java @@ -19,13 +19,20 @@ */ package org.olat.modules.lecture.ui; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; import org.olat.core.commons.persistence.SortKey; import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableDataModel; +import org.olat.core.gui.components.form.flexible.impl.elements.table.ExportableFlexiTableDataModel; +import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel; import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiSortableColumnDef; import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel; +import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableComponent; import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableDataModel; +import org.olat.core.gui.media.MediaResource; +import org.olat.core.gui.translator.Translator; /** * @@ -34,20 +41,36 @@ import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFl * */ public class ParticipantListDataModel extends DefaultFlexiTableDataModel<ParticipantRow> -implements SortableFlexiTableDataModel<ParticipantRow> { +implements SortableFlexiTableDataModel<ParticipantRow>, ExportableFlexiTableDataModel { private final Locale locale; + private final Translator translator; - public ParticipantListDataModel(FlexiTableColumnModel columnModel, Locale locale) { + public ParticipantListDataModel(FlexiTableColumnModel columnModel, Translator translator, Locale locale) { super(columnModel); this.locale = locale; + this.translator = translator; } @Override public void sort(SortKey sortKey) { // } - + + @Override + public MediaResource export(FlexiTableComponent ftC) { + FlexiTableColumnModel columnModel = getTableColumnModel(); + int numOfColumns = columnModel.getColumnCount(); + List<FlexiColumnModel> columns = new ArrayList<>(); + for(int i=0; i<numOfColumns; i++) { + FlexiColumnModel column = columnModel.getColumnModel(i); + if(column.isExportable()) { + columns.add(column); + } + } + return new ParticipantListExport().export(ftC, columns, translator); + } + @Override public Object getValueAt(int row, int col) { ParticipantRow participant = getObject(row); @@ -79,7 +102,7 @@ implements SortableFlexiTableDataModel<ParticipantRow> { @Override public DefaultFlexiTableDataModel<ParticipantRow> createCopyWithEmptyList() { - return new ParticipantListDataModel(getTableColumnModel(), locale); + return new ParticipantListDataModel(getTableColumnModel(), translator, locale); } public enum ParticipantsCols implements FlexiSortableColumnDef { diff --git a/src/main/java/org/olat/modules/lecture/ui/ParticipantListExport.java b/src/main/java/org/olat/modules/lecture/ui/ParticipantListExport.java new file mode 100644 index 0000000000000000000000000000000000000000..393007905fa7936f1a7f71b447db9f45d17b9366 --- /dev/null +++ b/src/main/java/org/olat/modules/lecture/ui/ParticipantListExport.java @@ -0,0 +1,50 @@ +package org.olat.modules.lecture.ui; + +import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel; +import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableComponent; +import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModel; +import org.olat.core.gui.components.form.flexible.impl.elements.table.XlsFlexiTableExporter; +import org.olat.core.gui.translator.Translator; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; +import org.olat.core.util.openxml.OpenXMLWorkbook; +import org.olat.core.util.openxml.OpenXMLWorksheet.Row; +import org.olat.modules.lecture.ui.ParticipantListDataModel.ParticipantsCols; + +/** + * + * + * Initial date: 10 juil. 2017<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class ParticipantListExport extends XlsFlexiTableExporter { + + private static final OLog log = Tracing.createLoggerFor(ParticipantListExport.class); + + @Override + protected void createCell(FlexiTableComponent ftC, FlexiColumnModel cd, Row dataRow, int row, int col, + Translator translator, OpenXMLWorkbook workbook) { + try { + int colIndex = cd.getColumnIndex(); + if(colIndex < ParticipantListRepositoryController.USER_PROPS_OFFSET) { + switch(ParticipantsCols.values()[colIndex]) { + case rate: + FlexiTableDataModel<?> dataModel = ftC.getFlexiTableElement().getTableDataModel(); + Object rate = dataModel.getValueAt(row, colIndex); + if(rate instanceof Number) { + dataRow.addCell(col, (Number)rate, workbook.getStyles().getPercentStyle()); + } + break; + default: + super.createCell(ftC, cd, dataRow, row, col, translator, workbook); + break; + } + } else { + super.createCell(ftC, cd, dataRow, row, col, translator, workbook); + } + } catch (Exception e) { + log.error("", e); + } + } +} diff --git a/src/main/java/org/olat/modules/lecture/ui/ParticipantListRepositoryController.java b/src/main/java/org/olat/modules/lecture/ui/ParticipantListRepositoryController.java index 647702de7f00bc001026dd0ef3e9dbc510b2d0df..3f3bd92e9c69b0f6587ff8a6583978741a280418 100644 --- a/src/main/java/org/olat/modules/lecture/ui/ParticipantListRepositoryController.java +++ b/src/main/java/org/olat/modules/lecture/ui/ParticipantListRepositoryController.java @@ -167,10 +167,14 @@ public class ParticipantListRepositoryController extends FormBasicController { if(authorizedAbsenceEnabled) { columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.authorizedAbsenceLectures)); } - columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.progress, new LectureStatisticsCellRenderer())); + FlexiColumnModel progressCol = new DefaultFlexiColumnModel(ParticipantsCols.progress, new LectureStatisticsCellRenderer()); + progressCol.setExportable(false); + columnsModel.addFlexiColumnModel(progressCol); } if(rateEnabled) { - columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.rateWarning, new RateWarningCellRenderer())); + FlexiColumnModel warningCol = new DefaultFlexiColumnModel(ParticipantsCols.rateWarning, new RateWarningCellRenderer()); + warningCol.setExportable(false); + columnsModel.addFlexiColumnModel(warningCol); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.rate, new PercentCellRenderer())); } @@ -182,12 +186,12 @@ public class ParticipantListRepositoryController extends FormBasicController { columnsModel.addFlexiColumnModel(editColumn); } - tableModel = new ParticipantListDataModel(columnsModel, getLocale()); + tableModel = new ParticipantListDataModel(columnsModel, getTranslator(), getLocale()); tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout); tableEl.setExportEnabled(!printView); tableEl.setMultiSelect(!printView); tableEl.setSelectAllEnable(!printView); - //TODO absence tableEl.setAndLoadPersistedPreferences(ureq, "participant-list-repo-entry"); + tableEl.setAndLoadPersistedPreferences(ureq, "participant-list-repo-entry"); } private void loadModel() { diff --git a/src/main/java/org/olat/modules/lecture/ui/TeacherLecturesTableController.java b/src/main/java/org/olat/modules/lecture/ui/TeacherLecturesTableController.java index 59da4ea416ab924ff4b7fa105597710c1c2ae982..4372899825f1957ec6dd916e9f551e065aba502d 100644 --- a/src/main/java/org/olat/modules/lecture/ui/TeacherLecturesTableController.java +++ b/src/main/java/org/olat/modules/lecture/ui/TeacherLecturesTableController.java @@ -88,7 +88,9 @@ public class TeacherLecturesTableController extends FormBasicController implemen private TeacherRollCallController rollCallCtrl; private int counter; + private final String id; private final boolean admin; + private final boolean sortAsc; private final String emptyI18nKey; private final boolean withRepositoryEntry, withTeachers; @@ -100,10 +102,12 @@ public class TeacherLecturesTableController extends FormBasicController implemen private LectureService lectureService; public TeacherLecturesTableController(UserRequest ureq, WindowControl wControl, - boolean admin, String emptyI18nKey, + boolean admin, String emptyI18nKey, boolean sortAsc, String id, boolean withRepositoryEntry, boolean withTeachers) { super(ureq, wControl, "teacher_view_table"); + this.id = id; this.admin = admin; + this.sortAsc = sortAsc; this.emptyI18nKey = emptyI18nKey; this.withTeachers = withTeachers; this.withRepositoryEntry = withRepositoryEntry; @@ -144,12 +148,12 @@ public class TeacherLecturesTableController extends FormBasicController implemen tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout); FlexiTableSortOptions sortOptions = new FlexiTableSortOptions(); - sortOptions.setDefaultOrderBy(new SortKey(TeachCols.date.name(), false)); + sortOptions.setDefaultOrderBy(new SortKey(TeachCols.date.name(), sortAsc)); tableEl.setSortSettings(sortOptions); tableEl.setCustomizeColumns(false); tableEl.setNumOfRowsEnabled(false); tableEl.setEmtpyTableMessageKey(emptyI18nKey); - tableEl.setAndLoadPersistedPreferences(ureq, "lecture-teacher-overview"); + tableEl.setAndLoadPersistedPreferences(ureq, "lecture-teacher-overview-".concat(id)); } public int getRowCount() { diff --git a/src/main/java/org/olat/modules/lecture/ui/TeacherOverviewDataModel.java b/src/main/java/org/olat/modules/lecture/ui/TeacherOverviewDataModel.java index 2cf64196b9f18334756adeecee374af1fe465c34..6ecbfd902c7237aaec441b35338901c4fbb18c86 100644 --- a/src/main/java/org/olat/modules/lecture/ui/TeacherOverviewDataModel.java +++ b/src/main/java/org/olat/modules/lecture/ui/TeacherOverviewDataModel.java @@ -72,7 +72,9 @@ public class TeacherOverviewDataModel extends DefaultFlexiTableDataModel<Lecture case status: return row.getLectureBlock(); case details: { Date end = row.getLectureBlock().getEndDate(); - return end.before(new Date()) || row.isIamTeacher(); + Date start = row.getLectureBlock().getStartDate(); + Date now = new Date(); + return end.before(new Date()) || (row.isIamTeacher() && start.compareTo(now) <= 0); } case tools: return row.getToolsLink(); default: return null; diff --git a/src/main/java/org/olat/modules/lecture/ui/TeacherRollCallController.java b/src/main/java/org/olat/modules/lecture/ui/TeacherRollCallController.java index 50f53f6add120413adb7bf7f457aa97b4a528e22..e5e37390dbcb6c6ce6dc6024f6cfc5bfe13456bb 100644 --- a/src/main/java/org/olat/modules/lecture/ui/TeacherRollCallController.java +++ b/src/main/java/org/olat/modules/lecture/ui/TeacherRollCallController.java @@ -179,13 +179,13 @@ public class TeacherRollCallController extends FormBasicController { layoutCont.contextPut("endTime", endTime); layoutCont.contextPut("dateAndTime", translate("lecture.block.dateAndTime", args)); layoutCont.contextPut("teachers", sb.toString()); - layoutCont.contextPut("lectureBlockTitle", StringHelper.escapeJavaScript(lectureBlock.getTitle())); - layoutCont.contextPut("lectureBlockExternaalId", StringHelper.escapeJavaScript(lectureBlock.getExternalId())); + layoutCont.contextPut("lectureBlockTitle", StringHelper.escapeHtml(lectureBlock.getTitle())); + layoutCont.contextPut("lectureBlockExternalId", StringHelper.escapeHtml(lectureBlock.getExternalId())); StringBuilder description = Formatter.stripTabsAndReturns(Formatter.formatURLsAsLinks(lectureBlock.getDescription())); layoutCont.contextPut("lectureBlockDescription", StringHelper.xssScan(description)); StringBuilder preparation = Formatter.stripTabsAndReturns(Formatter.formatURLsAsLinks(lectureBlock.getPreparation())); layoutCont.contextPut("lectureBlockPreparation", StringHelper.xssScan(preparation)); - layoutCont.contextPut("lectureBlockLocation", StringHelper.escapeJavaScript(lectureBlock.getLocation())); + layoutCont.contextPut("lectureBlockLocation", StringHelper.escapeHtml(lectureBlock.getLocation())); layoutCont.contextPut("lectureBlock",lectureBlock); layoutCont.contextPut("lectureBlockOptional", !lectureBlock.isCompulsory()); layoutCont.setFormTitle(translate("lecture.block", args)); diff --git a/src/main/java/org/olat/modules/lecture/ui/_content/rollcall.html b/src/main/java/org/olat/modules/lecture/ui/_content/rollcall.html index 2902fc063053b8d690e4a3e6ef3af1b901c1d3a7..656dcb18f3a132336d99d030aea4e08d19ad3513 100644 --- a/src/main/java/org/olat/modules/lecture/ui/_content/rollcall.html +++ b/src/main/java/org/olat/modules/lecture/ui/_content/rollcall.html @@ -2,9 +2,9 @@ <fieldset> <legend> $off_title "$lectureBlockTitle" - #if($lectureBlockExternaalId && $lectureBlockExternaalId!= "") + #if($r.isNotEmpty(lectureBlockExternalId)) <small class="text-muted"> - $lectureBlockExternaalId + $lectureBlockExternalId </small> #end </legend> @@ -37,12 +37,12 @@ #end </div> - #if($lectureBlockDescription && $lectureBlockDescription != "") + #if($r.isNotEmpty($lectureBlockDescription)) <div class="o_desc o_info"> $lectureBlockDescription </div> #end - #if($lectureBlockPreparation && $lectureBlockPreparation != "") + #if($r.isNotEmpty($lectureBlockPreparation)) <div class="o_preparation o_note"> $lectureBlockPreparation </div> diff --git a/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_de.properties index 574d4142fc9be1c120a8f27e42c263a97a1887be..a4d617dd6bad70753e475530258e85b5d4ef5b47 100644 --- a/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/modules/lecture/ui/_i18n/LocalStrings_de.properties @@ -71,7 +71,7 @@ first.admission=Erstzulassung form.managedflags.intro=Dieser Lektionblock wurde von einem externen Werkzeug erstellt. Einige Einstellungen und Module k\u00F6nnen daher in OpenOLAT nicht ver\u00E4ndert und benutzt werden. Folgende Elemente sind in OpenOLAT gesperrt\: {0} form.managedflags.intro.short=Dieser Lektionblock wurde von einem externen Werkzeug erstellt. Einige Einstellungen k\u00F6nnen daher in OpenOLAT nicht ver\u00E4ndert werden. info.lecture.block.optional=Dieser Lektionenblock ist <strong>nicht</strong> obligatorisch. -info.no.lectures=Sie folgen zur Zeit kein Lektionen +info.no.lectures=Sie folgen zur Zeit keinen Lektionen interceptor.start=Sie haben jetzt einen Lektionenblock f\u00FCr den Kurs "{0}" {1} von {4} bis {5}. lecture.absence.default.authorized=Absenzen per default entschuldigt lecture.admin.course.override.title=Konfiguration - Auf Kursebene \u00FCbersteuerbar @@ -158,7 +158,7 @@ reason.description=Beschreibung reason.id=ID reason.in.use=Diese Begr\u00FCndung wird noch von Lektionenblock verwendet und kann nich gel\u00F6scht werden. reason.title=Begr\u00FCndung -remove.custom.rate=Pers\u00F6nliches Schwellwert entfernen +remove.custom.rate=Pers\u00F6nlicher Schwellwert entfernen reopen=Wiederge\u00F6ffnet reopen.lecture.blocks=Lektionen wieder\u00F6ffnen repo.lectures=Lektionen @@ -219,7 +219,7 @@ table.header.lecture.block=Lektionenblock table.header.location=Ort table.header.planned.lectures=Lektionen table.header.presence=Abwesenheit -table.header.progress=Forschritt +table.header.progress=Fortschritt table.header.rate=Anwesenheit table.header.rate.warning=<i class\="o_icon o_midwarn"> </i> table.header.start.time=Von