Search in sources :

Example 1 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class ModifyCourseEvent method createCourse.

/**
 * Creates an empty course with a single root node. The course is linked to
 * 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.
 */
public static ICourse createCourse(RepositoryEntry courseEntry, String shortTitle, String longTitle, String learningObjectives) {
    OLATResource courseResource = courseEntry.getOlatResource();
    PersistingCourseImpl newCourse = new PersistingCourseImpl(courseResource);
    // Put new course in course cache
    loadedCourses.put(newCourse.getResourceableId(), newCourse);
    Structure initialStructure = new Structure();
    CourseNode runRootNode = new STCourseNode();
    runRootNode.setShortTitle(shortTitle);
    runRootNode.setLongTitle(longTitle);
    runRootNode.setLearningObjectives(learningObjectives);
    initialStructure.setRootNode(runRootNode);
    newCourse.setRunStructure(initialStructure);
    newCourse.saveRunStructure();
    CourseEditorTreeModel editorTreeModel = new CourseEditorTreeModel();
    CourseEditorTreeNode editorRootNode = new CourseEditorTreeNode((CourseNode) ObjectCloner.deepCopy(runRootNode));
    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;
}
Also used : CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) STCourseNode(org.olat.course.nodes.STCourseNode) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) OLATResource(org.olat.resource.OLATResource) STCourseNode(org.olat.course.nodes.STCourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseConfig(org.olat.course.config.CourseConfig)

Example 2 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class NodeExportVisitor method visit.

/**
 * Visitor pattern to delete the course nodes
 *
 * @see org.olat.core.util.tree.Visitor#visit(org.olat.core.util.nodes.INode)
 */
public void visit(INode node) {
    CourseEditorTreeNode cNode = (CourseEditorTreeNode) node;
    cNode.getCourseNode().exportNode(exportDirectory, course);
    // OLAT-5368: do frequent intermediate commits to avoid transaction timeout
    // discussion intermediatecommit vs increased transaction timeout:
    // pro intermediatecommit: not much
    // pro increased transaction timeout: would fix OLAT-5368 but only move the problem
    // @TODO OLAT-2597: real solution is a long-running background-task concept...
    DBFactory.getInstance().intermediateCommit();
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode)

Example 3 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class PublishProcessTest method testPublishNewNodeButNotMarkedAsSuchAndDeleted.

/**
 * Publish a course with a node marked as not new and deleted but
 * the node doesn't exist in the run structure.
 *
 * @throws URISyntaxException
 */
@Test
public void testPublishNewNodeButNotMarkedAsSuchAndDeleted() throws URISyntaxException {
    Identity author = JunitTestHelper.createAndPersistIdentityAsAdmin("publisher-" + UUID.randomUUID().toString());
    RepositoryEntry re = deployTestCourse("simple_course_err4_not_new_deleted.zip");
    // change node 1
    ICourse course = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
    CourseEditorTreeModel cetm = course.getEditorTreeModel();
    CourseEditorTreeNode node1 = (CourseEditorTreeNode) cetm.getRootNode().getChildAt(0);
    // publish the course and must survive this without exception
    // as the course has no changes but we try to publish it
    List<String> nodeIds = Collections.singletonList(node1.getIdent());
    publishCourse(nodeIds, re, author);
    // check the change
    ICourse reloadedCourse = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
    Assert.assertEquals(2, reloadedCourse.getRunStructure().getRootNode().getChildCount());
    INode runNode1 = reloadedCourse.getRunStructure().getRootNode().getChildAt(0);
    Assert.assertNotNull(runNode1);
    CourseNode runNode1Impl = (CourseNode) runNode1;
    Assert.assertEquals("Node 2", runNode1Impl.getShortTitle());
}
Also used : INode(org.olat.core.util.nodes.INode) CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 4 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class PublishProcessTest method testPublishNewNodeButNotMarkedAsSuch.

/**
 * Publish a course with a node marked as not new but the
 * node dosn't exist in the run structure.
 *
 * @throws URISyntaxException
 */
@Test
public void testPublishNewNodeButNotMarkedAsSuch() throws URISyntaxException {
    Identity author = JunitTestHelper.createAndPersistIdentityAsAdmin("publisher-" + UUID.randomUUID().toString());
    RepositoryEntry re = deployTestCourse("simple_course_err3_not_new.zip");
    // change node 1
    ICourse course = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
    CourseEditorTreeModel cetm = course.getEditorTreeModel();
    CourseEditorTreeNode node1 = (CourseEditorTreeNode) cetm.getRootNode().getChildAt(0);
    // publish the course and must survive this without exception
    // as the course has no changes but we try to publish it
    List<String> nodeIds = Collections.singletonList(node1.getIdent());
    publishCourse(nodeIds, re, author);
    // check the change
    ICourse reloadedCourse = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
    Assert.assertEquals(3, reloadedCourse.getRunStructure().getRootNode().getChildCount());
    INode runNode1 = reloadedCourse.getRunStructure().getRootNode().getChildAt(0);
    Assert.assertNotNull(runNode1);
    CourseNode runNode1Impl = (CourseNode) runNode1;
    Assert.assertEquals("Node 1 from hell", runNode1Impl.getShortTitle());
}
Also used : INode(org.olat.core.util.nodes.INode) CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 5 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class EditorMainController method doOpenNodeTypeChooser.

private void doOpenNodeTypeChooser(UserRequest ureq) {
    removeAsListenerAndDispose(cmc);
    removeAsListenerAndDispose(chooseNodeTypeCtr);
    menuTree.getSelectedNode();
    TreeNode tn = menuTree.getSelectedNode();
    CourseEditorTreeNode cetn = tn == null ? null : cetm.getCourseEditorNodeById(tn.getIdent());
    chooseNodeTypeCtr = new ChooseNodeController(ureq, getWindowControl(), ores, cetn);
    listenTo(chooseNodeTypeCtr);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), chooseNodeTypeCtr.getInitialComponent(), true, translate("header.insertnodes"));
    listenTo(cmc);
    cmc.activate();
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode)

Aggregations

CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)88 CourseNode (org.olat.course.nodes.CourseNode)54 ICourse (org.olat.course.ICourse)38 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)24 INode (org.olat.core.util.nodes.INode)22 Test (org.junit.Test)20 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Identity (org.olat.core.id.Identity)14 TreeVisitor (org.olat.core.util.tree.TreeVisitor)14 Visitor (org.olat.core.util.tree.Visitor)14 CourseNodeVO (org.olat.restapi.support.vo.CourseNodeVO)12 TreeNode (org.olat.core.gui.components.tree.TreeNode)10 STCourseNode (org.olat.course.nodes.STCourseNode)10 ArrayList (java.util.ArrayList)9 File (java.io.File)8 URI (java.net.URI)8 HttpResponse (org.apache.http.HttpResponse)8 HttpPut (org.apache.http.client.methods.HttpPut)8 Structure (org.olat.course.Structure)8 BCCourseNode (org.olat.course.nodes.BCCourseNode)8