Merge branch 'dev-2.0' of github.com:SafeExamBrowser/seb-server into redesign

This commit is contained in:
Nadim Ritter 2024-07-30 11:44:13 +02:00
commit 600e805240
7 changed files with 107 additions and 10 deletions

View file

@ -857,11 +857,23 @@ public final class Utils {
} }
public static int compareDateTime(final DateTime dt1, final DateTime dt2, final boolean descending) { 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) { 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) { public static String toFileName(final String name) {

View file

@ -70,6 +70,10 @@ public class CurrentUser {
this.attributes.put(name, value); this.attributes.put(name, value);
} }
public void deleteAttribute(final String name) {
this.attributes.remove(name);
}
public String getAttribute(final String name) { public String getAttribute(final String name) {
return this.attributes.get(name); return this.attributes.get(name);
} }

View file

@ -338,7 +338,7 @@ public class MonitoringProctoringService {
.getUserPassword(); .getUserPassword();
final String body = "username=" + currentUser.get().username final String body = "username=" + currentUser.get().username
+ "&password=" + userPassword.toString() + "&password=" + userPassword.toString()
+ "&redirect=/galleryView/" + group.uuid; + "&redirect=/gallery-view/" + group.uuid;
// apply jwt token request // apply jwt token request
final HttpEntity<String> httpEntity = new HttpEntity<>(body, httpHeaders); final HttpEntity<String> httpEntity = new HttpEntity<>(body, httpHeaders);

View file

@ -76,6 +76,7 @@ public class EntityTable<ROW extends ModelIdAware> {
private final String sortAttrName; private final String sortAttrName;
private final String sortOrderAttrName; private final String sortOrderAttrName;
private final String currentPageAttrName; private final String currentPageAttrName;
private final String columnWidthAttrName;
private final boolean markupEnabled; private final boolean markupEnabled;
private final Consumer<EntityTable<ROW>> pageReloadListener; private final Consumer<EntityTable<ROW>> pageReloadListener;
@ -138,6 +139,7 @@ public class EntityTable<ROW extends ModelIdAware> {
this.sortAttrName = name + "_sort"; this.sortAttrName = name + "_sort";
this.sortOrderAttrName = name + "_sortOrder"; this.sortOrderAttrName = name + "_sortOrder";
this.currentPageAttrName = name + "_currentPage"; this.currentPageAttrName = name + "_currentPage";
this.columnWidthAttrName = name + "_columnWidth";
this.markupEnabled = markupEnabled; this.markupEnabled = markupEnabled;
this.defaultSortColumn = defaultSortColumn; this.defaultSortColumn = defaultSortColumn;
@ -236,6 +238,7 @@ public class EntityTable<ROW extends ModelIdAware> {
this.navigator = new TableNavigator(this); this.navigator = new TableNavigator(this);
createTableColumns(); createTableColumns();
this.pageNumber = initCurrentPageFromUserAttr(); this.pageNumber = initCurrentPageFromUserAttr();
initFilterFromUserAttrs(); initFilterFromUserAttrs();
initSortFromUserAttr(); initSortFromUserAttr();
@ -317,6 +320,8 @@ public class EntityTable<ROW extends ModelIdAware> {
} }
public void reset() { public void reset() {
deleteColumnWidths();
adaptColumnWidth(null);
this.sortColumn = this.defaultSortColumn; this.sortColumn = this.defaultSortColumn;
this.sortOrder = this.defaultSortOrder; this.sortOrder = this.defaultSortOrder;
updateSortUserAttr(); updateSortUserAttr();
@ -595,7 +600,7 @@ public class EntityTable<ROW extends ModelIdAware> {
try { try {
int currentTableWidth = this.table.getParent().getClientArea().width; int currentTableWidth = this.table.getParent().getClientArea().width;
// If we have all columns with filter we need some more space for the // 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()) { if (this.filter != null && this.columns.size() == this.filter.size()) {
currentTableWidth -= 60; currentTableWidth -= 60;
} }
@ -620,7 +625,7 @@ public class EntityTable<ROW extends ModelIdAware> {
final int newWidth = (pSize > 0) final int newWidth = (pSize > 0)
? columnUnitSize * column.getWidthProportion() ? columnUnitSize * column.getWidthProportion()
: columnUnitSize; : columnUnitSize;
tableColumn.setWidth(newWidth); loadOrSetColumnWidth(index, newWidth);
if (this.filter != null) { if (this.filter != null) {
this.filter.adaptColumnWidth(this.table.indexOf(tableColumn), newWidth); this.filter.adaptColumnWidth(this.table.indexOf(tableColumn), newWidth);
} }
@ -639,11 +644,7 @@ public class EntityTable<ROW extends ModelIdAware> {
final Widget widget = event.widget; final Widget widget = event.widget;
if (widget instanceof TableColumn) { if (widget instanceof TableColumn) {
final TableColumn tableColumn = ((TableColumn) widget); final TableColumn tableColumn = ((TableColumn) widget);
if (this.filter != null) { this.saveColumnSize(table.indexOf(tableColumn));
this.filter.adaptColumnWidth(
this.table.indexOf(tableColumn),
tableColumn.getWidth());
}
} }
} }
@ -906,4 +907,37 @@ public class EntityTable<ROW extends ModelIdAware> {
} }
} }
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);
}
}
} }

View file

@ -530,6 +530,29 @@ public abstract class MoodleUtils {
this.mailformat = mailformat; this.mailformat = mailformat;
this.descriptionformat = descriptionformat; 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) @JsonIgnoreProperties(ignoreUnknown = true)

View file

@ -403,6 +403,18 @@ public class MoodleCourseAccess implements CourseAccessAPI {
throw new RuntimeException("No user details on Moodle API request"); 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<String, String> additionalAttributes = MoodleUtils.getMoodleAccountDetails(userDetails); final Map<String, String> additionalAttributes = MoodleUtils.getMoodleAccountDetails(userDetails);
return new ExamineeAccountDetails( return new ExamineeAccountDetails(
userDetails[0].id, userDetails[0].id,

View file

@ -339,6 +339,18 @@ public class MoodlePluginCourseAccess extends AbstractCachedCourseAccess impleme
throw new RuntimeException("No user details on Moodle API request"); 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<String, String> additionalAttributes = MoodleUtils.getMoodleAccountDetails(userDetails); final Map<String, String> additionalAttributes = MoodleUtils.getMoodleAccountDetails(userDetails);
return new ExamineeAccountDetails( return new ExamineeAccountDetails(
userDetails[0].id, userDetails[0].id,