Merge remote-tracking branch 'origin/rel-1.4.0' into dev-1.4

This commit is contained in:
anhefti 2022-08-16 12:14:18 +02:00
commit 793d61836d
3 changed files with 27 additions and 2 deletions

View file

@ -202,7 +202,7 @@ public class LmsAPITemplateAdapter implements LmsAPITemplate {
throw new RuntimeException("No course API Access: " + testCourseAccessAPI);
}
return testCourseAccessAPI;
});
}).getOrThrow();
}
@Override

View file

@ -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;
})

View file

@ -88,6 +88,31 @@ class ExamUpdateHandler {
final Set<String> 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 -> {