diff --git a/src/main/java/org/olat/course/nodes/st/assessment/STFullyAssessedEvaluator.java b/src/main/java/org/olat/course/nodes/st/assessment/STFullyAssessedEvaluator.java index 9ab9d9094a6daa25ff76edbebb05449c442bb09c..f56dab2f984a88c1dd535ad6dbac2e7c794ae3a8 100644 --- a/src/main/java/org/olat/course/nodes/st/assessment/STFullyAssessedEvaluator.java +++ b/src/main/java/org/olat/course/nodes/st/assessment/STFullyAssessedEvaluator.java @@ -37,13 +37,23 @@ public class STFullyAssessedEvaluator implements FullyAssessedEvaluator { @Override public Boolean getFullyAssessed(AssessmentEvaluation currentEvaluation, List<AssessmentEvaluation> children, Blocker blocker) { + boolean hasMandatory = false; for (AssessmentEvaluation evaluation : children) { - if (isMandatory(evaluation) && isNotFullyAssessedYet(evaluation)) { - blocker.block(); - return Boolean.FALSE; + if (isMandatory(evaluation)) { + hasMandatory = true; + if (isNotFullyAssessedYet(evaluation)) { + blocker.block(); + return Boolean.FALSE; + } } } - return Boolean.TRUE; + // If the participant has fully assessed all mandatory elements, + // he should be able to continue from that element. In that case + // he has fully assessed the nodes earlier. So don't stop him afterwards! + if (hasMandatory) { + return Boolean.TRUE; + } + return Boolean.valueOf(!blocker.isBlocked()); } private boolean isNotFullyAssessedYet(AssessmentEvaluation evaluation) { diff --git a/src/main/java/org/olat/course/nodes/st/assessment/STLearningPathStatusEvaluator.java b/src/main/java/org/olat/course/nodes/st/assessment/STLearningPathStatusEvaluator.java index fb62c55c7dcfb51c4daa4e2dbd397649d78496ed..1b4e0351d5b9e6a89a66f4f8274c8398b786a6db 100644 --- a/src/main/java/org/olat/course/nodes/st/assessment/STLearningPathStatusEvaluator.java +++ b/src/main/java/org/olat/course/nodes/st/assessment/STLearningPathStatusEvaluator.java @@ -42,8 +42,7 @@ public class STLearningPathStatusEvaluator implements StatusEvaluator { @Override public AssessmentEntryStatus getStatus(AssessmentEvaluation currentEvaluation, Blocker blocker) { - AssessmentEntryStatus currentStatus = currentEvaluation.getAssessmentStatus(); - AssessmentEntryStatus status = currentStatus; + AssessmentEntryStatus status = currentEvaluation.getAssessmentStatus(); if (isBlocked(blocker)) { status = AssessmentEntryStatus.notReady; } else { @@ -69,6 +68,7 @@ public class STLearningPathStatusEvaluator implements StatusEvaluator { List<AssessmentEvaluation> children) { boolean notStarted = false; boolean inProgress = false; + boolean hasMandatory = false; boolean done = true; for (AssessmentEvaluation child : children) { if (isNotStarted(child)) { @@ -77,11 +77,19 @@ public class STLearningPathStatusEvaluator implements StatusEvaluator { if (isInProgess(child)) { inProgress = true; } - if (isMandatory(child) && isNotFullyAssessed(child)) { - done = false; + if (isMandatory(child)) { + hasMandatory = true; + if (isNotFullyAssessed(child)) { + done = false; + } } } + // Only optional, but no one is started. + if (!hasMandatory && !inProgress && done && AssessmentEntryStatus.notReady == currentEvaluation.getAssessmentStatus()) { + return AssessmentEntryStatus.notReady; + } + if (done) return AssessmentEntryStatus.done; if (inProgress) return AssessmentEntryStatus.inProgress; if (notStarted) return AssessmentEntryStatus.notStarted; diff --git a/src/test/java/org/olat/course/nodes/st/assessment/STFullyAssessedEvaluatorTest.java b/src/test/java/org/olat/course/nodes/st/assessment/STFullyAssessedEvaluatorTest.java index cccbfaeff2c4293932d6add31d0970ef254da5fe..5693d9974f8d921ba90c07fbc1f9f85511d1ab9f 100644 --- a/src/test/java/org/olat/course/nodes/st/assessment/STFullyAssessedEvaluatorTest.java +++ b/src/test/java/org/olat/course/nodes/st/assessment/STFullyAssessedEvaluatorTest.java @@ -56,6 +56,18 @@ public class STFullyAssessedEvaluatorTest { assertThat(blocker.isBlocked()).isFalse(); } + @Test + public void shouldReturnTrueIfAllMandatoryChildrenAreFullyAssessedEvenIfItIsBlocked() { + Blocker blocker = new SequentialBlocker(); + blocker.block(); + AssessmentEvaluation childMandatoryAssessed = createAssessmentEvaluation(Boolean.TRUE, AssessmentObligation.mandatory); + List<AssessmentEvaluation> children = Arrays.asList(childMandatoryAssessed); + + Boolean fullyAssessed = sut.getFullyAssessed(null, children, blocker); + + assertThat(fullyAssessed).isTrue(); + } + @Test public void shouldReturnTrueIfItHasNoChildren() { Blocker blocker = new SequentialBlocker(); @@ -91,7 +103,30 @@ public class STFullyAssessedEvaluatorTest { assertThat(blocker.isBlocked()).isTrue(); } - + @Test + public void shouldReturnTrueIfItHasOnlyOptionalChildren() { + Blocker blocker = new SequentialBlocker(); + AssessmentEvaluation childOptoinalNotAssessed = createAssessmentEvaluation(Boolean.FALSE, AssessmentObligation.optional); + List<AssessmentEvaluation> children = Arrays.asList(childOptoinalNotAssessed); + + Boolean fullyAssessed = sut.getFullyAssessed(null, children, blocker); + + assertThat(fullyAssessed).isTrue(); + } + + @Test + public void shouldReturnFalseIfItHasOnlyOptionalChildrenButItIsBlocked() { + Blocker blocker = new SequentialBlocker(); + blocker.block(); + AssessmentEvaluation childOptoinalNotAssessed1 = createAssessmentEvaluation(Boolean.FALSE, AssessmentObligation.optional); + AssessmentEvaluation childOptoinalNotAssessed2 = createAssessmentEvaluation(null, AssessmentObligation.optional); + List<AssessmentEvaluation> children = Arrays.asList(childOptoinalNotAssessed1, childOptoinalNotAssessed2); + + Boolean fullyAssessed = sut.getFullyAssessed(null, children, blocker); + + assertThat(fullyAssessed).isFalse(); + } + private AssessmentEvaluation createAssessmentEvaluation(Boolean fullyAssessd, AssessmentObligation obligation) { return new AssessmentEvaluation(null, null, null, null, null, null, null, null, fullyAssessd, null, null, null, null, null, null, null, 0, null, null, null, null, null, null, Overridable.of(obligation), null, null, null); diff --git a/src/test/java/org/olat/course/nodes/st/assessment/STLearningPathStatusEvaluatorTest.java b/src/test/java/org/olat/course/nodes/st/assessment/STLearningPathStatusEvaluatorTest.java index 629d5c65141141535074b364c5892db39cc40f45..e7b1f86da8151f4c90c5edb0d9b2a1e0926708d5 100644 --- a/src/test/java/org/olat/course/nodes/st/assessment/STLearningPathStatusEvaluatorTest.java +++ b/src/test/java/org/olat/course/nodes/st/assessment/STLearningPathStatusEvaluatorTest.java @@ -163,6 +163,34 @@ public class STLearningPathStatusEvaluatorTest { assertThat(status).isEqualTo(AssessmentEntryStatus.done); } + + @Test + public void shouldReturnNotReadyIfItHasOnlyOptionalChildrenButWasNotReady() { + AssessmentEvaluation currentEvaluation = getAssessmentEvaluation(Boolean.TRUE, AssessmentEntryStatus.notReady, null); + AssessmentEvaluation child1 = getAssessmentEvaluation(Boolean.FALSE, AssessmentEntryStatus.notReady, + AssessmentObligation.optional); + AssessmentEvaluation child2 = getAssessmentEvaluation(Boolean.FALSE, AssessmentEntryStatus.notStarted, + AssessmentObligation.optional); + List<AssessmentEvaluation> children = Arrays.asList(child1, child2); + + AssessmentEntryStatus status = sut.getStatus(currentEvaluation, children); + + assertThat(status).isEqualTo(AssessmentEntryStatus.notReady); + } + + @Test + public void shouldReturnDoneIfItHasOnlyOptionalChildrenButWasNotStarted() { + AssessmentEvaluation currentEvaluation = getAssessmentEvaluation(Boolean.TRUE, AssessmentEntryStatus.notStarted, null); + AssessmentEvaluation child1 = getAssessmentEvaluation(Boolean.FALSE, AssessmentEntryStatus.notReady, + AssessmentObligation.optional); + AssessmentEvaluation child2 = getAssessmentEvaluation(Boolean.FALSE, AssessmentEntryStatus.notStarted, + AssessmentObligation.optional); + List<AssessmentEvaluation> children = Arrays.asList(child1, child2); + + AssessmentEntryStatus status = sut.getStatus(currentEvaluation, children); + + assertThat(status).isEqualTo(AssessmentEntryStatus.done); + } private AssessmentEvaluation getAssessmentEvaluation(Boolean fullyAssessd, AssessmentEntryStatus assessmentStatus, AssessmentObligation obligation) { return new AssessmentEvaluation(null, null, null, null, null, null, assessmentStatus, null, fullyAssessd, null,