SEBSERV-150 fixed filtering
This commit is contained in:
parent
7fcfcf1445
commit
9941d57d44
3 changed files with 21 additions and 7 deletions
|
@ -246,7 +246,8 @@ public class QuizLookupList implements TemplateComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Function<QuizData, String> quizDataLmsSetupNameFunction(final ResourceService resourceService) {
|
private static Function<QuizData, String> quizDataLmsSetupNameFunction(final ResourceService resourceService) {
|
||||||
return quizData -> resourceService.getLmsSetupNameFunction()
|
final Function<String, String> lmsSetupNameFunction = resourceService.getLmsSetupNameFunction();
|
||||||
|
return quizData -> lmsSetupNameFunction
|
||||||
.apply(String.valueOf(quizData.lmsSetupId));
|
.apply(String.valueOf(quizData.lmsSetupId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl;
|
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -156,8 +157,16 @@ 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) {
|
||||||
return getLmsAPITemplate(lmsSetupId)
|
final Long institutionId = filterMap.getInstitutionId();
|
||||||
.flatMap(template -> template.getQuizzes(filterMap))
|
|
||||||
|
final LmsAPITemplate template = getLmsAPITemplate(lmsSetupId)
|
||||||
|
.getOrThrow();
|
||||||
|
|
||||||
|
if (institutionId != null && template.lmsSetup().institutionId != institutionId) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return template
|
||||||
|
.getQuizzes(filterMap)
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.moodle;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ public class MoodleLmsAPITemplateFactory {
|
||||||
private final AsyncService asyncService;
|
private final AsyncService asyncService;
|
||||||
private final ClientCredentialService clientCredentialService;
|
private final ClientCredentialService clientCredentialService;
|
||||||
private final ClientHttpRequestFactoryService clientHttpRequestFactoryService;
|
private final ClientHttpRequestFactoryService clientHttpRequestFactoryService;
|
||||||
private final MoodleCourseDataLazyLoader moodleCourseDataLazyLoader;
|
private final ApplicationContext applicationContext;
|
||||||
private final String[] alternativeTokenRequestPaths;
|
private final String[] alternativeTokenRequestPaths;
|
||||||
|
|
||||||
protected MoodleLmsAPITemplateFactory(
|
protected MoodleLmsAPITemplateFactory(
|
||||||
|
@ -41,14 +42,14 @@ public class MoodleLmsAPITemplateFactory {
|
||||||
final AsyncService asyncService,
|
final AsyncService asyncService,
|
||||||
final ClientCredentialService clientCredentialService,
|
final ClientCredentialService clientCredentialService,
|
||||||
final ClientHttpRequestFactoryService clientHttpRequestFactoryService,
|
final ClientHttpRequestFactoryService clientHttpRequestFactoryService,
|
||||||
final MoodleCourseDataLazyLoader moodleCourseDataLazyLoader,
|
final ApplicationContext applicationContext,
|
||||||
@Value("${sebserver.webservice.lms.moodle.api.token.request.paths:}") final String alternativeTokenRequestPaths) {
|
@Value("${sebserver.webservice.lms.moodle.api.token.request.paths:}") final String alternativeTokenRequestPaths) {
|
||||||
|
|
||||||
this.jsonMapper = jsonMapper;
|
this.jsonMapper = jsonMapper;
|
||||||
this.asyncService = asyncService;
|
this.asyncService = asyncService;
|
||||||
this.clientCredentialService = clientCredentialService;
|
this.clientCredentialService = clientCredentialService;
|
||||||
this.clientHttpRequestFactoryService = clientHttpRequestFactoryService;
|
this.clientHttpRequestFactoryService = clientHttpRequestFactoryService;
|
||||||
this.moodleCourseDataLazyLoader = moodleCourseDataLazyLoader;
|
this.applicationContext = applicationContext;
|
||||||
this.alternativeTokenRequestPaths = (alternativeTokenRequestPaths != null)
|
this.alternativeTokenRequestPaths = (alternativeTokenRequestPaths != null)
|
||||||
? StringUtils.split(alternativeTokenRequestPaths, Constants.LIST_SEPARATOR)
|
? StringUtils.split(alternativeTokenRequestPaths, Constants.LIST_SEPARATOR)
|
||||||
: null;
|
: null;
|
||||||
|
@ -61,6 +62,9 @@ public class MoodleLmsAPITemplateFactory {
|
||||||
|
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
|
|
||||||
|
final MoodleCourseDataLazyLoader lazyLoaderPrototype =
|
||||||
|
this.applicationContext.getBean(MoodleCourseDataLazyLoader.class);
|
||||||
|
|
||||||
final MoodleRestTemplateFactory moodleRestTemplateFactory = new MoodleRestTemplateFactory(
|
final MoodleRestTemplateFactory moodleRestTemplateFactory = new MoodleRestTemplateFactory(
|
||||||
this.jsonMapper,
|
this.jsonMapper,
|
||||||
lmsSetup,
|
lmsSetup,
|
||||||
|
@ -74,7 +78,7 @@ public class MoodleLmsAPITemplateFactory {
|
||||||
this.jsonMapper,
|
this.jsonMapper,
|
||||||
lmsSetup,
|
lmsSetup,
|
||||||
moodleRestTemplateFactory,
|
moodleRestTemplateFactory,
|
||||||
this.moodleCourseDataLazyLoader,
|
lazyLoaderPrototype,
|
||||||
this.asyncService);
|
this.asyncService);
|
||||||
|
|
||||||
final MoodleCourseRestriction moodleCourseRestriction = new MoodleCourseRestriction(
|
final MoodleCourseRestriction moodleCourseRestriction = new MoodleCourseRestriction(
|
||||||
|
|
Loading…
Reference in a new issue