From 8560546f4b035323000ebd10b7805d2383a625c6 Mon Sep 17 00:00:00 2001
From: uhensler <urs.hensler@frentix.com>
Date: Tue, 10 Dec 2019 16:50:59 +0100
Subject: [PATCH] OO-4241: Prepare feed course elements for usage in learning
 path

---
 .../course/nodes/AbstractFeedCourseNode.java  |  2 +-
 .../feed/FeedLearningPathNodeHandler.java     | 69 +++++++++++++++++++
 .../feed/blog/BlogAssessmentHandler.java      | 40 +++++++++++
 .../blog/BlogLearningPathNodeHandler.java     | 40 +++++++++++
 .../podcast/PodcastAssessmentHandler.java     | 40 +++++++++++
 .../PodcastLearningPathNodeHandler.java       | 40 +++++++++++
 6 files changed, 230 insertions(+), 1 deletion(-)
 create mode 100644 src/main/java/org/olat/course/nodes/feed/FeedLearningPathNodeHandler.java
 create mode 100644 src/main/java/org/olat/course/nodes/feed/blog/BlogAssessmentHandler.java
 create mode 100644 src/main/java/org/olat/course/nodes/feed/blog/BlogLearningPathNodeHandler.java
 create mode 100644 src/main/java/org/olat/course/nodes/feed/podcast/PodcastAssessmentHandler.java
 create mode 100644 src/main/java/org/olat/course/nodes/feed/podcast/PodcastLearningPathNodeHandler.java

diff --git a/src/main/java/org/olat/course/nodes/AbstractFeedCourseNode.java b/src/main/java/org/olat/course/nodes/AbstractFeedCourseNode.java
index bea89875095..76578cbe786 100644
--- a/src/main/java/org/olat/course/nodes/AbstractFeedCourseNode.java
+++ b/src/main/java/org/olat/course/nodes/AbstractFeedCourseNode.java
@@ -252,7 +252,7 @@ public abstract class AbstractFeedCourseNode extends AbstractAccessableCourseNod
 		}
 	}
 
-	private void removeCustomPreconditions() {
+	public void removeCustomPreconditions() {
 		preConditionModerator = null;
 		preConditionPoster = null;
 		preConditionReader = null;
diff --git a/src/main/java/org/olat/course/nodes/feed/FeedLearningPathNodeHandler.java b/src/main/java/org/olat/course/nodes/feed/FeedLearningPathNodeHandler.java
new file mode 100644
index 00000000000..f848d324ce8
--- /dev/null
+++ b/src/main/java/org/olat/course/nodes/feed/FeedLearningPathNodeHandler.java
@@ -0,0 +1,69 @@
+/**
+ * <a href="http://www.openolat.org">
+ * OpenOLAT - Online Learning and Training</a><br>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); <br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at the
+ * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
+ * <p>
+ * Unless required by applicable law or agreed to in writing,<br>
+ * software distributed under the License is distributed on an "AS IS" BASIS, <br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
+ * See the License for the specific language governing permissions and <br>
+ * limitations under the License.
+ * <p>
+ * Initial code contributed and copyrighted by<br>
+ * frentix GmbH, http://www.frentix.com
+ * <p>
+ */
+package org.olat.course.nodes.feed;
+
+import org.olat.core.gui.UserRequest;
+import org.olat.core.gui.control.Controller;
+import org.olat.core.gui.control.WindowControl;
+import org.olat.course.learningpath.LearningPathConfigs;
+import org.olat.course.learningpath.LearningPathNodeHandler;
+import org.olat.course.learningpath.model.ModuleLearningPathConfigs;
+import org.olat.course.learningpath.ui.LearningPathNodeConfigController;
+import org.olat.course.learningpath.ui.LearningPathNodeConfigController.LearningPathControllerConfig;
+import org.olat.course.nodes.AbstractFeedCourseNode;
+import org.olat.course.nodes.CourseNode;
+import org.olat.repository.RepositoryEntry;
+
+/**
+ * 
+ * Initial date: 10 Dec 2019<br>
+ * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
+ *
+ */
+public abstract class FeedLearningPathNodeHandler implements LearningPathNodeHandler {
+
+	@Override
+	public boolean isSupported() {
+		return true;
+	}
+
+	@Override
+	public LearningPathConfigs getConfigs(CourseNode courseNode) {
+		return new ModuleLearningPathConfigs(courseNode.getModuleConfiguration(), true);
+	}
+
+	@Override
+	public Controller createConfigEditController(UserRequest ureq, WindowControl wControl, RepositoryEntry courseEntry, CourseNode courseNode) {
+		LearningPathControllerConfig ctrlConfig = LearningPathNodeConfigController.builder()
+				.enableNodeVisited()
+				.enableConfirmed()
+				.build();
+		return new LearningPathNodeConfigController(ureq, wControl, courseEntry, courseNode.getModuleConfiguration(), ctrlConfig);
+	}
+
+	@Override
+	public void onMigrated(CourseNode courseNode) {
+		if (courseNode instanceof AbstractFeedCourseNode) {
+			AbstractFeedCourseNode feedNode = (AbstractFeedCourseNode)courseNode;
+			feedNode.removeCustomPreconditions();
+		}
+	}
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/olat/course/nodes/feed/blog/BlogAssessmentHandler.java b/src/main/java/org/olat/course/nodes/feed/blog/BlogAssessmentHandler.java
new file mode 100644
index 00000000000..8ee877b2ceb
--- /dev/null
+++ b/src/main/java/org/olat/course/nodes/feed/blog/BlogAssessmentHandler.java
@@ -0,0 +1,40 @@
+/**
+ * <a href="http://www.openolat.org">
+ * OpenOLAT - Online Learning and Training</a><br>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); <br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at the
+ * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
+ * <p>
+ * Unless required by applicable law or agreed to in writing,<br>
+ * software distributed under the License is distributed on an "AS IS" BASIS, <br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
+ * See the License for the specific language governing permissions and <br>
+ * limitations under the License.
+ * <p>
+ * Initial code contributed and copyrighted by<br>
+ * frentix GmbH, http://www.frentix.com
+ * <p>
+ */
+package org.olat.course.nodes.feed.blog;
+
+import org.olat.course.learningpath.LearningPathOnlyAssessmentHandler;
+import org.olat.course.nodes.BlogCourseNode;
+import org.springframework.stereotype.Service;
+
+/**
+ * 
+ * Initial date: 10 Dez 2019<br>
+ * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
+ *
+ */
+@Service
+public class BlogAssessmentHandler extends LearningPathOnlyAssessmentHandler {
+
+	@Override
+	public String acceptCourseNodeType() {
+		return BlogCourseNode.TYPE;
+	}
+
+}
diff --git a/src/main/java/org/olat/course/nodes/feed/blog/BlogLearningPathNodeHandler.java b/src/main/java/org/olat/course/nodes/feed/blog/BlogLearningPathNodeHandler.java
new file mode 100644
index 00000000000..c2909647f92
--- /dev/null
+++ b/src/main/java/org/olat/course/nodes/feed/blog/BlogLearningPathNodeHandler.java
@@ -0,0 +1,40 @@
+/**
+ * <a href="http://www.openolat.org">
+ * OpenOLAT - Online Learning and Training</a><br>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); <br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at the
+ * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
+ * <p>
+ * Unless required by applicable law or agreed to in writing,<br>
+ * software distributed under the License is distributed on an "AS IS" BASIS, <br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
+ * See the License for the specific language governing permissions and <br>
+ * limitations under the License.
+ * <p>
+ * Initial code contributed and copyrighted by<br>
+ * frentix GmbH, http://www.frentix.com
+ * <p>
+ */
+package org.olat.course.nodes.feed.blog;
+
+import org.olat.course.nodes.BlogCourseNode;
+import org.olat.course.nodes.feed.FeedLearningPathNodeHandler;
+import org.springframework.stereotype.Service;
+
+/**
+ * 
+ * Initial date: 10 Dez 2019<br>
+ * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
+ *
+ */
+@Service
+public class BlogLearningPathNodeHandler extends FeedLearningPathNodeHandler {
+
+	@Override
+	public String acceptCourseNodeType() {
+		return BlogCourseNode.TYPE;
+	}
+
+}
diff --git a/src/main/java/org/olat/course/nodes/feed/podcast/PodcastAssessmentHandler.java b/src/main/java/org/olat/course/nodes/feed/podcast/PodcastAssessmentHandler.java
new file mode 100644
index 00000000000..17cb6a8b4df
--- /dev/null
+++ b/src/main/java/org/olat/course/nodes/feed/podcast/PodcastAssessmentHandler.java
@@ -0,0 +1,40 @@
+/**
+ * <a href="http://www.openolat.org">
+ * OpenOLAT - Online Learning and Training</a><br>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); <br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at the
+ * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
+ * <p>
+ * Unless required by applicable law or agreed to in writing,<br>
+ * software distributed under the License is distributed on an "AS IS" BASIS, <br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
+ * See the License for the specific language governing permissions and <br>
+ * limitations under the License.
+ * <p>
+ * Initial code contributed and copyrighted by<br>
+ * frentix GmbH, http://www.frentix.com
+ * <p>
+ */
+package org.olat.course.nodes.feed.podcast;
+
+import org.olat.course.learningpath.LearningPathOnlyAssessmentHandler;
+import org.olat.course.nodes.PodcastCourseNode;
+import org.springframework.stereotype.Service;
+
+/**
+ * 
+ * Initial date: 10 Dez 2019<br>
+ * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
+ *
+ */
+@Service
+public class PodcastAssessmentHandler extends LearningPathOnlyAssessmentHandler {
+
+	@Override
+	public String acceptCourseNodeType() {
+		return PodcastCourseNode.TYPE;
+	}
+
+}
diff --git a/src/main/java/org/olat/course/nodes/feed/podcast/PodcastLearningPathNodeHandler.java b/src/main/java/org/olat/course/nodes/feed/podcast/PodcastLearningPathNodeHandler.java
new file mode 100644
index 00000000000..9bc10d582fd
--- /dev/null
+++ b/src/main/java/org/olat/course/nodes/feed/podcast/PodcastLearningPathNodeHandler.java
@@ -0,0 +1,40 @@
+/**
+ * <a href="http://www.openolat.org">
+ * OpenOLAT - Online Learning and Training</a><br>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); <br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at the
+ * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
+ * <p>
+ * Unless required by applicable law or agreed to in writing,<br>
+ * software distributed under the License is distributed on an "AS IS" BASIS, <br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
+ * See the License for the specific language governing permissions and <br>
+ * limitations under the License.
+ * <p>
+ * Initial code contributed and copyrighted by<br>
+ * frentix GmbH, http://www.frentix.com
+ * <p>
+ */
+package org.olat.course.nodes.feed.podcast;
+
+import org.olat.course.nodes.PodcastCourseNode;
+import org.olat.course.nodes.feed.FeedLearningPathNodeHandler;
+import org.springframework.stereotype.Service;
+
+/**
+ * 
+ * Initial date: 10 Dez 2019<br>
+ * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
+ *
+ */
+@Service
+public class PodcastLearningPathNodeHandler extends FeedLearningPathNodeHandler {
+
+	@Override
+	public String acceptCourseNodeType() {
+		return PodcastCourseNode.TYPE;
+	}
+
+}
-- 
GitLab