fixed tests
This commit is contained in:
parent
4c002b4ac2
commit
34c8e2e33c
7 changed files with 35 additions and 29 deletions
|
@ -27,7 +27,6 @@ public final class LmsSetupTestResult {
|
||||||
public static final String ATTR_MISSING_ATTRIBUTE = "missingLMSSetupAttribute";
|
public static final String ATTR_MISSING_ATTRIBUTE = "missingLMSSetupAttribute";
|
||||||
|
|
||||||
public enum ErrorType {
|
public enum ErrorType {
|
||||||
FEATURE_NOT_AVAILABLE,
|
|
||||||
MISSING_ATTRIBUTE,
|
MISSING_ATTRIBUTE,
|
||||||
TOKEN_REQUEST,
|
TOKEN_REQUEST,
|
||||||
QUIZ_ACCESS_API_REQUEST,
|
QUIZ_ACCESS_API_REQUEST,
|
||||||
|
@ -119,10 +118,6 @@ public final class LmsSetupTestResult {
|
||||||
return new LmsSetupTestResult(new Error(ErrorType.QUIZ_RESTRICTION_API_REQUEST, message));
|
return new LmsSetupTestResult(new Error(ErrorType.QUIZ_RESTRICTION_API_REQUEST, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LmsSetupTestResult ofQuizRestrictionNotAvailable() {
|
|
||||||
return new LmsSetupTestResult(new Error(ErrorType.FEATURE_NOT_AVAILABLE, "Restriction Feature Not Available"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static class Error {
|
public final static class Error {
|
||||||
|
|
||||||
@JsonProperty(ATTR_ERROR_TYPE)
|
@JsonProperty(ATTR_ERROR_TYPE)
|
||||||
|
|
|
@ -36,6 +36,8 @@ import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.ProctoringSettings;
|
import ch.ethz.seb.sebserver.gbl.model.exam.ProctoringSettings;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.Features;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult.ErrorType;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult.ErrorType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
|
import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
|
||||||
|
@ -464,6 +466,14 @@ public class ExamForm implements TemplateComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean testSEBRestrictionAPI(final Exam exam) {
|
private boolean testSEBRestrictionAPI(final Exam exam) {
|
||||||
|
final Result<LmsSetup> lmsSetupCall = this.restService.getBuilder(GetLmsSetup.class)
|
||||||
|
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId))
|
||||||
|
.call();
|
||||||
|
|
||||||
|
if (!lmsSetupCall.hasError() && !lmsSetupCall.get().lmsType.features.contains(Features.SEB_RESTRICTION)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Call the testing endpoint with the specified data to test
|
// Call the testing endpoint with the specified data to test
|
||||||
final Result<LmsSetupTestResult> result = this.restService.getBuilder(TestLmsSetup.class)
|
final Result<LmsSetupTestResult> result = this.restService.getBuilder(TestLmsSetup.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId))
|
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId))
|
||||||
|
@ -474,8 +484,7 @@ public class ExamForm implements TemplateComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
final LmsSetupTestResult lmsSetupTestResult = result.get();
|
final LmsSetupTestResult lmsSetupTestResult = result.get();
|
||||||
return !lmsSetupTestResult.hasError(ErrorType.QUIZ_RESTRICTION_API_REQUEST)
|
return !lmsSetupTestResult.hasError(ErrorType.QUIZ_RESTRICTION_API_REQUEST);
|
||||||
&& !lmsSetupTestResult.hasError(ErrorType.FEATURE_NOT_AVAILABLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showConsistencyChecks(final Collection<APIMessage> result, final Composite parent) {
|
private void showConsistencyChecks(final Collection<APIMessage> result, final Composite parent) {
|
||||||
|
|
|
@ -69,7 +69,6 @@ public class MonitoringExamSearchPopup {
|
||||||
final PageActionBuilder actionBuilder = this.pageService
|
final PageActionBuilder actionBuilder = this.pageService
|
||||||
.pageActionBuilder(pageContext.clearEntityKeys());
|
.pageActionBuilder(pageContext.clearEntityKeys());
|
||||||
|
|
||||||
final EntityTable<ClientConnection> table =
|
|
||||||
this.pageService.entityTableBuilder(restService.getRestCall(GetClientConnectionPage.class))
|
this.pageService.entityTableBuilder(restService.getRestCall(GetClientConnectionPage.class))
|
||||||
.withEmptyMessage(EMPTY_LIST_TEXT_KEY)
|
.withEmptyMessage(EMPTY_LIST_TEXT_KEY)
|
||||||
.withPaging(10)
|
.withPaging(10)
|
||||||
|
|
|
@ -120,9 +120,9 @@ public class LmsAPIServiceImpl implements LmsAPIService {
|
||||||
|
|
||||||
if (template.lmsSetup().getLmsType().features.contains(LmsSetup.Features.SEB_RESTRICTION)) {
|
if (template.lmsSetup().getLmsType().features.contains(LmsSetup.Features.SEB_RESTRICTION)) {
|
||||||
return template.testCourseRestrictionAPI();
|
return template.testCourseRestrictionAPI();
|
||||||
} else {
|
|
||||||
return LmsSetupTestResult.ofQuizRestrictionNotAvailable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return LmsSetupTestResult.ofOkay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,6 +21,7 @@ public abstract class AbstractClientIndicator implements ClientIndicator {
|
||||||
protected Long connectionId;
|
protected Long connectionId;
|
||||||
protected boolean cachingEnabled;
|
protected boolean cachingEnabled;
|
||||||
|
|
||||||
|
protected boolean valueInitializes = false;
|
||||||
protected double currentValue = Double.NaN;
|
protected double currentValue = Double.NaN;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,12 +53,14 @@ public abstract class AbstractClientIndicator implements ClientIndicator {
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
this.currentValue = Double.NaN;
|
this.currentValue = Double.NaN;
|
||||||
|
this.valueInitializes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getValue() {
|
public double getValue() {
|
||||||
if (Double.isNaN(this.currentValue) || !this.cachingEnabled) {
|
if (!this.valueInitializes || !this.cachingEnabled) {
|
||||||
this.currentValue = computeValueAt(DateTime.now(DateTimeZone.UTC).getMillis());
|
this.currentValue = computeValueAt(DateTime.now(DateTimeZone.UTC).getMillis());
|
||||||
|
this.valueInitializes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.currentValue;
|
return this.currentValue;
|
||||||
|
|
|
@ -61,7 +61,7 @@ public abstract class AbstractLogLevelCountIndicator extends AbstractLogIndicato
|
||||||
return errors.doubleValue();
|
return errors.doubleValue();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.error("Failed to get indicator count from persistent storage: ", e);
|
log.error("Failed to get indicator count from persistent storage: ", e);
|
||||||
return 0;
|
return super.currentValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,14 +65,14 @@ public abstract class AbstractLogNumberIndicator extends AbstractLogIndicator {
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
if (execute == null || execute.isEmpty()) {
|
if (execute == null || execute.isEmpty()) {
|
||||||
return 0;
|
return super.currentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final BigDecimal numericValue = execute.get(execute.size() - 1).getNumericValue();
|
final BigDecimal numericValue = execute.get(execute.size() - 1).getNumericValue();
|
||||||
if (numericValue != null) {
|
if (numericValue != null) {
|
||||||
return numericValue.doubleValue();
|
return numericValue.doubleValue();
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return super.currentValue;
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.error("Failed to get indicator number from persistent storage: {}", e.getMessage());
|
log.error("Failed to get indicator number from persistent storage: {}", e.getMessage());
|
||||||
|
|
Loading…
Reference in a new issue