diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java index bc4c28ef..03b604b2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java @@ -857,11 +857,23 @@ public final class Utils { } public static int compareDateTime(final DateTime dt1, final DateTime dt2, final boolean descending) { - return Objects.compare(dt1, dt1, DateTime::compareTo ) * ((descending) ? -1 : 1); + return ((dt1 == dt2) + ? 0 + : (dt1 == null || dt1 == null) + ? 1 + : (dt2 == null || dt2 == null) + ? -1 + : dt1.compareTo(dt2)) * ((descending) ? -1 : 1); } public static int compareIds(final Long id1, final Long id2, final boolean descending) { - return Objects.compare(id1, id2, Long::compareTo ) * ((descending) ? -1 : 1); + return ((Objects.equals(id1, id2)) + ? 0 + : (id1 == null || id1 == null) + ? 1 + : (id2 == null || id2 == null) + ? -1 + : id1.compareTo(id2)) * ((descending) ? -1 : 1); } public static String toFileName(final String name) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/CurrentUser.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/CurrentUser.java index b1bb9384..cc139930 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/CurrentUser.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/CurrentUser.java @@ -70,6 +70,10 @@ public class CurrentUser { this.attributes.put(name, value); } + public void deleteAttribute(final String name) { + this.attributes.remove(name); + } + public String getAttribute(final String name) { return this.attributes.get(name); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/proctoring/MonitoringProctoringService.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/proctoring/MonitoringProctoringService.java index fee1dbfc..7e428a2b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/proctoring/MonitoringProctoringService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/proctoring/MonitoringProctoringService.java @@ -338,7 +338,7 @@ public class MonitoringProctoringService { .getUserPassword(); final String body = "username=" + currentUser.get().username + "&password=" + userPassword.toString() - + "&redirect=/galleryView/" + group.uuid; + + "&redirect=/gallery-view/" + group.uuid; // apply jwt token request final HttpEntity httpEntity = new HttpEntity<>(body, httpHeaders); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java index f5d5d926..59d43c88 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java @@ -76,6 +76,7 @@ public class EntityTable { private final String sortAttrName; private final String sortOrderAttrName; private final String currentPageAttrName; + private final String columnWidthAttrName; private final boolean markupEnabled; private final Consumer> pageReloadListener; @@ -138,6 +139,7 @@ public class EntityTable { this.sortAttrName = name + "_sort"; this.sortOrderAttrName = name + "_sortOrder"; this.currentPageAttrName = name + "_currentPage"; + this.columnWidthAttrName = name + "_columnWidth"; this.markupEnabled = markupEnabled; this.defaultSortColumn = defaultSortColumn; @@ -236,6 +238,7 @@ public class EntityTable { this.navigator = new TableNavigator(this); createTableColumns(); + this.pageNumber = initCurrentPageFromUserAttr(); initFilterFromUserAttrs(); initSortFromUserAttr(); @@ -317,6 +320,8 @@ public class EntityTable { } public void reset() { + deleteColumnWidths(); + adaptColumnWidth(null); this.sortColumn = this.defaultSortColumn; this.sortOrder = this.defaultSortOrder; updateSortUserAttr(); @@ -595,7 +600,7 @@ public class EntityTable { try { int currentTableWidth = this.table.getParent().getClientArea().width; // If we have all columns with filter we need some more space for the - // filter actions in the right hand side. This tweak gives enough space for that + // filter actions on the right hand side. This tweak gives enough space for that if (this.filter != null && this.columns.size() == this.filter.size()) { currentTableWidth -= 60; } @@ -620,7 +625,7 @@ public class EntityTable { final int newWidth = (pSize > 0) ? columnUnitSize * column.getWidthProportion() : columnUnitSize; - tableColumn.setWidth(newWidth); + loadOrSetColumnWidth(index, newWidth); if (this.filter != null) { this.filter.adaptColumnWidth(this.table.indexOf(tableColumn), newWidth); } @@ -639,11 +644,7 @@ public class EntityTable { final Widget widget = event.widget; if (widget instanceof TableColumn) { final TableColumn tableColumn = ((TableColumn) widget); - if (this.filter != null) { - this.filter.adaptColumnWidth( - this.table.indexOf(tableColumn), - tableColumn.getWidth()); - } + this.saveColumnSize(table.indexOf(tableColumn)); } } @@ -906,4 +907,37 @@ public class EntityTable { } } + private void saveColumnSize(final int columnIndex) { + final TableColumn column = table.getColumn(columnIndex); + if (column.getWidth() > 0) { + this.pageService + .getCurrentUser() + .putAttribute( + columnWidthAttrName + columnIndex, + String.valueOf(table.getColumn(columnIndex).getWidth())); + } + } + + private void loadOrSetColumnWidth(final int columnIndex, final int defaultWidth) { + int width = defaultWidth; + try { + width = Integer.parseInt(this.pageService + .getCurrentUser() + .getAttribute(columnWidthAttrName + columnIndex)); + } catch (final Exception e) { + // ignore + } + + table.getColumn(columnIndex).setWidth(width); + saveColumnSize(columnIndex); + } + + private void deleteColumnWidths() { + for (int i = 0; i < this.columns.size(); i++) { + this.pageService + .getCurrentUser() + .deleteAttribute(columnWidthAttrName + i); + } + } + } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleUtils.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleUtils.java index d6d83a39..a5b8e4be 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleUtils.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/MoodleUtils.java @@ -530,6 +530,29 @@ public abstract class MoodleUtils { this.mailformat = mailformat; this.descriptionformat = descriptionformat; } + @Override + public String toString() { + return "MoodleUserDetails{" + + "id='" + id + '\'' + + ", username='" + username + '\'' + + ", firstname='" + firstname + '\'' + + ", lastname='" + lastname + '\'' + + ", fullname='" + fullname + '\'' + + ", email='" + email + '\'' + + ", department='" + department + '\'' + + ", firstaccess=" + firstaccess + + ", lastaccess=" + lastaccess + + ", auth='" + auth + '\'' + + ", suspended=" + suspended + + ", confirmed=" + confirmed + + ", lang='" + lang + '\'' + + ", theme='" + theme + '\'' + + ", timezone='" + timezone + '\'' + + ", description='" + description + '\'' + + ", mailformat=" + mailformat + + ", descriptionformat=" + descriptionformat + + '}'; + } } @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/legacy/MoodleCourseAccess.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/legacy/MoodleCourseAccess.java index f37e62e7..f9b51b91 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/legacy/MoodleCourseAccess.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/legacy/MoodleCourseAccess.java @@ -403,6 +403,18 @@ public class MoodleCourseAccess implements CourseAccessAPI { throw new RuntimeException("No user details on Moodle API request"); } + System.out.println("---------------------"); + System.out.println("*************it got here moodle course access debugging"); + if (log.isDebugEnabled()) { + System.out.println("*************inside if"); + log.debug("User details received from Moodle: {}", userDetails[0]); + } + System.out.println("firstname: " + userDetails[0].firstname); + System.out.println("firstname: " + userDetails[0].lastname); + System.out.println("firstname: " + userDetails[0].fullname); + System.out.println(userDetails[0]); + System.out.println("---------------------"); + final Map additionalAttributes = MoodleUtils.getMoodleAccountDetails(userDetails); return new ExamineeAccountDetails( userDetails[0].id, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java index c6bce011..4725f1dd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/plugin/MoodlePluginCourseAccess.java @@ -339,6 +339,18 @@ public class MoodlePluginCourseAccess extends AbstractCachedCourseAccess impleme throw new RuntimeException("No user details on Moodle API request"); } + System.out.println("---------------------"); + System.out.println("*************it got here moodle plugin debugging"); + if (log.isDebugEnabled()) { + System.out.println("*************inside if"); + log.debug("User details received from Moodle: {}", userDetails[0]); + } + System.out.println("firstname: " + userDetails[0].firstname); + System.out.println("firstname: " + userDetails[0].lastname); + System.out.println("firstname: " + userDetails[0].fullname); + System.out.println(userDetails[0]); + System.out.println("---------------------"); + final Map additionalAttributes = MoodleUtils.getMoodleAccountDetails(userDetails); return new ExamineeAccountDetails( userDetails[0].id,