From 0d8fb4b8802b810745545cf2936a1789276a7001 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 17 May 2021 14:36:50 +0200 Subject: [PATCH] code cleanup --- .../servicelayer/lms/SEBRestrictionService.java | 12 +++++++++--- .../lms/impl/SEBRestrictionServiceImpl.java | 4 +--- .../session/impl/ExamSessionServiceImpl.java | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionService.java index 57558816..0eefed29 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/SEBRestrictionService.java @@ -8,8 +8,6 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.lms; -import javax.validation.constraints.NotNull; - import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction; import ch.ethz.seb.sebserver.gbl.util.Result; @@ -55,6 +53,14 @@ public interface SEBRestrictionService { * @return Result refer to the Exam instance or to an error if happened */ Result releaseSEBClientRestriction(Exam exam); - boolean checkConsistency(@NotNull Long lmsSetupId, Exam exam); + /** This checks whether the SEB Restriction is switched on for the given Exam. + * The check only applies if the SEB Restriction feature is switched on + * for the particular LMS type of the Exam. otherwise it returns true to indicate + * everything is fine with SEB Restriction + * + * @param exam the Exam instance to chech + * @return false if the SEB Restriction feature is switched on for the given Exam but the restriction is not applied + * to the LMS */ + boolean checkSebRestrictionSet(Exam exam); } 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 081e0ad0..dfc47920 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 @@ -18,8 +18,6 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import javax.validation.constraints.NotNull; - import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,7 +69,7 @@ public class SEBRestrictionServiceImpl implements SEBRestrictionService { } @Override - public boolean checkConsistency(@NotNull final Long lmsSetupId, final Exam exam) { + public boolean checkSebRestrictionSet(final Exam exam) { final LmsSetup lmsSetup = this.lmsAPIService .getLmsSetup(exam.lmsSetupId) .getOr(null); 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 1d01a7df..1860b58d 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 @@ -148,7 +148,7 @@ public class ExamSessionServiceImpl implements ExamSessionService { return null; }); - if (!this.sebRestrictionService.checkConsistency(exam.lmsSetupId, exam)) { + if (!this.sebRestrictionService.checkSebRestrictionSet(exam)) { result.add( ErrorMessage.EXAM_CONSISTENCY_VALIDATION_SEB_RESTRICTION .of(exam.getModelId()));