Skip to content
Snippets Groups Projects
Commit aa40e140 authored by uhensler's avatar uhensler
Browse files

OO-4207: Treat the children obligation to evaluate the status of structure nodes

parent 20992e75
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ package org.olat.course.nodes.st.learningpath;
import java.util.List;
import org.olat.course.learningpath.LearningPathObligation;
import org.olat.course.learningpath.LearningPathStatus;
import org.olat.course.learningpath.evaluation.DefaultLinearStatusEvaluator;
import org.olat.course.learningpath.evaluation.StatusEvaluator;
......@@ -57,10 +58,10 @@ class STLinearStatusEvaluator implements StatusEvaluator {
boolean allDone = true;
boolean inProgress = false;
for (LearningPathTreeNode child : children) {
if (allDone && isChildNotDone(child)) {
if (allDone && isNotOptional(child) && isNotDone(child)) {
allDone = false;
}
if (isChildInProgess(child)) {
if (isInProgess(child)) {
inProgress = true;
}
}
......@@ -70,13 +71,17 @@ class STLinearStatusEvaluator implements StatusEvaluator {
return currentNode.getStatus();
}
private boolean isChildInProgess(LearningPathTreeNode child) {
return LearningPathStatus.inProgress.equals(child.getStatus())
|| LearningPathStatus.done.equals(child.getStatus());
private boolean isNotOptional(LearningPathTreeNode node) {
return !LearningPathObligation.optional.equals(node.getObligation());
}
private boolean isChildNotDone(LearningPathTreeNode child) {
return !LearningPathStatus.done.equals(child.getStatus());
private boolean isInProgess(LearningPathTreeNode node) {
return LearningPathStatus.inProgress.equals(node.getStatus())
|| LearningPathStatus.done.equals(node.getStatus());
}
private boolean isNotDone(LearningPathTreeNode node) {
return !LearningPathStatus.done.equals(node.getStatus());
}
}
......@@ -25,9 +25,9 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.olat.course.learningpath.LearningPathObligation;
import org.olat.course.learningpath.LearningPathStatus;
import org.olat.course.learningpath.ui.LearningPathTreeNode;
import org.olat.course.nodes.st.learningpath.STLinearStatusEvaluator;
/**
*
......@@ -56,10 +56,17 @@ public class STLinearStatusEvaluatorTest {
List<LearningPathTreeNode> children = new ArrayList<>();
LearningPathTreeNode child1 = new LearningPathTreeNode(null, 1);
child1.setStatus(LearningPathStatus.done);
child1.setObligation(LearningPathObligation.mandatory);
children.add(child1);
LearningPathTreeNode child2 = new LearningPathTreeNode(null, 1);
child2.setStatus(LearningPathStatus.done);
child2.setObligation(LearningPathObligation.mandatory);
children.add(child2);
// Optional nodes should not be treated
LearningPathTreeNode child3 = new LearningPathTreeNode(null, 1);
child3.setStatus(LearningPathStatus.ready);
child3.setObligation(LearningPathObligation.optional);
children.add(child3);
LearningPathStatus status = sut.getStatus(currentNode, children);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment