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;
}
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();
}
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());
}
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());
}
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();
}
Aggregations