From ceb2a53c834ae3de6e174bf08fc9d780fce9279f Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 25 May 2022 09:00:52 +0200 Subject: [PATCH] fixed exam quiz data update --- .../java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java | 6 ++++++ .../ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java | 2 +- .../ch/ethz/seb/sebserver/gui/content/exam/ExamList.java | 2 +- .../servicelayer/session/impl/ExamSessionServiceImpl.java | 2 +- .../servicelayer/session/impl/ExamUpdateHandler.java | 6 +++--- 5 files changed, 12 insertions(+), 6 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 01fd2206..cfdb4196 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 @@ -16,6 +16,7 @@ import java.util.Map; import javax.validation.constraints.NotNull; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -295,6 +296,11 @@ public final class Exam implements GrantEntity { return this.lmsAvailable; } + @JsonIgnore + public boolean isLmsAvailable() { + return BooleanUtils.isTrue(this.lmsAvailable); + } + public String getExternalId() { return this.externalId; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java index 45486939..05020439 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java @@ -596,7 +596,7 @@ public class ExamForm implements TemplateComposer { } private boolean testSEBRestrictionAPI(final Exam exam) { - if (!exam.lmsAvailable) { + if (!exam.isLmsAvailable()) { return false; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamList.java index d5c2fd75..a30016ef 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamList.java @@ -274,7 +274,7 @@ public class ExamList implements TemplateComposer { final Exam exam, final PageService pageService) { - if (BooleanUtils.isFalse(exam.lmsAvailable)) { + if (BooleanUtils.isFalse(exam.isLmsAvailable())) { item.setData(RWT.CUSTOM_VARIANT, CustomVariant.DISABLED.key); return; } 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 cad4963e..1c063ccf 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 @@ -132,7 +132,7 @@ public class ExamSessionServiceImpl implements ExamSessionService { .getOrThrow(); // check lms connection - if (!exam.lmsAvailable) { + if (!exam.isLmsAvailable()) { result.add(ErrorMessage.EXAM_CONSISTENCY_VALIDATION_LMS_CONNECTION.of(exam.getModelId())); } 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 0b4d1bb9..4cf9edaf 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 @@ -108,7 +108,7 @@ class ExamUpdateHandler { log.error("Failed to update quiz data for exam: {}", quiz, updateQuizData.getError()); } else { - if (!exam.lmsAvailable) { + if (!exam.isLmsAvailable()) { this.examDAO.markLMSAvailability(quiz.id, true, updateId); } failedOrMissing.remove(quiz.id); @@ -116,7 +116,7 @@ class ExamUpdateHandler { } } else { - if (!exam.lmsAvailable) { + if (!exam.isLmsAvailable()) { this.examDAO.markLMSAvailability(quiz.id, true, updateId); } failedOrMissing.remove(quiz.id); @@ -282,7 +282,7 @@ class ExamUpdateHandler { } } - if (exam.lmsAvailable) { + if (exam.isLmsAvailable()) { this.examDAO.markLMSAvailability(quizId, false, updateId); } throw new RuntimeException("Not Available");