handle another error caused by invalid LMS Setup access

This commit is contained in:
anhefti 2020-12-17 19:34:48 +01:00
parent 7ad3dc77b5
commit 69f8d6cd4a

View file

@ -157,17 +157,22 @@ public class LmsAPIServiceImpl implements LmsAPIService {
// case 1. if lmsSetupId is available only get quizzes from specified LmsSetup // case 1. if lmsSetupId is available only get quizzes from specified LmsSetup
final Long lmsSetupId = filterMap.getLmsSetupId(); final Long lmsSetupId = filterMap.getLmsSetupId();
if (lmsSetupId != null) { if (lmsSetupId != null) {
final Long institutionId = filterMap.getInstitutionId(); try {
final Long institutionId = filterMap.getInstitutionId();
final LmsAPITemplate template = getLmsAPITemplate(lmsSetupId) final LmsAPITemplate template = getLmsAPITemplate(lmsSetupId)
.getOrThrow(); .getOrThrow();
if (institutionId != null && template.lmsSetup().institutionId != institutionId) { if (institutionId != null && template.lmsSetup().institutionId != institutionId) {
return Collections.emptyList();
}
return template
.getQuizzes(filterMap)
.getOrThrow();
} catch (final Exception e) {
log.error("Failed to get quizzes from LMS Setup: {}", lmsSetupId, e);
return Collections.emptyList(); return Collections.emptyList();
} }
return template
.getQuizzes(filterMap)
.getOrThrow();
} }
// case 2. get quizzes from all LmsSetups of specified institution // case 2. get quizzes from all LmsSetups of specified institution