From 9625383f50f4a706ceb54957d1fa50c8984fde59 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Aug 2022 14:15:27 +0200 Subject: [PATCH 1/9] prepare for 1.4.1 patch --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bb0e4b3b..a3ce4601 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ jar - 1.4.0 + 1.4.1-SNAPSHOT ${sebserver-version} ${sebserver-version} UTF-8 From 7869ceb4939d620c84250827e69c221a2abd62e8 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 29 Aug 2022 10:42:15 +0200 Subject: [PATCH 2/9] better check if exam data has changed on LMS --- .../ch/ethz/seb/sebserver/gbl/util/Utils.java | 14 ++++++++++++++ .../session/impl/ExamUpdateHandler.java | 17 ++++++++++++++--- .../ethz/seb/sebserver/gbl/util/ReplTest.java | 14 ++++++++++++++ .../ethz/seb/sebserver/gbl/util/UtilsTest.java | 13 +++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) 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 18f1ed69..45095388 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 @@ -757,4 +757,18 @@ public final class Utils { } } + public static boolean isEqualsWithEmptyCheck(final String s1, final String s2) { + // checks equal strings and both null + if (Objects.equals(s1, s2)) { + return true; + } + + // check null and empty string + if (StringUtils.isBlank(s1) && StringUtils.isBlank(s2)) { + return true; + } + + return false; + } + } 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 d911846c..4c7ce0e4 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 @@ -341,15 +341,26 @@ class ExamUpdateHandler { if (!Objects.equals(exam.name, quizData.name) || !Objects.equals(exam.startTime, quizData.startTime) || !Objects.equals(exam.endTime, quizData.endTime) || - !Objects.equals(exam.getDescription(), quizData.description) || - !Objects.equals(exam.getStartURL(), quizData.startURL)) { + !Utils.isEqualsWithEmptyCheck(exam.getDescription(), quizData.description) || + !Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) { + + if (log.isDebugEnabled()) { + log.debug("Update difference from LMS. Exam:{}, QuizData: {}", exam, quizData); + } return true; } if (quizData.additionalAttributes != null && !quizData.additionalAttributes.isEmpty()) { for (final Map.Entry attr : quizData.additionalAttributes.entrySet()) { - if (!Objects.equals(exam.getAdditionalAttribute(attr.getKey()), attr.getValue())) { + final String currentAttrValue = exam.getAdditionalAttribute(attr.getKey()); + if (!Utils.isEqualsWithEmptyCheck(currentAttrValue, attr.getValue())) { + if (log.isDebugEnabled()) { + log.debug("Update difference from LMS: attribute{}, currentValue: {}, lmsValue: {}", + attr.getKey(), + currentAttrValue, + attr.getValue()); + } return true; } } diff --git a/src/test/java/ch/ethz/seb/sebserver/gbl/util/ReplTest.java b/src/test/java/ch/ethz/seb/sebserver/gbl/util/ReplTest.java index bd19fe5a..fe39fbce 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gbl/util/ReplTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gbl/util/ReplTest.java @@ -8,6 +8,13 @@ package ch.ethz.seb.sebserver.gbl.util; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Objects; + +import org.junit.Test; + public class ReplTest { // @Test @@ -48,4 +55,11 @@ public class ReplTest { // assertTrue(new Boolean(false) == new Boolean(false)); // } + @Test + public void testObjectEquals() { + assertTrue(Objects.equals("", "")); + assertTrue(Objects.equals(null, null)); + assertFalse(Objects.equals("", null)); + } + } diff --git a/src/test/java/ch/ethz/seb/sebserver/gbl/util/UtilsTest.java b/src/test/java/ch/ethz/seb/sebserver/gbl/util/UtilsTest.java index 6bc7a523..a5e00fd7 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gbl/util/UtilsTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gbl/util/UtilsTest.java @@ -243,4 +243,17 @@ public class UtilsTest { .contains("ch.ethz.seb.sebserver.gbl.util.UtilsTest.testFormatStackTracePrint")); } + @Test + public void testIsEqualsWithEmptyCheck() { + assertTrue(Utils.isEqualsWithEmptyCheck("aa", "aa")); + assertTrue(Utils.isEqualsWithEmptyCheck("", "")); + assertTrue(Utils.isEqualsWithEmptyCheck(null, null)); + assertTrue(Utils.isEqualsWithEmptyCheck("", null)); + assertTrue(Utils.isEqualsWithEmptyCheck(null, "")); + assertTrue(Utils.isEqualsWithEmptyCheck(" ", null)); + assertTrue(Utils.isEqualsWithEmptyCheck(" ", " ")); + + assertFalse(Utils.isEqualsWithEmptyCheck(" ", "a")); + } + } From d5d119fe7d8042170a44279a958aeee2b1090e33 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 18 Oct 2022 10:48:11 +0200 Subject: [PATCH 3/9] prevent empty additional attributes from being saved --- .../servicelayer/dao/impl/ExamDAOImpl.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java index dd17c5ff..847490b8 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java @@ -742,14 +742,20 @@ public class ExamDAOImpl implements ExamDAO { private QuizData saveAdditionalQuizAttributes(final Long examId, final QuizData quizData) { final Map additionalAttributes = new HashMap<>(quizData.getAdditionalAttributes()); - additionalAttributes.put(QuizData.QUIZ_ATTR_DESCRIPTION, quizData.description); - additionalAttributes.put(QuizData.QUIZ_ATTR_START_URL, quizData.startURL); + if (StringUtils.isNotBlank(quizData.description)) { + additionalAttributes.put(QuizData.QUIZ_ATTR_DESCRIPTION, quizData.description); + } + if (StringUtils.isNotBlank(quizData.startURL)) { + additionalAttributes.put(QuizData.QUIZ_ATTR_START_URL, quizData.startURL); + } - this.additionalAttributesDAO.saveAdditionalAttributes( - EntityType.EXAM, - examId, - additionalAttributes) - .getOrThrow(); + if (!additionalAttributes.isEmpty()) { + this.additionalAttributesDAO.saveAdditionalAttributes( + EntityType.EXAM, + examId, + additionalAttributes) + .getOrThrow(); + } return quizData; } From 6a4924d16968ebd5e4ed8bfbe3d06985fff7bea9 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 20 Oct 2022 08:40:43 +0200 Subject: [PATCH 4/9] fixed init admin for existing but deactivated admin account --- .../sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java index fb0a9f82..63586188 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java @@ -135,8 +135,6 @@ public class UserDAOImpl implements UserDAO { this.userRecordMapper .selectByExample() .where(UserRecordDynamicSqlSupport.username, isEqualTo(username)) - .and(UserRecordDynamicSqlSupport.active, - isEqualTo(BooleanUtils.toInteger(true))) .build() .execute()) .flatMap(this::sebServerUserFromRecord); From 019f9e142116eaacdf9d28eed2b2f6b5691fb0df Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 20 Oct 2022 09:58:09 +0200 Subject: [PATCH 5/9] SEBSERV-354 fixed --- .../servicelayer/lms/SEBRestrictionAPI.java | 2 +- .../lms/impl/SEBRestrictionServiceImpl.java | 1 + .../impl/ExamConfigUpdateServiceImpl.java | 20 +++++++++---------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionAPI.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionAPI.java index a88786ee..7667a4b3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionAPI.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionAPI.java @@ -35,7 +35,7 @@ public interface SEBRestrictionAPI { /** Use this to check if there is a SEB restriction available on the LMS for the specified exam. * - * A SEB Restriction is available if there it can get from LMS and if there is either a Config-Key + * A SEB Restriction is available if it can get from LMS and if there is either a Config-Key * or a BrowserExam-Key set or both. If none of this keys is set, the SEB Restriction is been * considered to not set on the LMS. * diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java index 05c69b7f..417d6899 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/SEBRestrictionServiceImpl.java @@ -197,6 +197,7 @@ public class SEBRestrictionServiceImpl implements SEBRestrictionService { log.info("ExamStartedEvent received, process applySEBClientRestriction..."); applySEBClientRestriction(event.exam) + .flatMap(e -> this.examDAO.setSEBRestriction(e.id, true)) .onError(error -> log.error( "Failed to apply SEB restrictions for started exam: {}", event.exam, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java index 3c369f10..38196264 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java @@ -129,11 +129,12 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService { // generate the new Config Key and update the Config Key within the LMSSetup API for each exam (delete old Key and add new Key) for (final Exam exam : exams) { - if (exam.getStatus() == ExamStatus.RUNNING || this.examAdminService.isRestricted(exam).getOr(false)) { + if (exam.getStatus() == ExamStatus.RUNNING) { this.examUpdateHandler .getSEBRestrictionService() .applySEBClientRestriction(exam) + .flatMap(e -> this.examDAO.setSEBRestriction(e.id, true)) .onError(t -> log.error("Failed to update SEB Client restriction for Exam: {}", exam, t)); } } @@ -201,15 +202,14 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService { .getOrThrow(); // update seb client restriction if the feature is activated for the exam - if (this.examAdminService.isRestricted(exam).getOr(false)) { - this.examUpdateHandler - .getSEBRestrictionService() - .applySEBClientRestriction(exam) - .onError(t -> log.error( - "Failed to update SEB Client restriction for Exam: {}", - exam, - t)); - } + this.examUpdateHandler + .getSEBRestrictionService() + .applySEBClientRestriction(exam) + .flatMap(e -> this.examDAO.setSEBRestriction(e.id, true)) + .onError(t -> log.error( + "Failed to update SEB Client restriction for Exam: {}", + exam, + t)); // flush the exam cache. If there was an error during flush, it is logged but this process goes on // and the saved changes are not rolled back From 9a1fea50ab16a87edac886f192be45d3a5956122 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 7 Nov 2022 15:55:08 +0100 Subject: [PATCH 6/9] SEBSERV-362 Send (re)join instruction after collecting room was closed by proctor --- .../impl/proctoring/ExamProctoringRoomServiceImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ExamProctoringRoomServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ExamProctoringRoomServiceImpl.java index 5241d681..8ddd0d78 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ExamProctoringRoomServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ExamProctoringRoomServiceImpl.java @@ -475,7 +475,8 @@ public class ExamProctoringRoomServiceImpl implements ExamProctoringRoomService final ExamProctoringService examProctoringService) { // get all connections of the room - final List connectionTokens = this.getActiveCollectingRoomConnections(examId, roomName) + final List connectionTokens = this + .getActiveCollectingRoomConnections(examId, roomName) .getOrThrow() .stream() .map(cc -> cc.connectionToken) @@ -501,6 +502,12 @@ public class ExamProctoringRoomServiceImpl implements ExamProctoringRoomService connectionTokens, examProctoringService.getDefaultReconfigInstructionAttributes()); } + + // Send the rejoin to collecting room instruction to all involved clients + sendJoinCollectingRoomInstructions( + proctoringSettings, + connectionTokens, + examProctoringService); } private void cleanupBreakOutRooms(final ClientConnectionRecord cc) { From bcedeaf5d5aaceff2945e5019e1d9b8751d281c1 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 10 Nov 2022 10:36:20 +0100 Subject: [PATCH 7/9] code cleanup --- .../session/impl/ExamConfigUpdateServiceImpl.java | 6 +----- .../servicelayer/session/impl/ExamUpdateHandler.java | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java index 38196264..b5576433 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamConfigUpdateServiceImpl.java @@ -29,7 +29,6 @@ import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ConfigurationDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamConfigurationMapDAO; import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO; -import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamAdminService; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamConfigUpdateService; import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService; @@ -45,22 +44,19 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService { private final ExamConfigurationMapDAO examConfigurationMapDAO; private final ExamSessionService examSessionService; private final ExamUpdateHandler examUpdateHandler; - private final ExamAdminService examAdminService; protected ExamConfigUpdateServiceImpl( final ExamDAO examDAO, final ConfigurationDAO configurationDAO, final ExamConfigurationMapDAO examConfigurationMapDAO, final ExamSessionService examSessionService, - final ExamUpdateHandler examUpdateHandler, - final ExamAdminService examAdminService) { + final ExamUpdateHandler examUpdateHandler) { this.examDAO = examDAO; this.configurationDAO = configurationDAO; this.examConfigurationMapDAO = examConfigurationMapDAO; this.examSessionService = examSessionService; this.examUpdateHandler = examUpdateHandler; - this.examAdminService = examAdminService; } // processing: 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 4c7ce0e4..51bbb203 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 @@ -338,7 +338,7 @@ class ExamUpdateHandler { } private boolean hasChanges(final Exam exam, final QuizData quizData) { - if (!Objects.equals(exam.name, quizData.name) || + 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) || From c5ff3b0369f4ac0841889ef2f37e99ec3e2e9f86 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 10 Nov 2022 11:08:42 +0100 Subject: [PATCH 8/9] fixed exam update task : has changed test --- .../webservice/servicelayer/session/impl/ExamUpdateHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 51bbb203..b792fe8f 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 @@ -338,7 +338,7 @@ class ExamUpdateHandler { } private boolean hasChanges(final Exam exam, final QuizData quizData) { - if (Utils.isEqualsWithEmptyCheck(exam.name, quizData.name) || + 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) || From 0a99979e328fe35715b8333ffd10842ae2f0beb4 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 10 Nov 2022 14:41:24 +0100 Subject: [PATCH 9/9] prepare for patch release 1.4.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a3ce4601..1d7cb3be 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ jar - 1.4.1-SNAPSHOT + 1.4.1 ${sebserver-version} ${sebserver-version} UTF-8