From 6c4902db029300cbcbf5fe7c4ea052e1da0632b6 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 18 Jul 2024 12:00:22 +0200 Subject: [PATCH 1/6] improve logging for Moodle user Details --- .../lms/impl/moodle/MoodleUtils.java | 23 +++++++++++++++++++ .../moodle/legacy/MoodleCourseAccess.java | 4 ++++ .../plugin/MoodlePluginCourseAccess.java | 4 ++++ 3 files changed, 31 insertions(+) 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..89dd9dbe 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,10 @@ public class MoodleCourseAccess implements CourseAccessAPI { throw new RuntimeException("No user details on Moodle API request"); } + if (log.isDebugEnabled()) { + log.debug("User details received from Moodle: {}", userDetails[0]); + } + 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..2d30ffd5 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,10 @@ public class MoodlePluginCourseAccess extends AbstractCachedCourseAccess impleme throw new RuntimeException("No user details on Moodle API request"); } + if (log.isDebugEnabled()) { + log.debug("User details received from Moodle: {}", userDetails[0]); + } + final Map additionalAttributes = MoodleUtils.getMoodleAccountDetails(userDetails); return new ExamineeAccountDetails( userDetails[0].id, From 3166152c90fbcc1d3d16489c81db62a0a2e48078 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 18 Jul 2024 13:44:54 +0200 Subject: [PATCH 2/6] SEBSERV-541 column width now sticks to user session --- .../remote/webservice/auth/CurrentUser.java | 4 ++ .../seb/sebserver/gui/table/EntityTable.java | 48 ++++++++++++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) 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/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); + } + } + } From b0e8e11d263dd66a8ffc49c9cedd63d906e600ee Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 18 Jul 2024 14:18:10 +0200 Subject: [PATCH 3/6] SEBSERV-569 fixed, regression due to code cleanup --- .../seb/sebserver/gbl/model/exam/QuizData.java | 2 ++ .../ch/ethz/seb/sebserver/gbl/util/Utils.java | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java index c171ba5f..a456c7d3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java @@ -253,7 +253,9 @@ public final class QuizData implements GrantEntity { } public static Comparator getComparator(final String sort) { + final boolean descending = PageSortOrder.getSortOrder(sort) == PageSortOrder.DESCENDING; + System.out.println("**************** sort: " + sort + " descending " + descending); final String sortParam = PageSortOrder.decode(sort); if (QUIZ_ATTR_NAME.equals(sortParam)) { return (qd1, qd2) -> StringUtils.compare(qd1.name, qd2.name) * ((descending) ? -1 : 1); 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) { From f4ccd16425cb2c170891a3460a75aefa023af627 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 18 Jul 2024 14:18:29 +0200 Subject: [PATCH 4/6] SEBSERV-569 fixed, regression due to code cleanup --- .../java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java index a456c7d3..c171ba5f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/QuizData.java @@ -253,9 +253,7 @@ public final class QuizData implements GrantEntity { } public static Comparator getComparator(final String sort) { - final boolean descending = PageSortOrder.getSortOrder(sort) == PageSortOrder.DESCENDING; - System.out.println("**************** sort: " + sort + " descending " + descending); final String sortParam = PageSortOrder.decode(sort); if (QUIZ_ATTR_NAME.equals(sortParam)) { return (qd1, qd2) -> StringUtils.compare(qd1.name, qd2.name) * ((descending) ? -1 : 1); From 1cb0242507b28d7eb90a103b0d9b4e540ae3aaea Mon Sep 17 00:00:00 2001 From: Nadim Ritter Date: Fri, 19 Jul 2024 11:34:45 +0200 Subject: [PATCH 5/6] better logging for lastname bug --- .../lms/impl/moodle/legacy/MoodleCourseAccess.java | 8 ++++++++ .../lms/impl/moodle/plugin/MoodlePluginCourseAccess.java | 8 ++++++++ 2 files changed, 16 insertions(+) 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 89dd9dbe..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,9 +403,17 @@ 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( 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 2d30ffd5..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,9 +339,17 @@ 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( From deac21f4bad014df56f8d72564eabf18ac9c86a7 Mon Sep 17 00:00:00 2001 From: Nadim Ritter Date: Mon, 22 Jul 2024 14:13:50 +0200 Subject: [PATCH 6/6] rename redirect to gallery-view --- .../service/session/proctoring/MonitoringProctoringService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);