diff --git a/src/main/java/org/olat/course/CourseFactory.java b/src/main/java/org/olat/course/CourseFactory.java index 285aae1944058bbbc3228544bd748749ab9f0d3c..be58679480fb50d2a581d6e357fb93ce6d74beaf 100644 --- a/src/main/java/org/olat/course/CourseFactory.java +++ b/src/main/java/org/olat/course/CourseFactory.java @@ -205,19 +205,20 @@ public class CourseFactory extends BasicManager { /** * Creates an empty course with a single root node. The course is linked to - * the resourceable ores. + * the resourceable ores. The efficiency statment are enabled per default! * * @param ores * @param shortTitle Short title of root node * @param longTitle Long title of root node * @param learningObjectives Learning objectives of root node - * @return an empty course with a single root node. + * @return An empty course with a single root node. */ - public static ICourse createEmptyCourse(RepositoryEntry courseEntry, String shortTitle, String longTitle, String learningObjectives) { + public static ICourse createCourse(RepositoryEntry courseEntry, + String shortTitle, String longTitle, String learningObjectives) { OLATResource courseResource = courseEntry.getOlatResource(); PersistingCourseImpl newCourse = new PersistingCourseImpl(courseResource.getResourceableId()); // Put new course in course cache - loadedCourses.put(newCourse.getResourceableId() ,newCourse); + loadedCourses.put(newCourse.getResourceableId(), newCourse); Structure initialStructure = new Structure(); CourseNode runRootNode = new STCourseNode(); @@ -233,9 +234,16 @@ public class CourseFactory extends BasicManager { editorTreeModel.setRootNode(editorRootNode); newCourse.setEditorTreeModel(editorTreeModel); newCourse.saveEditorTreeModel(); + + //enable efficiency statement per default + CourseConfig courseConfig = newCourse.getCourseConfig(); + courseConfig.setEfficencyStatementIsEnabled(true); + newCourse.setCourseConfig(courseConfig); return newCourse; } + + /** * Gets the course from cache if already there, or loads the course and puts it into cache. diff --git a/src/main/java/org/olat/repository/handlers/CourseHandler.java b/src/main/java/org/olat/repository/handlers/CourseHandler.java index 190189186dd490d297e630dfe03150c0c8130f5e..40acd4e26474fb8bf02b96c3807fd5f582af210c 100644 --- a/src/main/java/org/olat/repository/handlers/CourseHandler.java +++ b/src/main/java/org/olat/repository/handlers/CourseHandler.java @@ -85,7 +85,6 @@ import org.olat.course.config.CourseConfig; import org.olat.course.export.CourseEnvironmentMapper; import org.olat.course.groupsandrights.CourseGroupManager; import org.olat.course.groupsandrights.PersistingCourseGroupManager; -import org.olat.course.nodes.CourseNode; import org.olat.course.run.CourseRuntimeController; import org.olat.course.run.RunMainController; import org.olat.course.tree.CourseEditorTreeNode; @@ -143,27 +142,10 @@ public class CourseHandler implements RepositoryHandler { OLATResource resource = OLATResourceManager.getInstance().createOLATResourceInstance(CourseModule.class); RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS); DBFactory.getInstance().commit(); - - ICourse course = CourseFactory.createEmptyCourse(re, "New Course", "New Course", ""); - course = CourseFactory.openCourseEditSession(re.getOlatResource().getResourceableId()); - + String shortDisplayname = Formatter.truncateOnly(displayname, 25); - CourseNode runRootNode = course.getRunStructure().getRootNode(); - runRootNode.setShortTitle(shortDisplayname); //do not use truncate! - runRootNode.setLongTitle(displayname); - - //enable efficiency statement per default - CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig(); - courseConfig.setEfficencyStatementIsEnabled(true); - CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig); - - CourseNode rootNode = ((CourseEditorTreeNode)course.getEditorTreeModel().getRootNode()).getCourseNode(); - rootNode.setShortTitle(shortDisplayname); //do not use truncate! - rootNode.setLongTitle(displayname); - - CourseFactory.saveCourse(course.getResourceableId()); - CourseFactory.closeCourseEditSession(course.getResourceableId(), true); - + ICourse course = CourseFactory.createCourse(re, shortDisplayname, displayname, ""); + log.audit("Course created: " + course.getCourseTitle()); return re; } diff --git a/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java b/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java index 331faae17498db8914ac0e001f672d8132f3ce3c..e0f8e787d11a4508f446bdc7f2ca64bc8413e463 100644 --- a/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java +++ b/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java @@ -518,7 +518,7 @@ public class CoursesWebService { addedEntry = repositoryService.update(addedEntry); // create an empty course - CourseFactory.createEmptyCourse(addedEntry, shortTitle, longTitle, learningObjectives); + CourseFactory.createCourse(addedEntry, shortTitle, longTitle, learningObjectives); return prepareCourse(addedEntry, shortTitle, longTitle, courseConfigVO); } catch (Exception e) { diff --git a/src/main/java/org/olat/search/ui/SearchInputController.java b/src/main/java/org/olat/search/ui/SearchInputController.java index e9bff5e9b8f5bb4692cc6a9cc8fd2c7ca7d89acf..0d0c43d10fc5885ceb71d342385bbe8ddef2a6eb 100644 --- a/src/main/java/org/olat/search/ui/SearchInputController.java +++ b/src/main/java/org/olat/search/ui/SearchInputController.java @@ -49,7 +49,6 @@ import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController; -import org.olat.core.gui.media.RedirectMediaResource; import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.BusinessControl; import org.olat.core.id.context.BusinessControlFactory; diff --git a/src/test/java/org/olat/course/config/CourseConfigManagerImplTest.java b/src/test/java/org/olat/course/config/CourseConfigManagerImplTest.java index 52b8763ab46ff08dec365eb5a3e6999925574802..6d2cdf9999d419f4aec8c09cc7a7c41cec20e0cb 100644 --- a/src/test/java/org/olat/course/config/CourseConfigManagerImplTest.java +++ b/src/test/java/org/olat/course/config/CourseConfigManagerImplTest.java @@ -64,7 +64,7 @@ public class CourseConfigManagerImplTest extends OlatTestCase { // create course and persist as OLATResourceImpl OLATResource resource = resourceManager.createOLATResourceInstance(CourseModule.class); RepositoryEntry addedEntry = repositoryService.create("Ayanami", "-", "JUnit course configuration course", "A JUnit course", resource); - ICourse course = CourseFactory.createEmptyCourse(addedEntry, "JUnitCourseConfig", "JUnitCourseConfig Long Title", + ICourse course = CourseFactory.createCourse(addedEntry, "JUnitCourseConfig", "JUnitCourseConfig Long Title", "objective 1 objective 2 objective 3"); dbInstance.commitAndCloseSession(); diff --git a/src/test/java/org/olat/course/nodes/en/EnrollmentManagerConcurrentTest.java b/src/test/java/org/olat/course/nodes/en/EnrollmentManagerConcurrentTest.java index bd6852a2eae0d6898bc9696fcc0b1cd0a3788126..0272c99fd0972b6904b2d767cf9738acb28faf78 100644 --- a/src/test/java/org/olat/course/nodes/en/EnrollmentManagerConcurrentTest.java +++ b/src/test/java/org/olat/course/nodes/en/EnrollmentManagerConcurrentTest.java @@ -160,7 +160,7 @@ public class EnrollmentManagerConcurrentTest extends OlatTestCase implements Win OLATResource resource = resourceManager.createOLATResourceInstance(CourseModule.class); RepositoryEntry addedEntry = repositoryService.create("Ayanami", "-", "Enrollment test course 1", "A JUnit course", resource); - CourseEnvironment cenv = CourseFactory.createEmptyCourse(addedEntry, "Test", "Test", "learningObjectives").getCourseEnvironment(); + CourseEnvironment cenv = CourseFactory.createCourse(addedEntry, "Test", "Test", "learningObjectives").getCourseEnvironment(); // 1. enroll wg1 user IdentityEnvironment ienv = new IdentityEnvironment(); ienv.setIdentity(wg1); @@ -257,7 +257,7 @@ public class EnrollmentManagerConcurrentTest extends OlatTestCase implements Win ENCourseNode enNode = new ENCourseNode(); OLATResource resource = resourceManager.createOLATResourceInstance(CourseModule.class); RepositoryEntry addedEntry = repositoryService.create("Ayanami", "-", "Enrollment test course 2", "A JUnit course", resource); - CourseEnvironment cenv = CourseFactory.createEmptyCourse(addedEntry, "Test-Enroll", "Test", "Test enrollment with concurrent users").getCourseEnvironment(); + CourseEnvironment cenv = CourseFactory.createCourse(addedEntry, "Test-Enroll", "Test", "Test enrollment with concurrent users").getCourseEnvironment(); BusinessGroup group = businessGroupService.createBusinessGroup(id1, "Enrollment", "Enroll", new Integer(1), new Integer(10), true, false, null); Assert.assertNotNull(group); dbInstance.commitAndCloseSession();