From ce8a509fa9dbcb11c4dd8c8101c313ac88f96918 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 6 Apr 2023 15:10:01 +0200 Subject: [PATCH 1/4] prepare for UZH pre release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b9306729..694a5310 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ jar - 1.5-SNAPSHOT + 1.5-pre-uzh ${sebserver-version} ${sebserver-version} UTF-8 From bdec39d6f5ce13e99fa26069a47fc0fc66aaaa75 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 20 Apr 2023 09:51:09 +0200 Subject: [PATCH 2/4] fixed proctoring settings bug also for UZH --- .../gui/service/examconfig/impl/CellFieldBuilderAdapter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CellFieldBuilderAdapter.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CellFieldBuilderAdapter.java index 5e1f312e..db720158 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CellFieldBuilderAdapter.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CellFieldBuilderAdapter.java @@ -213,6 +213,7 @@ interface CellFieldBuilderAdapter { class ExpandBarCellFieldBuilderAdapter implements CellFieldBuilderAdapter { + public static final int HEIGHT_PER_FIELD = 26; final Map> orientationsOfExpandBar; int x = 100; @@ -278,7 +279,7 @@ interface CellFieldBuilderAdapter { this.width, labelKey); - expandItem.setHeight(this.height * 23); + expandItem.setHeight(this.height * HEIGHT_PER_FIELD); final Composite body = (Composite) expandItem.getControl(); final ViewGridBuilder expandBuilder = new ViewGridBuilder( body, From d6c0e8810d9fd7fb78905f5b0fb7af74caf37c82 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 25 Apr 2023 14:12:11 +0200 Subject: [PATCH 3/4] SEBSERV-140 fixed and adapted to Ans API change also fixed start-end date formatting (UTC) --- .../lms/impl/ans/AnsLmsAPITemplate.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java index f83df71a..25b85a07 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/ans/AnsLmsAPITemplate.java @@ -24,6 +24,7 @@ import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -58,6 +59,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPITemplate; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.AbstractCachedCourseAccess; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.AssignmentData; +import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.IntegrationsData; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.SEBServerData; import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.ans.AnsLmsData.UserData; @@ -247,8 +249,8 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms a.start_at = java.time.Instant.now().plus(365, java.time.temporal.ChronoUnit.DAYS).toString(); a.end_at = java.time.Instant.now().plus(366, java.time.temporal.ChronoUnit.DAYS).toString(); } - final DateTime startTime = new DateTime(a.start_at); - final DateTime endTime = new DateTime(a.end_at); + final DateTime startTime = new DateTime(a.start_at).toDateTime(DateTimeZone.UTC); + final DateTime endTime = new DateTime(a.end_at).toDateTime(DateTimeZone.UTC); final Map attrs = new HashMap<>(); attrs.put("assignment_id", String.valueOf(a.id)); return new QuizData( @@ -276,7 +278,15 @@ public class AnsLmsAPITemplate extends AbstractCachedCourseAccess implements Lms private AssignmentData getAssignmentById(final RestTemplate restTemplate, final String id) { final String url = String.format("/api/v2/assignments/%s", id); - return this.apiGet(restTemplate, url, AssignmentData.class); + final AssignmentData assignment = this.apiGet(restTemplate, url, AssignmentData.class); + if (assignment.integrations == null) { + assignment.integrations = new IntegrationsData(); + } + if (assignment.integrations.safe_exam_browser_server == null) { + assignment.integrations.safe_exam_browser_server = new SEBServerData(); + assignment.integrations.safe_exam_browser_server.enabled = false; + } + return assignment; } private List getQuizzesByIds(final RestTemplate restTemplate, final Set ids) { From 56ad74dc25ae647d90a9bd50ea1c04bdf13ea83c Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 27 Apr 2023 11:38:24 +0200 Subject: [PATCH 4/4] 3. patch UZH fix log spam (description), concurrent GUI calls using same hashmmap --- .../ethz/seb/sebserver/gbl/model/exam/Exam.java | 2 +- .../ch/ethz/seb/sebserver/gbl/util/Utils.java | 12 ++++++++++++ .../session/impl/ExamSessionServiceImpl.java | 16 +++++++++------- .../session/impl/ExamUpdateHandler.java | 13 ++++++------- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java index 87a6dbb0..8f7e10ce 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java @@ -426,7 +426,7 @@ public final class Exam implements GrantEntity { builder.append(", name="); builder.append(this.name); builder.append(", description="); - builder.append(this.getDescription()); + builder.append(Utils.truncateText(this.getDescription(), 255)); builder.append(", startTime="); builder.append(this.startTime); builder.append(", endTime="); 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 dc6f696a..7e0d736b 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 @@ -821,6 +821,18 @@ public final class Utils { return false; } + public static boolean isEqualsWithEmptyCheckTruncated(final String s1, final String s2) { + if (s2 == null || s1 == null) { + return false; + } + + if (s1.endsWith("...")) { + return Objects.equals(truncateText(s1, 1000), truncateText(s2, 1000)); + } else { + return Objects.equals(s1, s2); + } + } + public static Long toLong(final String longValue) { try { return Long.valueOf(longValue); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index 80178cc5..d49e8c4d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -467,15 +467,15 @@ public class ExamSessionServiceImpl implements ExamSessionService { final Set connectionIds) { this.duplicateCheck.clear(); - this.duplicates.clear(); + final Set duplicates = new HashSet<>(); return this.clientConnectionDAO .getConnectionTokens(examId) .map(tokens -> tokens.stream() - .map(this::getForTokenAndCheckDuplication) + .map(token -> this.getForTokenAndCheckDuplication(token, duplicates)) .filter(ccd -> connectionIds.contains(ccd.clientConnection.id)) .map(ccd -> ccd.clientStaticData) .collect(Collectors.toList())) - .map(staticData -> new MonitoringStaticClientData(staticData, this.duplicates)); + .map(staticData -> new MonitoringStaticClientData(staticData, duplicates)); } @Override @@ -633,17 +633,19 @@ public class ExamSessionServiceImpl implements ExamSessionService { } private final Map duplicateCheck = new HashMap<>(); - private final Set duplicates = new HashSet<>(); - private ClientConnectionDataInternal getForTokenAndCheckDuplication(final String token) { + private ClientConnectionDataInternal getForTokenAndCheckDuplication( + final String token, + final Set duplicates) { + final ClientConnectionDataInternal cc = this.examSessionCacheService.getClientConnection(token); if (cc.clientConnection.status.duplicateCheckStatus) { final Long id = this.duplicateCheck.put( cc.clientConnection.userSessionId, cc.getConnectionId()); if (id != null) { - this.duplicates.add(id); - this.duplicates.add(cc.getConnectionId()); + duplicates.add(id); + duplicates.add(cc.getConnectionId()); } } return cc; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java index f76b3a67..665e9400 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java @@ -355,22 +355,21 @@ class ExamUpdateHandler { if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name) || !Objects.equals(exam.startTime, quizData.startTime) || !Objects.equals(exam.endTime, quizData.endTime) || - !Utils.isEqualsWithEmptyCheck(exam.getDescription(), quizData.description) || + !Utils.isEqualsWithEmptyCheckTruncated(exam.getDescription(), quizData.description) || !Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) { if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name)) { - log.info("Update name difference from LMS. Exam:{}, QuizData: {}", exam.name, quizData.name); + log.info("Update name difference from LMS. Exam: {}, QuizData: {}", exam.name, quizData.name); } if (!Objects.equals(exam.startTime, quizData.startTime)) { - log.info("Update startTime difference from LMS. Exam:{}, QuizData: {}", exam.startTime, + log.info("Update startTime difference from LMS. Exam: {}, QuizData: {}", exam.startTime, quizData.startTime); } if (!Objects.equals(exam.endTime, quizData.endTime)) { - log.info("Update endTime difference from LMS. Exam:{}, QuizData: {}", exam.endTime, quizData.endTime); + log.info("Update endTime difference from LMS. Exam: {}, QuizData: {}", exam.endTime, quizData.endTime); } - if (!Utils.isEqualsWithEmptyCheck(exam.getDescription(), quizData.description)) { - log.info("Update description difference from LMS. Exam:{}, QuizData: {}", exam.getDescription(), - quizData.description); + if (!Utils.isEqualsWithEmptyCheckTruncated(exam.getDescription(), quizData.description)) { + log.info("Update description difference from LMS. Exam: {}", exam); } if (!Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) { log.info("Update startURL difference from LMS. Exam:{}, QuizData: {}",