fixed edx restriction check
This commit is contained in:
parent
c2d3cb4984
commit
7e725ff765
3 changed files with 10 additions and 12 deletions
|
@ -47,7 +47,10 @@ public interface SEBRestrictionAPI {
|
|||
return false;
|
||||
}
|
||||
|
||||
final SEBRestriction sebRestriction = sebClientRestriction.get();
|
||||
return hasSEBClientRestriction(sebClientRestriction.get());
|
||||
}
|
||||
|
||||
default boolean hasSEBClientRestriction(final SEBRestriction sebRestriction) {
|
||||
return !sebRestriction.configKeys.isEmpty() || !sebRestriction.browserExamKeys.isEmpty();
|
||||
}
|
||||
|
||||
|
|
|
@ -404,8 +404,7 @@ public class LmsAPITemplateAdapter implements LmsAPITemplate {
|
|||
return false;
|
||||
}
|
||||
|
||||
final SEBRestriction sebRestriction = sebClientRestriction.get();
|
||||
return !sebRestriction.configKeys.isEmpty() || !sebRestriction.browserExamKeys.isEmpty();
|
||||
return this.sebRestrictionAPI.hasSEBClientRestriction(sebClientRestriction.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,6 +38,7 @@ public class OpenEdxCourseRestriction implements SEBRestrictionAPI {
|
|||
|
||||
private static final Logger log = LoggerFactory.getLogger(OpenEdxCourseRestriction.class);
|
||||
|
||||
private static final SEBRestriction NO_RESTRICTION_MARKER = new SEBRestriction(null, null, null, null);
|
||||
private static final String OPEN_EDX_DEFAULT_COURSE_RESTRICTION_API_INFO = "/seb-openedx/seb-info";
|
||||
private static final String OPEN_EDX_DEFAULT_COURSE_RESTRICTION_API_PATH =
|
||||
"/seb-openedx/api/v1/course/%s/configuration/";
|
||||
|
@ -104,13 +105,8 @@ public class OpenEdxCourseRestriction implements SEBRestrictionAPI {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSEBClientRestriction(final Exam exam) {
|
||||
final Result<SEBRestriction> sebClientRestriction = getSEBClientRestriction(exam);
|
||||
if (sebClientRestriction.hasError()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
public boolean hasSEBClientRestriction(final SEBRestriction sebRestriction) {
|
||||
return NO_RESTRICTION_MARKER != sebRestriction;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -142,8 +138,8 @@ public class OpenEdxCourseRestriction implements SEBRestrictionAPI {
|
|||
return SEBRestriction.from(exam.id, data);
|
||||
} catch (final HttpClientErrorException ce) {
|
||||
if (ce.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||
// No SEB restriction is set for the specified exam, return an empty one
|
||||
return new SEBRestriction(exam.id, null, null, null);
|
||||
// No SEB restriction is set for the specified exam, return NO_RESTRICTION_MARKER
|
||||
return NO_RESTRICTION_MARKER;
|
||||
}
|
||||
throw ce;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue