SEBSERV-366
This commit is contained in:
parent
729dd23577
commit
b9962a2609
5 changed files with 64 additions and 36 deletions
|
@ -136,6 +136,8 @@ public class ExamForm implements TemplateComposer {
|
|||
new LocTextKey("sebserver.exam.consistency.no-lms-connection");
|
||||
private final static LocTextKey CONSISTENCY_MESSAGEINVALID_ID_REFERENCE =
|
||||
new LocTextKey("sebserver.exam.consistency.invalid-lms-id");
|
||||
private final static LocTextKey CONSISTENCY_MESSAGE_SEB_RESTRICTION_MISMATCH =
|
||||
new LocTextKey("sebserver.exam.consistencyseb-restriction-mismatch");
|
||||
|
||||
private final static LocTextKey AUTO_GEN_CONFIG_ERROR_TITLE =
|
||||
new LocTextKey("sebserver.exam.autogen.error.config.title");
|
||||
|
@ -220,30 +222,6 @@ public class ExamForm implements TemplateComposer {
|
|||
// new PageContext with actual EntityKey
|
||||
final PageContext formContext = pageContext.withEntityKey(exam.getEntityKey());
|
||||
|
||||
// check exam consistency and inform the user if needed
|
||||
Collection<APIMessage> warnings = null;
|
||||
if (readonly) {
|
||||
warnings = this.restService.getBuilder(CheckExamConsistency.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
||||
.call()
|
||||
.getOr(Collections.emptyList());
|
||||
if (warnings != null && !warnings.isEmpty()) {
|
||||
showConsistencyChecks(warnings, formContext.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
// the default page layout with title
|
||||
final LocTextKey titleKey = importFromQuizData
|
||||
? EXAM_FORM_TITLE_IMPORT_KEY
|
||||
: EXAM_FORM_TITLE_KEY;
|
||||
final Composite content = this.widgetFactory.defaultPageLayout(
|
||||
formContext.getParent(),
|
||||
titleKey);
|
||||
if (warnings != null && !warnings.isEmpty()) {
|
||||
final GridData gridData = (GridData) content.getLayoutData();
|
||||
gridData.verticalIndent = 10;
|
||||
}
|
||||
|
||||
final BooleanSupplier isNew = () -> importFromQuizData;
|
||||
final BooleanSupplier isNotNew = () -> !isNew.getAsBoolean();
|
||||
final EntityGrantCheck entityGrantCheck = currentUser.entityGrantCheck(exam);
|
||||
|
@ -262,6 +240,32 @@ public class ExamForm implements TemplateComposer {
|
|||
.call()
|
||||
.onError(e -> log.error("Unexpected error while trying to verify seb restriction settings: ", e))
|
||||
.getOr(false);
|
||||
final boolean sebRestrictionMismatch = isRestricted != exam.sebRestriction;
|
||||
|
||||
// check exam consistency and inform the user if needed
|
||||
Collection<APIMessage> warnings = null;
|
||||
if (readonly) {
|
||||
warnings = this.restService.getBuilder(CheckExamConsistency.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
||||
.call()
|
||||
.getOr(Collections.emptyList());
|
||||
if (sebRestrictionMismatch || (warnings != null && !warnings.isEmpty())) {
|
||||
showConsistencyChecks(warnings, sebRestrictionMismatch, formContext.getParent());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// the default page layout with title
|
||||
final LocTextKey titleKey = importFromQuizData
|
||||
? EXAM_FORM_TITLE_IMPORT_KEY
|
||||
: EXAM_FORM_TITLE_KEY;
|
||||
final Composite content = this.widgetFactory.defaultPageLayout(
|
||||
formContext.getParent(),
|
||||
titleKey);
|
||||
if ((warnings != null && !warnings.isEmpty()) || sebRestrictionMismatch) {
|
||||
final GridData gridData = (GridData) content.getLayoutData();
|
||||
gridData.verticalIndent = 10;
|
||||
}
|
||||
|
||||
// The Exam form
|
||||
final FormHandle<Exam> formHandle = this.pageService.formBuilder(
|
||||
|
@ -637,10 +641,10 @@ public class ExamForm implements TemplateComposer {
|
|||
return !lmsSetupTestResult.hasError(ErrorType.QUIZ_RESTRICTION_API_REQUEST);
|
||||
}
|
||||
|
||||
private void showConsistencyChecks(final Collection<APIMessage> result, final Composite parent) {
|
||||
if (result == null || result.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
private void showConsistencyChecks(
|
||||
final Collection<APIMessage> result,
|
||||
final boolean sebRestrictionMismatch,
|
||||
final Composite parent) {
|
||||
|
||||
final Composite warningPanel = this.widgetFactory.createWarningPanel(parent);
|
||||
this.widgetFactory.labelLocalized(
|
||||
|
@ -656,6 +660,21 @@ public class ExamForm implements TemplateComposer {
|
|||
warningPanel,
|
||||
CustomVariant.MESSAGE,
|
||||
message));
|
||||
|
||||
if (sebRestrictionMismatch) {
|
||||
this.widgetFactory.labelLocalized(
|
||||
warningPanel,
|
||||
CustomVariant.MESSAGE,
|
||||
CONSISTENCY_MESSAGE_SEB_RESTRICTION_MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
private void showSEBRestrictionMismatchMessage(final Composite parent) {
|
||||
final Composite warningPanel = this.widgetFactory.createWarningPanel(parent);
|
||||
this.widgetFactory.labelLocalized(
|
||||
warningPanel,
|
||||
CustomVariant.MESSAGE,
|
||||
CONSISTENCY_MESSAGE_SEB_RESTRICTION_MISMATCH);
|
||||
}
|
||||
|
||||
private Result<Exam> getExistingExam(final PageContext pageContext) {
|
||||
|
|
|
@ -372,14 +372,11 @@ public class LmsAPITemplateAdapter implements LmsAPITemplate {
|
|||
log.debug("Get course restriction: {} for LMSSetup: {}", exam.externalId, lmsSetup());
|
||||
}
|
||||
|
||||
System.out.println("******************* getSEBClientRestriction");
|
||||
|
||||
return this.restrictionRequest.protectedRun(() -> this.sebRestrictionAPI
|
||||
.getSEBClientRestriction(exam)
|
||||
.onError(error -> {
|
||||
if (error instanceof NoSEBRestrictionException) {
|
||||
return;
|
||||
}
|
||||
log.error("Failed to get SEB restrictions: {}", error.getMessage());
|
||||
})
|
||||
.onError(error -> log.error("Failed to get SEB restrictions: {}", error.getMessage()))
|
||||
.getOrThrow());
|
||||
}
|
||||
|
||||
|
|
|
@ -244,6 +244,7 @@ public class SEBRestrictionServiceImpl implements SEBRestrictionService {
|
|||
exam,
|
||||
sebRestrictionData))
|
||||
.map(data -> exam)
|
||||
.onError(error -> this.examDAO.setSEBRestriction(exam.id, false))
|
||||
.getOrThrow();
|
||||
})
|
||||
.getOrThrow();
|
||||
|
|
|
@ -30,7 +30,16 @@ public class MockSEBRestrictionAPI implements SEBRestrictionAPI {
|
|||
|
||||
@Override
|
||||
public Result<SEBRestriction> getSEBClientRestriction(final Exam exam) {
|
||||
log.info("Apply SEB Client restriction for Exam: {}", exam);
|
||||
log.info("Get SEB Client restriction for Exam: {}", exam);
|
||||
// if (BooleanUtils.toBoolean(exam.sebRestriction)) {
|
||||
// return Result.of(new SEBRestriction(
|
||||
// exam.id,
|
||||
// Stream.of("configKey").collect(Collectors.toList()),
|
||||
// Collections.emptyList(),
|
||||
// Collections.emptyMap()));
|
||||
// } else {
|
||||
// return Result.ofError(new NoSEBRestrictionException());
|
||||
// }
|
||||
return Result.ofError(new NoSEBRestrictionException());
|
||||
}
|
||||
|
||||
|
@ -40,6 +49,7 @@ public class MockSEBRestrictionAPI implements SEBRestrictionAPI {
|
|||
final SEBRestriction sebRestrictionData) {
|
||||
|
||||
log.info("Apply SEB Client restriction: {}", sebRestrictionData);
|
||||
//return Result.ofError(new NoSEBRestrictionException());
|
||||
return Result.of(sebRestrictionData);
|
||||
}
|
||||
|
||||
|
|
|
@ -509,9 +509,10 @@ sebserver.exam.consistency.title=Note: This exam is already running but has some
|
|||
sebserver.exam.consistency.missing-supporter= - There are no Exam Supporter defined for this exam. Use 'Edit Exam' on the right to add an Exam Supporter.
|
||||
sebserver.exam.consistency.missing-indicator= - There is no indicator defined for this exam. Use 'Add Indicator" on the right to add an indicator.
|
||||
sebserver.exam.consistency.missing-config= - There is no configuration defined for this exam. Use 'Add Configuration' to attach one.
|
||||
sebserver.exam.consistency.missing-seb-restriction= - There is currently no SEB restriction applied on the LMS side. Use 'Enable SEB Restriction' on the right to activate auto-restriction.<br/> Or if this is not possible consider doing it manually on the LMS.
|
||||
sebserver.exam.consistency.missing-seb-restriction= - There is currently no SEB restriction applied on the LMS side. Use 'Apply SEB Lock' on the right to activate auto-restriction.<br/> Or if this is not possible consider doing it manually on the LMS.
|
||||
sebserver.exam.consistency.no-lms-connection= - Failed to connect to the LMS Setup of this exam yet.<br/>Please check the LMS connection within the LMS Setup.
|
||||
sebserver.exam.consistency.invalid-lms-id= - The referencing course identifier seems to be invalid.<br/>Please check if the course for this exam still exists on the LMS and the course identifier has not changed.
|
||||
sebserver.exam.consistencyseb-restriction-mismatch= - There seems to be a mismatch in the SEB restriction for this exam. SEB Server has different state then the one of the LMS.<br/> The cause of this might lie in a connection errors with the LMS.<br/> However SEB Server is not able to verify the exact status of the SEB restriction on the LMS for this exam.
|
||||
sebserver.exam.confirm.remove-config=This exam is current running. The remove of the attached configuration will led to an invalid state<br/>where connecting SEB clients cannot download the configuration for the exam.<br/><br/>Are you sure to remove the configuration?
|
||||
sebserver.exam.autogen.error.config.title=Exam Import Setup Failure
|
||||
sebserver.exam.autogen.error.config.text=There was an unexpected error while setting up the imported exam.<br/> Please note that the exam has successfully been imported and can be modified but one or more additional auto-setup(s) failed:<br/>{0}
|
||||
|
|
Loading…
Reference in a new issue