From c5aa34c939fc679320c949926874762371cec894 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Aug 2022 11:40:13 +0200 Subject: [PATCH 1/8] code cleanup uncomment Demo Exams for development --- .../lms/impl/mockup/MockCourseAccessAPI.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java index a92c65a7..37e32ff0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java @@ -92,25 +92,25 @@ public class MockCourseAccessAPI implements CourseAccessAPI { null, "http://lms.mockup.com/api/")); - if (webserviceInfo.hasProfile("dev")) { - for (int i = 12; i < 50; i++) { - this.mockups.add(new QuizData( - "quiz10" + i, institutionId, lmsSetupId, lmsType, "Demo Quiz 10 " + i + " (MOCKUP)", - i + "_Starts in a minute and ends after five minutes", - DateTime.now(DateTimeZone.UTC).plus(Constants.MINUTE_IN_MILLIS) - .toString(Constants.DEFAULT_DATE_TIME_FORMAT), - DateTime.now(DateTimeZone.UTC).plus(6 * Constants.MINUTE_IN_MILLIS) - .toString(Constants.DEFAULT_DATE_TIME_FORMAT), - "http://lms.mockup.com/api/")); - this.mockups.add(new QuizData( - "quiz11" + i, institutionId, lmsSetupId, lmsType, "Demo Quiz 11 " + i + " (MOCKUP)", - i + "_Starts in a minute and ends never", - DateTime.now(DateTimeZone.UTC).plus(Constants.MINUTE_IN_MILLIS) - .toString(Constants.DEFAULT_DATE_TIME_FORMAT), - null, - "http://lms.mockup.com/api/")); - } - } +// if (webserviceInfo.hasProfile("dev")) { +// for (int i = 12; i < 50; i++) { +// this.mockups.add(new QuizData( +// "quiz10" + i, institutionId, lmsSetupId, lmsType, "Demo Quiz 10 " + i + " (MOCKUP)", +// i + "_Starts in a minute and ends after five minutes", +// DateTime.now(DateTimeZone.UTC).plus(Constants.MINUTE_IN_MILLIS) +// .toString(Constants.DEFAULT_DATE_TIME_FORMAT), +// DateTime.now(DateTimeZone.UTC).plus(6 * Constants.MINUTE_IN_MILLIS) +// .toString(Constants.DEFAULT_DATE_TIME_FORMAT), +// "http://lms.mockup.com/api/")); +// this.mockups.add(new QuizData( +// "quiz11" + i, institutionId, lmsSetupId, lmsType, "Demo Quiz 11 " + i + " (MOCKUP)", +// i + "_Starts in a minute and ends never", +// DateTime.now(DateTimeZone.UTC).plus(Constants.MINUTE_IN_MILLIS) +// .toString(Constants.DEFAULT_DATE_TIME_FORMAT), +// null, +// "http://lms.mockup.com/api/")); +// } +// } } @Override From 422fbb61df5b55e9ed04c1f7fb75227802bf9e64 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Aug 2022 12:53:50 +0200 Subject: [PATCH 2/8] prepare for release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 99b11afc..bb0e4b3b 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ jar - 1.4.0-SNAPSHOT + 1.4.0 ${sebserver-version} ${sebserver-version} UTF-8 From 9625383f50f4a706ceb54957d1fa50c8984fde59 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 15 Aug 2022 14:15:27 +0200 Subject: [PATCH 3/8] 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 25ed224b3a03c1e3a91e45ef35076202d6029c9f Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Aug 2022 10:47:35 +0200 Subject: [PATCH 4/8] fixed lms update if not available at all --- .../legacy/MoodleRestTemplateFactory.java | 2 +- .../session/impl/ExamUpdateHandler.java | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/legacy/MoodleRestTemplateFactory.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/legacy/MoodleRestTemplateFactory.java index 5de31e82..f3b803ae 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/legacy/MoodleRestTemplateFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/moodle/legacy/MoodleRestTemplateFactory.java @@ -137,7 +137,7 @@ public class MoodleRestTemplateFactory { log.warn("Failed to get access token for LMS: {}({})", lmsSetup.name, lmsSetup.id, - result.getError()); + result.getError().getMessage()); } return result; }) 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 a3dd4a3c..d911846c 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 @@ -88,6 +88,31 @@ class ExamUpdateHandler { final Set failedOrMissing = new HashSet<>(exams.keySet()); final String updateId = this.createUpdateId(); + // test overall LMS access + try { + this.lmsAPIService + .getLmsAPITemplate(lmsSetupId) + .getOrThrow() + .checkCourseAPIAccess(); + } catch (final Exception e) { + log.warn("No LMS access, mark all exams of the LMS as not connected to LMS"); + if (!failedOrMissing.isEmpty()) { + failedOrMissing + .stream() + .forEach(quizId -> { + try { + final Exam exam = exams.get(quizId); + if (exam.lmsAvailable == null || exam.isLmsAvailable()) { + this.examDAO.markLMSAvailability(quizId, false, updateId); + } + } catch (final Exception ee) { + log.error("Failed to mark exam: {} as not connected to LMS", quizId, ee); + } + }); + } + return failedOrMissing; + } + this.lmsAPIService .getLmsAPITemplate(lmsSetupId) .map(template -> { From 9bc53edf6bd26dfdf004c03ec24dd4fd692b5ee2 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Aug 2022 11:08:21 +0200 Subject: [PATCH 5/8] test --- .../webservice/servicelayer/session/impl/ExamUpdateHandler.java | 1 + 1 file changed, 1 insertion(+) 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..1b0763d7 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 @@ -94,6 +94,7 @@ class ExamUpdateHandler { .getLmsAPITemplate(lmsSetupId) .getOrThrow() .checkCourseAPIAccess(); + log.info("LMS access OK"); } catch (final Exception e) { log.warn("No LMS access, mark all exams of the LMS as not connected to LMS"); if (!failedOrMissing.isEmpty()) { From 75eae12dc0d4107659b2180720ee1c68f2faed64 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Aug 2022 11:13:59 +0200 Subject: [PATCH 6/8] test fix --- .../servicelayer/session/impl/ExamUpdateHandler.java | 3 ++- 1 file changed, 2 insertions(+), 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 1b0763d7..87eae3bf 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 @@ -94,8 +94,9 @@ class ExamUpdateHandler { .getLmsAPITemplate(lmsSetupId) .getOrThrow() .checkCourseAPIAccess(); - log.info("LMS access OK"); + log.info("LMS access OK: {}", lmsSetupId); } catch (final Exception e) { + log.info("LMS access NOT OK: {}", lmsSetupId); log.warn("No LMS access, mark all exams of the LMS as not connected to LMS"); if (!failedOrMissing.isEmpty()) { failedOrMissing From cf2a978ad38b28644d8886073049611360f460a9 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Aug 2022 11:27:55 +0200 Subject: [PATCH 7/8] fix check --- .../webservice/servicelayer/lms/impl/LmsAPITemplateAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/LmsAPITemplateAdapter.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/LmsAPITemplateAdapter.java index 71f79253..9a647c34 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/LmsAPITemplateAdapter.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/LmsAPITemplateAdapter.java @@ -202,7 +202,7 @@ public class LmsAPITemplateAdapter implements LmsAPITemplate { throw new RuntimeException("No course API Access: " + testCourseAccessAPI); } return testCourseAccessAPI; - }); + }).getOrThrow(); } @Override From d127ecebbe7d41f8065303936a8555bd3af111d5 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Aug 2022 11:42:47 +0200 Subject: [PATCH 8/8] cleanup --- .../webservice/servicelayer/session/impl/ExamUpdateHandler.java | 2 -- 1 file changed, 2 deletions(-) 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 87eae3bf..d911846c 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 @@ -94,9 +94,7 @@ class ExamUpdateHandler { .getLmsAPITemplate(lmsSetupId) .getOrThrow() .checkCourseAPIAccess(); - log.info("LMS access OK: {}", lmsSetupId); } catch (final Exception e) { - log.info("LMS access NOT OK: {}", lmsSetupId); log.warn("No LMS access, mark all exams of the LMS as not connected to LMS"); if (!failedOrMissing.isEmpty()) { failedOrMissing