diff --git a/src/main/java/org/olat/course/assessment/manager/CourseAssessmentManagerImpl.java b/src/main/java/org/olat/course/assessment/manager/CourseAssessmentManagerImpl.java index 31c2fb4e6fd62aee7216aaa341c1f9b52a7c2731..12c8a81160a367f47bd4ed7cb33932c1a5bc75f8 100644 --- a/src/main/java/org/olat/course/assessment/manager/CourseAssessmentManagerImpl.java +++ b/src/main/java/org/olat/course/assessment/manager/CourseAssessmentManagerImpl.java @@ -443,7 +443,8 @@ public class CourseAssessmentManagerImpl implements AssessmentManager { assessmentService.updateAssessmentEntry(nodeAssessment); DBFactory.getInstance().commit(); - nodeAccessService.onCompletionUpdate(courseNode, userCourseEnvironment, completion, status, by); + nodeAccessService.onStatusUpdated(courseNode, userCourseEnvironment, status, by); + DBFactory.getInstance().commit(); ScoreAccounting scoreAccounting = userCourseEnvironment.getScoreAccounting(); scoreAccounting.evaluateAll(true); @@ -456,7 +457,7 @@ public class CourseAssessmentManagerImpl implements AssessmentManager { Identity assessedIdentity = userCourseEnvironment.getIdentityEnvironment().getIdentity(); AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity , courseNode); if (Objects.equal(fullyAssessed, nodeAssessment.getFullyAssessed())) { - // Fully assess can only set once to true + // Fully assess can only set once return; } @@ -527,16 +528,16 @@ public class CourseAssessmentManagerImpl implements AssessmentManager { assessmentEntry.setAttempts(attempts); } assessmentEntry = assessmentService.updateAssessmentEntry(assessmentEntry); - DBFactory.getInstance().commit();//commit before sending events + DBFactory.getInstance().commit(); - if (Boolean.TRUE.equals(passed)) { - nodeAccessService.onPassed(courseNode, userCourseEnv , Role.auto); - } + nodeAccessService.onPassedUpdated(courseNode, userCourseEnv, passed, Role.auto); + nodeAccessService.onStatusUpdated(courseNode, userCourseEnv, assessmentEntry.getAssessmentStatus(), by); + DBFactory.getInstance().commit(); //reevalute the tree ScoreAccounting scoreAccounting = userCourseEnv.getScoreAccounting(); scoreAccounting.evaluateAll(true); - DBFactory.getInstance().commit();//commit before sending events + DBFactory.getInstance().commit(); // node log UserNodeAuditManager am = courseEnv.getAuditManager(); diff --git a/src/main/java/org/olat/course/condition/ConditionNodeAccessProvider.java b/src/main/java/org/olat/course/condition/ConditionNodeAccessProvider.java index 012aff75a2f0ac9b7180bb8305a2d17899ecfdfa..e3223daba4c27e92a8482b6b133ee5eedf7aa79f 100644 --- a/src/main/java/org/olat/course/condition/ConditionNodeAccessProvider.java +++ b/src/main/java/org/olat/course/condition/ConditionNodeAccessProvider.java @@ -99,13 +99,13 @@ public class ConditionNodeAccessProvider implements NodeAccessProvider { } @Override - public void onCompletionUpdate(CourseNode courseNode, UserCourseEnvironment userCourseEnv, - Double completion, AssessmentEntryStatus status, Role by) { + public void onStatusUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, + AssessmentEntryStatus status, Role by) { // nothing to do } @Override - public void onPassed(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Role by) { + public void onPassedUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Boolean passed, Role by) { // nothing to do } diff --git a/src/main/java/org/olat/course/learningpath/FullyAssessedResultImpl.java b/src/main/java/org/olat/course/learningpath/FullyAssessedResultImpl.java index a53dff1d5f92761f3efb9b476ecf898598caaa2b..171427ad969610953b2fc643abb66a7220d228b6 100644 --- a/src/main/java/org/olat/course/learningpath/FullyAssessedResultImpl.java +++ b/src/main/java/org/olat/course/learningpath/FullyAssessedResultImpl.java @@ -29,14 +29,21 @@ import org.olat.course.learningpath.LearningPathConfigs.FullyAssessedResult; */ class FullyAssessedResultImpl implements FullyAssessedResult { + private final boolean enabled; private final boolean fullyAssessed; private final boolean done; - FullyAssessedResultImpl(boolean fullyAssessed, boolean done) { + FullyAssessedResultImpl(boolean enabled, boolean fullyAssessed, boolean done) { + this.enabled = enabled; this.fullyAssessed = fullyAssessed; this.done = done; } + + @Override + public boolean isEnabled() { + return enabled; + } @Override public boolean isFullyAssessed() { diff --git a/src/main/java/org/olat/course/learningpath/LearningPathConfigs.java b/src/main/java/org/olat/course/learningpath/LearningPathConfigs.java index 6332e0fcf1f20c428bf8947c05ae6098f65ac9d0..3601181bf2d4ed69d12cb0cf0b4449b68e5ec921 100644 --- a/src/main/java/org/olat/course/learningpath/LearningPathConfigs.java +++ b/src/main/java/org/olat/course/learningpath/LearningPathConfigs.java @@ -40,23 +40,23 @@ public interface LearningPathConfigs { public FullyAssessedResult isFullyAssessedOnConfirmation(); - public FullyAssessedResult isFullyAssessedOnPassed(); - - public FullyAssessedResult isFullyAssessedOnCompletion(Double completion); + public FullyAssessedResult isFullyAssessedOnPassed(Boolean passed); public FullyAssessedResult isFullyAssessedOnStatus(AssessmentEntryStatus status); public static FullyAssessedResult notFullyAssessed() { - return new FullyAssessedResultImpl(false, false); + return new FullyAssessedResultImpl(false, false, false); } - public static FullyAssessedResult fullyAssessed(boolean fullyAssessed, boolean done) { - return new FullyAssessedResultImpl(fullyAssessed, done); + public static FullyAssessedResult fullyAssessed(boolean enabled, boolean fullyAssessed, boolean done) { + return new FullyAssessedResultImpl(enabled, fullyAssessed, done); } public interface FullyAssessedResult { + public boolean isEnabled(); + public boolean isFullyAssessed(); public boolean isDone(); diff --git a/src/main/java/org/olat/course/learningpath/manager/LearningPathNodeAccessProvider.java b/src/main/java/org/olat/course/learningpath/manager/LearningPathNodeAccessProvider.java index 489ba97ef4e8bcb4af0caff0579fa2541293d310..015d4a62cadf0a5e57e78faf1aa9b0e0f993cabf 100644 --- a/src/main/java/org/olat/course/learningpath/manager/LearningPathNodeAccessProvider.java +++ b/src/main/java/org/olat/course/learningpath/manager/LearningPathNodeAccessProvider.java @@ -96,10 +96,10 @@ public class LearningPathNodeAccessProvider implements NodeAccessProvider { public boolean onNodeVisited(CourseNode courseNode, UserCourseEnvironment userCourseEnv) { FullyAssessedResult result = getConfigs(courseNode).isFullyAssessedOnNodeVisited(); boolean participant = userCourseEnv.isParticipant(); - if (participant && result.isFullyAssessed()) { + if (participant && result.isEnabled()) { AssessmentEntryStatus status = getStatus(courseNode, userCourseEnv, result.isDone()); - courseAssessmentService.updateFullyAssessed(courseNode, userCourseEnv, Boolean.TRUE, - status, Role.user); + courseAssessmentService.updateFullyAssessed(courseNode, userCourseEnv, + Boolean.valueOf(result.isFullyAssessed()), status, Role.user); return true; } return false; @@ -109,43 +109,36 @@ public class LearningPathNodeAccessProvider implements NodeAccessProvider { public boolean isAssessmentConfirmationEnabled(CourseNode courseNode, UserCourseEnvironment userCourseEnv) { FullyAssessedResult result = getConfigs(courseNode).isFullyAssessedOnConfirmation(); boolean participant = userCourseEnv.isParticipant(); - boolean confirmationEnabled = participant && result.isFullyAssessed(); + boolean confirmationEnabled = participant && result.isEnabled(); return confirmationEnabled; } @Override public void onAssessmentConfirmed(CourseNode courseNode, UserCourseEnvironment userCourseEnv) { FullyAssessedResult result = getConfigs(courseNode).isFullyAssessedOnConfirmation(); - boolean participant = userCourseEnv.isParticipant(); - if (participant && result.isFullyAssessed()) { - AssessmentEntryStatus status = getStatus(courseNode, userCourseEnv, result.isDone()); - courseAssessmentService.updateFullyAssessed(courseNode, userCourseEnv, Boolean.TRUE, - status, Role.user); - } + updateFullyAssessed(courseNode, userCourseEnv, Role.user, result); } @Override - public void onPassed(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Role by) { - FullyAssessedResult result = getConfigs(courseNode).isFullyAssessedOnPassed(); - boolean participant = userCourseEnv.isParticipant(); - if (participant && result.isFullyAssessed()) { - AssessmentEntryStatus status = getStatus(courseNode, userCourseEnv, result.isDone()); - courseAssessmentService.updateFullyAssessed(courseNode, userCourseEnv, Boolean.TRUE, status, by); - } + public void onPassedUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Boolean passed, Role by) { + FullyAssessedResult result = getConfigs(courseNode).isFullyAssessedOnPassed(passed); + updateFullyAssessed(courseNode, userCourseEnv, by, result); } @Override - public void onCompletionUpdate(CourseNode courseNode, UserCourseEnvironment userCourseEnv, - Double completion, AssessmentEntryStatus status, Role by) { - FullyAssessedResult onCompletion = getConfigs(courseNode).isFullyAssessedOnCompletion(completion); - FullyAssessedResult onRunStatus = getConfigs(courseNode).isFullyAssessedOnStatus(status); - boolean isFullyAssessed = onCompletion.isFullyAssessed() || onRunStatus.isFullyAssessed(); + public void onStatusUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, + AssessmentEntryStatus status, Role by) { + FullyAssessedResult result = getConfigs(courseNode).isFullyAssessedOnStatus(status); + updateFullyAssessed(courseNode, userCourseEnv, by, result); + } + + void updateFullyAssessed(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Role by, + FullyAssessedResult result) { boolean participant = userCourseEnv.isParticipant(); - if (participant && isFullyAssessed) { - boolean isDone = onCompletion.isDone() || onRunStatus.isDone(); - AssessmentEntryStatus newStatus = getStatus(courseNode, userCourseEnv, isDone); - courseAssessmentService.updateFullyAssessed(courseNode, userCourseEnv, Boolean.TRUE, - newStatus, by); + if (participant && result.isEnabled()) { + AssessmentEntryStatus newStatus = getStatus(courseNode, userCourseEnv, result.isDone()); + courseAssessmentService.updateFullyAssessed(courseNode, userCourseEnv, + Boolean.valueOf(result.isFullyAssessed()), newStatus, by); } } @@ -153,7 +146,7 @@ public class LearningPathNodeAccessProvider implements NodeAccessProvider { boolean isDone) { return isDone ? AssessmentEntryStatus.done - :courseAssessmentService.getAssessmentEntry(courseNode, userCourseEnvironment).getAssessmentStatus(); + : courseAssessmentService.getAssessmentEntry(courseNode, userCourseEnvironment).getAssessmentStatus(); } } diff --git a/src/main/java/org/olat/course/learningpath/model/ModuleLearningPathConfigs.java b/src/main/java/org/olat/course/learningpath/model/ModuleLearningPathConfigs.java index 0b1d769673a13cdaa55b2800cc5885078854c15a..0c9c1562b056153a8bb37fbcf33b8fc8ede176b0 100644 --- a/src/main/java/org/olat/course/learningpath/model/ModuleLearningPathConfigs.java +++ b/src/main/java/org/olat/course/learningpath/model/ModuleLearningPathConfigs.java @@ -44,9 +44,11 @@ import org.olat.modules.assessment.model.AssessmentObligation; public class ModuleLearningPathConfigs implements LearningPathConfigs { private final ModuleConfiguration moduleConfiguration; + private final boolean doneOnFullyAssessed; - public ModuleLearningPathConfigs(ModuleConfiguration moduleConfiguration) { + public ModuleLearningPathConfigs(ModuleConfiguration moduleConfiguration, boolean doneOnFullyAssessed) { this.moduleConfiguration = moduleConfiguration; + this.doneOnFullyAssessed = doneOnFullyAssessed; } @Override @@ -81,7 +83,7 @@ public class ModuleLearningPathConfigs implements LearningPathConfigs { public FullyAssessedResult isFullyAssessedOnNodeVisited() { String doneTriggerName = getDoneTriggerName(); if (CONFIG_VALUE_TRIGGER_NODE_VISITED.equals(doneTriggerName)) { - return LearningPathConfigs.fullyAssessed(true, true); + return LearningPathConfigs.fullyAssessed(true, true, doneOnFullyAssessed); } return LearningPathConfigs.notFullyAssessed(); } @@ -90,16 +92,17 @@ public class ModuleLearningPathConfigs implements LearningPathConfigs { public FullyAssessedResult isFullyAssessedOnConfirmation() { String doneTriggerName = getDoneTriggerName(); if (CONFIG_VALUE_TRIGGER_CONFIRMED.equals(doneTriggerName)) { - return LearningPathConfigs.fullyAssessed(true, true); + return LearningPathConfigs.fullyAssessed(true, true, doneOnFullyAssessed); } return LearningPathConfigs.notFullyAssessed(); } @Override - public FullyAssessedResult isFullyAssessedOnPassed() { + public FullyAssessedResult isFullyAssessedOnPassed(Boolean passed) { String doneTriggerName = getDoneTriggerName(); if (CONFIG_VALUE_TRIGGER_PASSED.equals(doneTriggerName)) { - return LearningPathConfigs.fullyAssessed(true, true); + boolean fullyAssessed = Boolean.TRUE.equals(passed); + return LearningPathConfigs.fullyAssessed(true, fullyAssessed, doneOnFullyAssessed); } return LearningPathConfigs.notFullyAssessed(); } @@ -108,17 +111,12 @@ public class ModuleLearningPathConfigs implements LearningPathConfigs { return moduleConfiguration.getStringValue(CONFIG_KEY_TRIGGER, CONFIG_DEFAULT_TRIGGER); } - @Override - public FullyAssessedResult isFullyAssessedOnCompletion(Double completion) { - // not implemented yet - return LearningPathConfigs.notFullyAssessed(); - } - @Override public FullyAssessedResult isFullyAssessedOnStatus(AssessmentEntryStatus status) { String doneTriggerName = getDoneTriggerName(); - if (AssessmentEntryStatus.done.equals(status) && CONFIG_VALUE_TRIGGER_STATUS_DONE.equals(doneTriggerName)) { - return LearningPathConfigs.fullyAssessed(true, false); + if (CONFIG_VALUE_TRIGGER_STATUS_DONE.equals(doneTriggerName)) { + boolean fulylAssessed = AssessmentEntryStatus.done.equals(status); + return LearningPathConfigs.fullyAssessed(true, fulylAssessed, false); } return LearningPathConfigs.notFullyAssessed(); } diff --git a/src/main/java/org/olat/course/learningpath/model/UnsupportedLearningPathConfigs.java b/src/main/java/org/olat/course/learningpath/model/UnsupportedLearningPathConfigs.java index 0e99ad43658222f1b5ef9d2419d438280c839262..9611843403c603d3d31b87282821d215429b8d6f 100644 --- a/src/main/java/org/olat/course/learningpath/model/UnsupportedLearningPathConfigs.java +++ b/src/main/java/org/olat/course/learningpath/model/UnsupportedLearningPathConfigs.java @@ -57,12 +57,7 @@ public class UnsupportedLearningPathConfigs implements LearningPathConfigs { } @Override - public FullyAssessedResult isFullyAssessedOnPassed() { - return LearningPathConfigs.notFullyAssessed(); - } - - @Override - public FullyAssessedResult isFullyAssessedOnCompletion(Double completion) { + public FullyAssessedResult isFullyAssessedOnPassed(Boolean passed) { return LearningPathConfigs.notFullyAssessed(); } diff --git a/src/main/java/org/olat/course/nodeaccess/NodeAccessProvider.java b/src/main/java/org/olat/course/nodeaccess/NodeAccessProvider.java index e919930b6b3095b77d65fbb1abd5c898a2b4bec2..14eb08f05d25f94819f595b5700f6c7fef2c04a7 100644 --- a/src/main/java/org/olat/course/nodeaccess/NodeAccessProvider.java +++ b/src/main/java/org/olat/course/nodeaccess/NodeAccessProvider.java @@ -50,9 +50,9 @@ public interface NodeAccessProvider extends NodeAccessProviderIdentifier { public void onAssessmentConfirmed(CourseNode courseNode, UserCourseEnvironment userCourseEnv); - public void onPassed(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Role by); + public void onPassedUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Boolean passed, Role by); - public void onCompletionUpdate(CourseNode courseNode, UserCourseEnvironment userCourseEnv, - Double completion, AssessmentEntryStatus status, Role by); + public void onStatusUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, + AssessmentEntryStatus status, Role by); } diff --git a/src/main/java/org/olat/course/nodeaccess/NodeAccessService.java b/src/main/java/org/olat/course/nodeaccess/NodeAccessService.java index 60fc86180c33318b16c2c92085d21b89225ac20d..3d2e21423f07d4164e4cd026970f6012812089af 100644 --- a/src/main/java/org/olat/course/nodeaccess/NodeAccessService.java +++ b/src/main/java/org/olat/course/nodeaccess/NodeAccessService.java @@ -90,20 +90,20 @@ public interface NodeAccessService { * * @param courseNode * @param userCourseEnv + * @param passed * @param by */ - public void onPassed(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Role by); + public void onPassedUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Boolean passed, Role by); /** * Hook after the completion and the run status is updated. * * @param courseNode * @param userCourseEnv - * @param completion * @param status * @param by */ - public void onCompletionUpdate(CourseNode courseNode, UserCourseEnvironment userCourseEnv, - Double completion, AssessmentEntryStatus status, Role by); + public void onStatusUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, + AssessmentEntryStatus status, Role by); } diff --git a/src/main/java/org/olat/course/nodeaccess/manager/NodeAccessServiceImpl.java b/src/main/java/org/olat/course/nodeaccess/manager/NodeAccessServiceImpl.java index 20840c09295055f6a85358f1e27a5375ea670def..c5d6e3b9b6a01a33720bfd4eae6f652c4d8abf74 100644 --- a/src/main/java/org/olat/course/nodeaccess/manager/NodeAccessServiceImpl.java +++ b/src/main/java/org/olat/course/nodeaccess/manager/NodeAccessServiceImpl.java @@ -104,16 +104,16 @@ public class NodeAccessServiceImpl implements NodeAccessService, NodeVisitedList } @Override - public void onPassed(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Role by) { + public void onPassedUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, Boolean passed, Role by) { NodeAccessType type = NodeAccessType.of(userCourseEnv); - getNodeAccessProvider(type).onPassed(courseNode, userCourseEnv, by); + getNodeAccessProvider(type).onPassedUpdated(courseNode, userCourseEnv, passed, by); } @Override - public void onCompletionUpdate(CourseNode courseNode, UserCourseEnvironment userCourseEnv, - Double completion, AssessmentEntryStatus status, Role by) { + public void onStatusUpdated(CourseNode courseNode, UserCourseEnvironment userCourseEnv, + AssessmentEntryStatus status, Role by) { NodeAccessType type = NodeAccessType.of(userCourseEnv); - getNodeAccessProvider(type).onCompletionUpdate(courseNode, userCourseEnv, completion, status, by); + getNodeAccessProvider(type).onStatusUpdated(courseNode, userCourseEnv, status, by); } @Override diff --git a/src/main/java/org/olat/course/nodes/ScormCourseNode.java b/src/main/java/org/olat/course/nodes/ScormCourseNode.java index 7f47c159ff18f35844a5dbbebc65171a1a16d24d..5ff52f1b040b545a826da376513ae50aadd14770 100644 --- a/src/main/java/org/olat/course/nodes/ScormCourseNode.java +++ b/src/main/java/org/olat/course/nodes/ScormCourseNode.java @@ -178,7 +178,7 @@ public class ScormCourseNode extends AbstractAccessableCourseNode { boolean hasPassed = new ScormAssessmentConfig(getModuleConfiguration()).hasPassed(); boolean isPassedTrigger = CoreSpringFactory.getImpl(ScormLearningPathNodeHandler.class) .getConfigs(this) - .isFullyAssessedOnPassed() + .isFullyAssessedOnPassed(null) .isFullyAssessed(); return isPassedTrigger && !hasPassed; } diff --git a/src/main/java/org/olat/course/nodes/bc/BCLearningPathNodeHandler.java b/src/main/java/org/olat/course/nodes/bc/BCLearningPathNodeHandler.java index ae23660a87bc2d206fb099bb0a805cc208cb6f98..44bf8978d508fcfcdb808d8417d42532df85ca3d 100644 --- a/src/main/java/org/olat/course/nodes/bc/BCLearningPathNodeHandler.java +++ b/src/main/java/org/olat/course/nodes/bc/BCLearningPathNodeHandler.java @@ -53,7 +53,7 @@ public class BCLearningPathNodeHandler implements LearningPathNodeHandler { @Override public LearningPathConfigs getConfigs(CourseNode courseNode) { - return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration()); + return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration(), true); } @Override diff --git a/src/main/java/org/olat/course/nodes/scorm/ScormLearningPathNodeHandler.java b/src/main/java/org/olat/course/nodes/scorm/ScormLearningPathNodeHandler.java index dba10904fa8ff1539e61db13a10de8b3f1a8af1c..b669fd133ef21526b8ec79ceace93ec79577dd0d 100644 --- a/src/main/java/org/olat/course/nodes/scorm/ScormLearningPathNodeHandler.java +++ b/src/main/java/org/olat/course/nodes/scorm/ScormLearningPathNodeHandler.java @@ -53,7 +53,7 @@ public class ScormLearningPathNodeHandler implements LearningPathNodeHandler { @Override public LearningPathConfigs getConfigs(CourseNode courseNode) { - return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration()); + return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration(), false); } @Override diff --git a/src/main/java/org/olat/course/nodes/sp/SPLearningPathNodeHandler.java b/src/main/java/org/olat/course/nodes/sp/SPLearningPathNodeHandler.java index 6eb98d440799d7e7f323910722655095c339cd29..ca88a5780b4ba70f806bad26187d6970929c3b03 100644 --- a/src/main/java/org/olat/course/nodes/sp/SPLearningPathNodeHandler.java +++ b/src/main/java/org/olat/course/nodes/sp/SPLearningPathNodeHandler.java @@ -53,7 +53,7 @@ public class SPLearningPathNodeHandler implements LearningPathNodeHandler { @Override public LearningPathConfigs getConfigs(CourseNode courseNode) { - return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration()); + return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration(), true); } @Override diff --git a/src/main/java/org/olat/course/nodes/st/assessment/STLearningPathConfigs.java b/src/main/java/org/olat/course/nodes/st/assessment/STLearningPathConfigs.java index 9e3323b905002bd16bc26204c7685480286c9843..d725d8a87a39c19d25892f171f53a8835de62e67 100644 --- a/src/main/java/org/olat/course/nodes/st/assessment/STLearningPathConfigs.java +++ b/src/main/java/org/olat/course/nodes/st/assessment/STLearningPathConfigs.java @@ -57,7 +57,7 @@ public class STLearningPathConfigs implements LearningPathConfigs { } @Override - public FullyAssessedResult isFullyAssessedOnPassed() { + public FullyAssessedResult isFullyAssessedOnPassed(Boolean passed) { return LearningPathConfigs.notFullyAssessed(); } @@ -65,10 +65,4 @@ public class STLearningPathConfigs implements LearningPathConfigs { public FullyAssessedResult isFullyAssessedOnStatus(AssessmentEntryStatus status) { return LearningPathConfigs.notFullyAssessed(); } - - @Override - public FullyAssessedResult isFullyAssessedOnCompletion(Double completion) { - return LearningPathConfigs.notFullyAssessed(); - } - } diff --git a/src/main/java/org/olat/course/nodes/survey/SurveyLearningPathNodeHandler.java b/src/main/java/org/olat/course/nodes/survey/SurveyLearningPathNodeHandler.java index ddf130619358396b46712c895f600fa7651714de..be9a0709bd874857471dab6b95e640fddf03d4a0 100644 --- a/src/main/java/org/olat/course/nodes/survey/SurveyLearningPathNodeHandler.java +++ b/src/main/java/org/olat/course/nodes/survey/SurveyLearningPathNodeHandler.java @@ -56,7 +56,7 @@ public class SurveyLearningPathNodeHandler implements LearningPathNodeHandler { @Override public LearningPathConfigs getConfigs(CourseNode courseNode) { - return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration()); + return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration(), false); } @Override diff --git a/src/main/java/org/olat/course/nodes/video/VideoLearningPathNodeHandler.java b/src/main/java/org/olat/course/nodes/video/VideoLearningPathNodeHandler.java index 5ac5cc722fedbb5631e93c30499925ceb777b8c2..d37f14441fffcfab1c10d6ceadaae4f35f23a734 100644 --- a/src/main/java/org/olat/course/nodes/video/VideoLearningPathNodeHandler.java +++ b/src/main/java/org/olat/course/nodes/video/VideoLearningPathNodeHandler.java @@ -53,7 +53,7 @@ public class VideoLearningPathNodeHandler implements LearningPathNodeHandler { @Override public LearningPathConfigs getConfigs(CourseNode courseNode) { - return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration()); + return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration(), true); } @Override diff --git a/src/test/java/org/olat/course/learningpath/manager/LearningPathNodeAccessProviderTest.java b/src/test/java/org/olat/course/learningpath/manager/LearningPathNodeAccessProviderTest.java index 913e25ff750246b6499267da0735395f9166ab92..e38ce95a5da2e660ff6415a772100cd0cb62c5aa 100644 --- a/src/test/java/org/olat/course/learningpath/manager/LearningPathNodeAccessProviderTest.java +++ b/src/test/java/org/olat/course/learningpath/manager/LearningPathNodeAccessProviderTest.java @@ -20,12 +20,12 @@ package org.olat.course.learningpath.manager; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.olat.course.learningpath.LearningPathConfigs.fullyAssessed; -import static org.olat.course.learningpath.LearningPathConfigs.notFullyAssessed; import org.junit.Before; import org.junit.Test; @@ -34,10 +34,13 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.olat.course.assessment.CourseAssessmentService; import org.olat.course.learningpath.LearningPathConfigs; +import org.olat.course.learningpath.LearningPathConfigs.FullyAssessedResult; import org.olat.course.learningpath.LearningPathNodeHandler; import org.olat.course.nodes.CourseNode; import org.olat.course.run.userview.UserCourseEnvironment; +import org.olat.modules.assessment.AssessmentEntry; import org.olat.modules.assessment.Role; +import org.olat.modules.assessment.model.AssessmentEntryImpl; import org.olat.modules.assessment.model.AssessmentEntryStatus; /** @@ -47,12 +50,12 @@ import org.olat.modules.assessment.model.AssessmentEntryStatus; * */ public class LearningPathNodeAccessProviderTest { - - private static final Double COMPLETION = Double.valueOf(0.5); @Mock private CourseNode courseNodeMock; @Mock + private LearningPathConfigs configMock; + @Mock private LearningPathRegistry registry; @Mock private CourseAssessmentService courseAssessmentService; @@ -72,12 +75,16 @@ public class LearningPathNodeAccessProviderTest { coachCourseEnv = mock(UserCourseEnvironment.class); when(coachCourseEnv.isCoach()).thenReturn(Boolean.TRUE); + + LearningPathNodeHandler handlerMock = mock(LearningPathNodeHandler.class); + when(handlerMock.getConfigs(courseNodeMock)).thenReturn(configMock); + when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handlerMock); } @Test - public void shouldSetAssessmentAsDoneIfNodeVisited() { + public void shouldSetFullyAssessedIfNodeVisited() { LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnNodeVisited()).thenReturn(fullyAssessed(true, true)); + when(configs.isFullyAssessedOnNodeVisited()).thenReturn(fullyAssessed(true, true, true)); LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); when(handler.getConfigs(courseNodeMock)).thenReturn(configs); when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); @@ -89,9 +96,9 @@ public class LearningPathNodeAccessProviderTest { } @Test - public void shouldSetAssessmentAsDoneIfNodeVisitedNotEnabled() { + public void shouldNotSetFullyAssessedIfNodeVisitedNotEnabled() { LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnNodeVisited()).thenReturn(notFullyAssessed()); + when(configs.isFullyAssessedOnNodeVisited()).thenReturn(fullyAssessed(false, true, true)); LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); when(handler.getConfigs(courseNodeMock)).thenReturn(configs); when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); @@ -103,9 +110,9 @@ public class LearningPathNodeAccessProviderTest { } @Test - public void shouldNotChangeAssessmentIfNotAParticipantVisitedTheNode() { + public void shouldNotSetFullyAssessedIfNotAParticipantVisitedTheNode() { LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnNodeVisited()).thenReturn(fullyAssessed(true, true)); + when(configs.isFullyAssessedOnNodeVisited()).thenReturn(fullyAssessed(true, true, true)); LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); when(handler.getConfigs(courseNodeMock)).thenReturn(configs); when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); @@ -119,7 +126,7 @@ public class LearningPathNodeAccessProviderTest { @Test public void shouldReturnConfirmEnabled() { LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnConfirmation()).thenReturn(fullyAssessed(true, true)); + when(configs.isFullyAssessedOnConfirmation()).thenReturn(fullyAssessed(true, true, true)); LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); when(handler.getConfigs(courseNodeMock)).thenReturn(configs); when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); @@ -132,7 +139,7 @@ public class LearningPathNodeAccessProviderTest { @Test public void shouldNotReturnConfirmEnabledNotEnabledInConfiguration() { LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnConfirmation()).thenReturn(notFullyAssessed()); + when(configs.isFullyAssessedOnConfirmation()).thenReturn(fullyAssessed(false, true, true)); LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); when(handler.getConfigs(courseNodeMock)).thenReturn(configs); when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); @@ -145,7 +152,7 @@ public class LearningPathNodeAccessProviderTest { @Test public void shouldNotReturnConfirmEnabledNotAParticipant() { LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnConfirmation()).thenReturn(fullyAssessed(true, true)); + when(configs.isFullyAssessedOnConfirmation()).thenReturn(fullyAssessed(true, true, true)); LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); when(handler.getConfigs(courseNodeMock)).thenReturn(configs); when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); @@ -156,183 +163,87 @@ public class LearningPathNodeAccessProviderTest { } @Test - public void shouldSetAssessmentAsDoneIfConfirmed() { - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnConfirmation()).thenReturn(fullyAssessed(true, true)); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onAssessmentConfirmed(courseNodeMock, participantCourseEnv); - - verify(courseAssessmentService).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, Role.user); - } - - @Test - public void shouldSetAssessmentAsDoneIfConfirmationNotEnabled() { - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnConfirmation()).thenReturn(notFullyAssessed()); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onAssessmentConfirmed(courseNodeMock, participantCourseEnv); + public void shouldNotSetFullyAssessedIfNotEnabled() { + FullyAssessedResult result = fullyAssessed(false, true, true); + + sut.updateFullyAssessed(courseNodeMock, participantCourseEnv, Role.auto, result); verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, Role.user); + AssessmentEntryStatus.done, Role.auto); } @Test - public void shouldNotChangeAssessmentIfNotAParticipantConfirmed() { - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnConfirmation()).thenReturn(fullyAssessed(true, true)); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onAssessmentConfirmed(courseNodeMock, coachCourseEnv); + public void shouldNotSetFullyAssessedIfNotParticipant() { + FullyAssessedResult result = fullyAssessed(false, true, true); + + sut.updateFullyAssessed(courseNodeMock, participantCourseEnv, Role.auto, result); - verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, Role.user); + verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, coachCourseEnv, Boolean.TRUE, + AssessmentEntryStatus.done, Role.auto); } @Test - public void shouldSetAssessmentAsDoneIfPassed() { - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnPassed()).thenReturn(fullyAssessed(true, true)); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onPassed(courseNodeMock, participantCourseEnv, Role.user); + public void shouldSetFullyAssessedToTrue() { + FullyAssessedResult result = fullyAssessed(true, true, true); + + sut.updateFullyAssessed(courseNodeMock, participantCourseEnv, Role.auto, result); verify(courseAssessmentService).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, Role.user); + AssessmentEntryStatus.done, Role.auto); } - @Test - public void shouldSetAssessmentAsDoneIfPassedNotEnabled() { - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnPassed()).thenReturn(notFullyAssessed()); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onPassed(courseNodeMock, participantCourseEnv, Role.user); - - verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, Role.user); - } - - @Test - public void shouldNotChangeAssessmentIfNotAParticipantPassed() { - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnPassed()).thenReturn(fullyAssessed(true, true)); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onPassed(courseNodeMock, coachCourseEnv, Role.user); + public void shouldSetFullyAssessedToFalse() { + FullyAssessedResult result = fullyAssessed(true, false, true); + + sut.updateFullyAssessed(courseNodeMock, participantCourseEnv, Role.auto, result); - verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, Role.user); + verify(courseAssessmentService).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.FALSE, + AssessmentEntryStatus.done, Role.auto); } @Test - public void shouldSetAssessmentAsDoneIfRunStatusIsReached() { - Role role = Role.auto; - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnStatus(AssessmentEntryStatus.done)).thenReturn(fullyAssessed(true, true)); - when(configs.isFullyAssessedOnCompletion(COMPLETION)).thenReturn(LearningPathConfigs.notFullyAssessed()); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onCompletionUpdate(courseNodeMock, participantCourseEnv, COMPLETION, AssessmentEntryStatus.done, role); + public void shouldSetStatusDone() { + FullyAssessedResult result = fullyAssessed(true, true, true); + + sut.updateFullyAssessed(courseNodeMock, participantCourseEnv, Role.auto, result); verify(courseAssessmentService).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, role); + AssessmentEntryStatus.done, Role.auto); } @Test - public void shouldNotChangeAssessmentStatusIfRunStatusIsNotReached() { - Role role = Role.auto; - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnStatus(AssessmentEntryStatus.done)).thenReturn(LearningPathConfigs.notFullyAssessed()); - when(configs.isFullyAssessedOnCompletion(COMPLETION)).thenReturn(LearningPathConfigs.notFullyAssessed()); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onCompletionUpdate(courseNodeMock, participantCourseEnv, COMPLETION, AssessmentEntryStatus.done, role); - - verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, role); - } - - @Test - public void shouldNotChangeAssessmentStatusIfItIsNotAParticipant() { - Role role = Role.auto; - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnStatus(AssessmentEntryStatus.done)).thenReturn(fullyAssessed(true, true)); - when(configs.isFullyAssessedOnCompletion(COMPLETION)).thenReturn(LearningPathConfigs.notFullyAssessed()); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onCompletionUpdate(courseNodeMock, coachCourseEnv, COMPLETION, AssessmentEntryStatus.done, role); + public void shouldNotSetStatusDone() { + AssessmentEntry assessmentEntry = new AssessmentEntryImpl(); + assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inReview); + when(courseAssessmentService.getAssessmentEntry(courseNodeMock, participantCourseEnv)) + .thenReturn(assessmentEntry); + FullyAssessedResult result = fullyAssessed(true, true, false); + + sut.updateFullyAssessed(courseNodeMock, participantCourseEnv, Role.auto, result); - verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, role); + verify(courseAssessmentService).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, + AssessmentEntryStatus.inReview, Role.auto); } @Test - public void shouldSetAssessmentAsDoneIfCompletionIsReached() { - Role role = Role.auto; - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnStatus(AssessmentEntryStatus.done)).thenReturn(LearningPathConfigs.notFullyAssessed()); - when(configs.isFullyAssessedOnCompletion(COMPLETION)).thenReturn(fullyAssessed(true, true)); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onCompletionUpdate(courseNodeMock, participantCourseEnv, COMPLETION, null, role); + public void shouldInvokeConformedConfig() { + sut.onAssessmentConfirmed(courseNodeMock, coachCourseEnv); - verify(courseAssessmentService).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, role); + verify(configMock).isFullyAssessedOnConfirmation(); } @Test - public void shouldNotChangeAssessmentStatusIfCompletionNotIsReached() { - Role role = Role.auto; - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnStatus(AssessmentEntryStatus.done)).thenReturn(LearningPathConfigs.notFullyAssessed()); - when(configs.isFullyAssessedOnCompletion(COMPLETION)).thenReturn(LearningPathConfigs.notFullyAssessed()); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onCompletionUpdate(courseNodeMock, participantCourseEnv, COMPLETION, AssessmentEntryStatus.done, role); + public void shouldInvokePassedConfig() { + sut.onPassedUpdated(courseNodeMock, coachCourseEnv, null, null); - verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, role); + verify(configMock).isFullyAssessedOnPassed(any()); } @Test - public void shouldSetAssessmentAsDoneIfItIsNotAParticipant() { - Role role = Role.auto; - LearningPathConfigs configs = mock(LearningPathConfigs.class); - when(configs.isFullyAssessedOnStatus(AssessmentEntryStatus.done)).thenReturn(LearningPathConfigs.notFullyAssessed()); - when(configs.isFullyAssessedOnCompletion(COMPLETION)).thenReturn(fullyAssessed(true, true)); - LearningPathNodeHandler handler = mock(LearningPathNodeHandler.class); - when(handler.getConfigs(courseNodeMock)).thenReturn(configs); - when(registry.getLearningPathNodeHandler(courseNodeMock)).thenReturn(handler); - - sut.onCompletionUpdate(courseNodeMock, coachCourseEnv, COMPLETION, AssessmentEntryStatus.done, role); + public void onStatusUpdated() { + sut.onStatusUpdated(courseNodeMock, coachCourseEnv, null, null); - verify(courseAssessmentService, never()).updateFullyAssessed(courseNodeMock, participantCourseEnv, Boolean.TRUE, - AssessmentEntryStatus.done, role); + verify(configMock).isFullyAssessedOnStatus(any()); } }