diff --git a/src/main/java/org/olat/course/condition/ConditionNodeAccessProvider.java b/src/main/java/org/olat/course/condition/ConditionNodeAccessProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..0fe0c2acfc9f8bd007cbbfc2dbe6b8d469365921 --- /dev/null +++ b/src/main/java/org/olat/course/condition/ConditionNodeAccessProvider.java @@ -0,0 +1,51 @@ +/** + * <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.condition; + +import java.util.Locale; + +import org.olat.core.gui.translator.Translator; +import org.olat.core.util.Util; +import org.olat.course.nodeaccess.NodeAccessProvider; +import org.springframework.stereotype.Service; + +/** + * + * Initial date: 27 Aug 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +@Service +public class ConditionNodeAccessProvider implements NodeAccessProvider { + + public static String TYPE = "condition"; + + @Override + public String getType() { + return TYPE; + } + + @Override + public String getDisplayName(Locale locale) { + Translator translator = Util.createPackageTranslator(ConditionNodeAccessProvider.class, locale); + return translator.translate("access.provider.name"); + } + +} diff --git a/src/main/java/org/olat/course/condition/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/condition/_i18n/LocalStrings_de.properties index c8d9b6f89024660a069034250fffa6be9ed1c260..060206f211407cfcbf42ab8f22d0d4a0c19b4ad6 100644 --- a/src/main/java/org/olat/course/condition/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/course/condition/_i18n/LocalStrings_de.properties @@ -1,4 +1,5 @@ #Mon Mar 02 09:54:04 CET 2009 +access.provider.name=Herk\u00F6mmlicher Kurs apply=\u00DCbernehmen choose=Ausw\u00E4hlen command.activate.easyMode=Einfachen Modus anzeigen @@ -15,9 +16,7 @@ error.argtype.date=Die Zeitangabe f\u00FCr die "{0}"-Funktion muss wie folgt def error.argtype.institutionalname=Die "{0}"-Funktion muss mit einem Institutsnamen aufgerufen werden. error.argtype.username=Die "{0}"-Funktion muss mit einem Benutzernamen aufgerufen werden. error.fewerargs=Die "{0}"-Funktion hat weniger Argumente. -##<OLATCE-1088> -error.argtype.outcome.undefined=Die angeforderte Ergebnisvariable existiert im ausgew\u00e4hlten Test nicht! -##</OLATCE-1088> +error.argtype.outcome.undefined=Die angeforderte Ergebnisvariable existiert im ausgew\u00E4hlten Test nicht! error.divide.by.zero=Die Regel kann zu ein "Division durch 0" Fehler f\u00FChren. error.fix=Erstellen error.illegal.operation.at=Die Operation bei Zeichen {0} ist nicht erlaubt, konsultieren Sie die Hilfe f\u00FCr m\u00F6gliche Operationen. diff --git a/src/main/java/org/olat/course/condition/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/condition/_i18n/LocalStrings_en.properties index 89cdef79bbc773f0193eb9a950da7e3827844ed8..ec5fbe43a622b74c454ee7a94e3f4fc2d8cae58f 100644 --- a/src/main/java/org/olat/course/condition/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/course/condition/_i18n/LocalStrings_en.properties @@ -1,4 +1,5 @@ #Sun Jan 23 12:24:05 CET 2011 +access.provider.name=Conventional course apply=Apply choose=Select command.activate.easyMode=Display simple mode @@ -15,9 +16,7 @@ error.argtype.date=The "{0}" function has to indicate a point in time defined li error.argtype.institutionalname=The "{0}" function must contain an institutional name error.argtype.username=The "{0}" function must contain a user name. error.fewerargs=The "{0}" function has fewer arguments than specified. -##<OLATCE-1088> error.argtype.outcome.undefined=The requested outcome-variable does not exist in the given test! -##</OLATCE-1088> error.divide.by.zero=The rule can produce "divided by 0" errors. error.fix=Create error.illegal.operation.at=The operation at position {0} is not allowed, see Help for possible operations. diff --git a/src/main/java/org/olat/course/config/CourseConfig.java b/src/main/java/org/olat/course/config/CourseConfig.java index 9e059823e5a7735e2af11307d92e731de907ffba..d2fd125ca3a2982541f4add5dff59db7c6d7b0a4 100644 --- a/src/main/java/org/olat/course/config/CourseConfig.java +++ b/src/main/java/org/olat/course/config/CourseConfig.java @@ -31,6 +31,7 @@ import java.util.Map; import org.olat.core.util.StringHelper; import org.olat.course.certificate.RecertificationTimeUnit; +import org.olat.course.condition.ConditionNodeAccessProvider; /** * Description: <br> @@ -72,11 +73,14 @@ public class CourseConfig implements Serializable, Cloneable { /** * current config file version */ - private static final transient int CURRENTVERSION = 15; + private static final transient int CURRENTVERSION = 16; public static final transient String KEY_LOGLEVEL_ADMIN = "LOGLEVELADMIN"; public static final transient String KEY_LOGLEVEL_USER = "LOGLEVELUSER"; public static final transient String KEY_LOGLEVEL_STATISTIC = "LOGLEVELSTAT"; + + public static final transient String NODE_ACCESS_TYPE = "NODE_ACCESS_TYPE"; + public static final transient String NODE_ACCESS_TYPE_DEFAULT = ConditionNodeAccessProvider.TYPE; public static final transient String KEY_EFFICENCY_ENABLED = "KEY_EFFICENCY_ENABLED"; public static final transient String CERTIFICATE_AUTO_ENABLED = "CERTIFICATE_AUTO"; @@ -164,6 +168,8 @@ public class CourseConfig implements Serializable, Cloneable { configuration.put(PARTICIPANT_LIST_ENABLED, Boolean.FALSE); configuration.put(PARTICIPANT_INFO_ENABLED, Boolean.FALSE); configuration.put(EMAIL_ENABLED, Boolean.FALSE); + + configuration.put(NODE_ACCESS_TYPE, NODE_ACCESS_TYPE_DEFAULT); this.version = CURRENTVERSION; } @@ -264,6 +270,12 @@ public class CourseConfig implements Serializable, Cloneable { this.version = 15; } + + if (version == 15) { + if (!configuration.containsKey(NODE_ACCESS_TYPE)) configuration.put(NODE_ACCESS_TYPE, NODE_ACCESS_TYPE_DEFAULT); + + this.version = 16; + } /* @@ -294,6 +306,14 @@ public class CourseConfig implements Serializable, Cloneable { } return versionChanged; } + + public void setNodeAccessType(String nodeAccessType) { + configuration.put(NODE_ACCESS_TYPE, nodeAccessType); + } + + public String getNodeAccessType() { + return (String) configuration.get(NODE_ACCESS_TYPE); + } public boolean isChatEnabled() { Boolean bool = (Boolean) configuration.get(KEY_CHAT_ENABLED); diff --git a/src/main/java/org/olat/course/learningpath/LearningPathNodeAccessProvider.java b/src/main/java/org/olat/course/learningpath/LearningPathNodeAccessProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..4f3bae40b136832e95de4ffb621ca0d416889702 --- /dev/null +++ b/src/main/java/org/olat/course/learningpath/LearningPathNodeAccessProvider.java @@ -0,0 +1,50 @@ +/** + * <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.learningpath; + +import java.util.Locale; + +import org.olat.core.gui.translator.Translator; +import org.olat.core.util.Util; +import org.olat.course.learningpath.ui.LeaningPathNodeConfigController; +import org.olat.course.nodeaccess.NodeAccessProvider; +import org.springframework.stereotype.Service; + +/** + * + * Initial date: 27 Aug 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +@Service +public class LearningPathNodeAccessProvider implements NodeAccessProvider { + + @Override + public String getType() { + return "learningpath"; + } + + @Override + public String getDisplayName(Locale locale) { + Translator translator = Util.createPackageTranslator(LeaningPathNodeConfigController.class, locale); + return translator.translate("access.provider.name"); + } + +} diff --git a/src/main/java/org/olat/course/learningpath/ui/LeaningPathNodeConfigController.java b/src/main/java/org/olat/course/learningpath/ui/LeaningPathNodeConfigController.java new file mode 100644 index 0000000000000000000000000000000000000000..556b4f26a4e8bac0ffb83ff89737dfe29f512e41 --- /dev/null +++ b/src/main/java/org/olat/course/learningpath/ui/LeaningPathNodeConfigController.java @@ -0,0 +1,30 @@ +/** + * <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.learningpath.ui; + +/** + * + * Initial date: 27 Aug 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public class LeaningPathNodeConfigController { + +} diff --git a/src/main/java/org/olat/course/learningpath/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/learningpath/ui/_i18n/LocalStrings_de.properties new file mode 100644 index 0000000000000000000000000000000000000000..71f4b0ce27b172fef7518399dc6044532be1a421 --- /dev/null +++ b/src/main/java/org/olat/course/learningpath/ui/_i18n/LocalStrings_de.properties @@ -0,0 +1 @@ +access.provider.name=Lernpfad \ No newline at end of file diff --git a/src/main/java/org/olat/course/learningpath/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/learningpath/ui/_i18n/LocalStrings_en.properties new file mode 100644 index 0000000000000000000000000000000000000000..69e8fe2cc65b09b6a74b1722d37be58e7fdebe33 --- /dev/null +++ b/src/main/java/org/olat/course/learningpath/ui/_i18n/LocalStrings_en.properties @@ -0,0 +1 @@ +access.provider.name=Learning path \ No newline at end of file diff --git a/src/main/java/org/olat/course/nodeaccess/NodeAccessProvider.java b/src/main/java/org/olat/course/nodeaccess/NodeAccessProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..e93c1c0d945135e5424b2623331c8dad4e39b809 --- /dev/null +++ b/src/main/java/org/olat/course/nodeaccess/NodeAccessProvider.java @@ -0,0 +1,30 @@ +/** + * <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.nodeaccess; + +/** + * + * Initial date: 27 Aug 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public interface NodeAccessProvider extends NodeAccessProviderIdentifier { + +} diff --git a/src/main/java/org/olat/course/nodeaccess/NodeAccessProviderIdentifier.java b/src/main/java/org/olat/course/nodeaccess/NodeAccessProviderIdentifier.java new file mode 100644 index 0000000000000000000000000000000000000000..0795049a71bc401cf2d0a29c462f75ed1c0cf3d3 --- /dev/null +++ b/src/main/java/org/olat/course/nodeaccess/NodeAccessProviderIdentifier.java @@ -0,0 +1,36 @@ +/** + * <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.nodeaccess; + +import java.util.Locale; + +/** + * + * Initial date: 27 Aug 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public interface NodeAccessProviderIdentifier { + + public String getType(); + + public String getDisplayName(Locale locale); + +} diff --git a/src/main/java/org/olat/course/nodeaccess/NodeAccessService.java b/src/main/java/org/olat/course/nodeaccess/NodeAccessService.java new file mode 100644 index 0000000000000000000000000000000000000000..361c589a9de7ed134646cabe0f5e5410d5768da6 --- /dev/null +++ b/src/main/java/org/olat/course/nodeaccess/NodeAccessService.java @@ -0,0 +1,34 @@ +/** + * <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.nodeaccess; + +import java.util.List; + +/** + * + * Initial date: 27 Aug 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public interface NodeAccessService { + + public List<? extends NodeAccessProviderIdentifier> getNodeAccessProviderIdentifer(); + +} diff --git a/src/main/java/org/olat/course/nodeaccess/manager/NodeAccessServiceImpl.java b/src/main/java/org/olat/course/nodeaccess/manager/NodeAccessServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..2392b705885c9d0b726fa33eca14e623886b407e --- /dev/null +++ b/src/main/java/org/olat/course/nodeaccess/manager/NodeAccessServiceImpl.java @@ -0,0 +1,47 @@ +/** + * <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.nodeaccess.manager; + +import java.util.List; + +import org.olat.course.nodeaccess.NodeAccessProvider; +import org.olat.course.nodeaccess.NodeAccessProviderIdentifier; +import org.olat.course.nodeaccess.NodeAccessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * + * Initial date: 27 Aug 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +@Service +public class NodeAccessServiceImpl implements NodeAccessService { + + @Autowired + private List<NodeAccessProvider> nodeAccessProviders; + + @Override + public List<? extends NodeAccessProviderIdentifier> getNodeAccessProviderIdentifer() { + return nodeAccessProviders; + } + +} diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties index 44a8e4f67681a2ebd654d1eaaff325ff98c28b7f..44e23e42c913ce6f34040562371ebdbcba5a39b4 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties @@ -148,6 +148,7 @@ cif.license.elements=Details Element-Lizenzen cif.license.elements.content=Die Ressource enth\u00E4lt Elemente mit den folgenden Lizenzen: {0} Stellen Sie sicher, dass Sie f\u00FCr den {1} eine Lizenz ausw\u00E4hlen, die mindestens so restriktiv ist wie die Lizenzen der enthaltenen Elemente. cif.licensor=Lizenzgeber cif.location=Durchf\u00FChrungsort +cif.node.access=Zugriff Kursbausteine cif.mainLanguage=Hauptsprache cif.managedflags=Extern verwaltete Module cif.membership.mandatory=Meine Kurse diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties index 0b5f07b2f0d68ec46afa78d2c3a2b87de9592f78..226a2a1c90a987a9ed4167a64c8122b3b3315e7f 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties @@ -151,6 +151,7 @@ cif.location=Location cif.mainLanguage=Main language cif.managedflags=Externally managed modules cif.membership.mandatory=My courses only +cif.node.access=Access course elements cif.objectives=Objectives cif.ores_id=OpenOlat resource ID cif.organisations=Organisations diff --git a/src/main/java/org/olat/repository/handlers/CourseHandler.java b/src/main/java/org/olat/repository/handlers/CourseHandler.java index 4deba24665c3d081c69513d7f4e9eda60836d8e0..d7a88eb674d6154e1505d713a285f13ae4b1aad2 100644 --- a/src/main/java/org/olat/repository/handlers/CourseHandler.java +++ b/src/main/java/org/olat/repository/handlers/CourseHandler.java @@ -110,6 +110,8 @@ import org.olat.repository.RepositoryEntryStatusEnum; import org.olat.repository.RepositoryManager; import org.olat.repository.RepositoryService; import org.olat.repository.model.RepositoryEntrySecurity; +import org.olat.repository.ui.author.CreateCourseRepositoryEntryController; +import org.olat.repository.ui.author.CreateEntryController; import org.olat.resource.OLATResource; import org.olat.resource.OLATResourceManager; import org.olat.resource.references.ReferenceManager; @@ -139,6 +141,11 @@ public class CourseHandler implements RepositoryHandler { return true; } + @Override + public CreateEntryController createCreateRepositoryEntryController(UserRequest ureq, WindowControl wControl) { + return new CreateCourseRepositoryEntryController(ureq, wControl, this); + } + @Override public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Organisation organisation, Locale locale) { diff --git a/src/main/java/org/olat/repository/ui/author/CreateCourseRepositoryEntryController.java b/src/main/java/org/olat/repository/ui/author/CreateCourseRepositoryEntryController.java new file mode 100644 index 0000000000000000000000000000000000000000..ad24e1da458edcf51117ed56f24143c684172bd8 --- /dev/null +++ b/src/main/java/org/olat/repository/ui/author/CreateCourseRepositoryEntryController.java @@ -0,0 +1,93 @@ +/** + * <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.repository.ui.author; + +import org.apache.logging.log4j.Logger; +import org.olat.core.gui.UserRequest; +import org.olat.core.gui.components.form.flexible.FormItemContainer; +import org.olat.core.gui.components.form.flexible.elements.SingleSelection; +import org.olat.core.gui.components.util.KeyValues; +import org.olat.core.gui.control.Controller; +import org.olat.core.gui.control.WindowControl; +import org.olat.core.id.OLATResourceable; +import org.olat.core.logging.Tracing; +import org.olat.course.CourseFactory; +import org.olat.course.ICourse; +import org.olat.course.config.CourseConfig; +import org.olat.course.nodeaccess.NodeAccessProviderIdentifier; +import org.olat.course.nodeaccess.NodeAccessService; +import org.olat.repository.handlers.RepositoryHandler; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * + * Initial date: 27 Aug 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public class CreateCourseRepositoryEntryController extends CreateRepositoryEntryController { + + private static final Logger log = Tracing.createLoggerFor(CreateCourseRepositoryEntryController.class); + + private SingleSelection nodeAccessEl; + + @Autowired + private NodeAccessService nodeAccessService; + + public CreateCourseRepositoryEntryController(UserRequest ureq, WindowControl wControl, RepositoryHandler handler) { + super(ureq, wControl, handler); + } + + @Override + protected void initAdditionalFormElements(FormItemContainer formLayout, Controller listener, UserRequest ureq) { + KeyValues nodeAccessKV = new KeyValues(); + for (NodeAccessProviderIdentifier identifier : nodeAccessService.getNodeAccessProviderIdentifer()) { + nodeAccessKV.add(KeyValues.entry(identifier.getType(), identifier.getDisplayName(getLocale()))); + } + nodeAccessEl = uifactory.addDropdownSingleselect("cif.node.access", "cif.node.access", formLayout, + nodeAccessKV.keys(), nodeAccessKV.values()); + nodeAccessEl.select(CourseConfig.NODE_ACCESS_TYPE_DEFAULT, true); + } + + @Override + protected void afterEntryCreated() { + if (isNotDefaultNodeAccessType()) { + OLATResourceable courseOres = getAddedEntry().getOlatResource(); + if (CourseFactory.isCourseEditSessionOpen(courseOres.getResourceableId())) { + log.warn("Not able to set the course node access type: Edit session is already open!"); + return; + } + + ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId()); + CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig(); + String nodeAccessType = nodeAccessEl.getSelectedKey(); + courseConfig.setNodeAccessType(nodeAccessType); + + CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig); + CourseFactory.closeCourseEditSession(course.getResourceableId(), true); + } + } + + private boolean isNotDefaultNodeAccessType() { + return nodeAccessEl.isOneSelected() + && !CourseConfig.NODE_ACCESS_TYPE_DEFAULT.equals(nodeAccessEl.getSelectedValue()); + } + +} diff --git a/src/main/java/org/olat/repository/ui/author/CreateRepositoryEntryController.java b/src/main/java/org/olat/repository/ui/author/CreateRepositoryEntryController.java index 317b6823f7813da4875662713d92e1850a011bbc..a3f4c77f2feafed0a96d47f22be4f62ebc4790ab 100644 --- a/src/main/java/org/olat/repository/ui/author/CreateRepositoryEntryController.java +++ b/src/main/java/org/olat/repository/ui/author/CreateRepositoryEntryController.java @@ -175,6 +175,8 @@ public class CreateRepositoryEntryController extends FormBasicController impleme } organisationEl.setVisible(organisationKeys.size() > 1 && organisationModule.isEnabled()); + initAdditionalFormElements(formLayout, listener, ureq); + FormLayoutContainer buttonContainer = FormLayoutContainer.createButtonLayout("buttonContainer", getTranslator()); formLayout.add("buttonContainer", buttonContainer); buttonContainer.setElementCssClass("o_sel_repo_save_details"); @@ -189,6 +191,11 @@ public class CreateRepositoryEntryController extends FormBasicController impleme uifactory.addFormCancelButton("cancel", buttonContainer, ureq, getWindowControl()); } + @SuppressWarnings("unused") + protected void initAdditionalFormElements(FormItemContainer formLayout, Controller listener, UserRequest ureq) { + // + } + @Override protected void doDispose() { // @@ -259,10 +266,16 @@ public class CreateRepositoryEntryController extends FormBasicController impleme licenseService.createDefaultLicense(addedEntry.getOlatResource(), licenseHandler, getIdentity()); } } + + afterEntryCreated(); repositoryManager.triggerIndexer(addedEntry); ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_CREATE, getClass(), LoggingResourceable.wrap(addedEntry, OlatResourceableType.genRepoEntry)); } + + protected void afterEntryCreated() { + // May be overridden. + } }