fixed lms update if not available at all
This commit is contained in:
parent
422fbb61df
commit
25ed224b3a
2 changed files with 26 additions and 1 deletions
|
@ -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;
|
||||
})
|
||||
|
|
|
@ -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 -> {
|
||||
|
|
Loading…
Reference in a new issue