From 019f9e142116eaacdf9d28eed2b2f6b5691fb0df Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 20 Oct 2022 09:58:09 +0200 Subject: [PATCH] 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