use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.
the class PublishProcessTest method publishCourse.
private void publishCourse(List<String> nodeIds, RepositoryEntry re, Identity author) {
ICourse course = CourseFactory.openCourseEditSession(re.getOlatResource().getResourceableId());
CourseEditorTreeModel cetm = course.getEditorTreeModel();
PublishProcess pp = PublishProcess.getInstance(course, cetm, locale);
// create publish node list
pp.createPublishSetFor(nodeIds);
PublishSetInformations set = pp.testPublishSet(locale);
StatusDescription[] sds = set.getWarnings();
Assert.assertNotNull(sds);
Assert.assertEquals(0, sds.length);
pp.applyPublishSet(author, locale, true);
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
}
use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.
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.CourseEditorTreeModel in project openolat by klemens.
the class PublishProcessTest method testPublishANotReallyNewNode.
/**
* Publish a course with a node marked as new but the node
* exists already in the run structure.
*
* @throws URISyntaxException
*/
@Test
public void testPublishANotReallyNewNode() throws URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAdmin("publisher-" + UUID.randomUUID().toString());
RepositoryEntry re = deployTestCourse("simple_course_err1_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 not really new", runNode1Impl.getShortTitle());
}
use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.
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.CourseEditorTreeModel in project openolat by klemens.
the class CourseExtensionHelper method createNode.
/**
* Creates a course node and appends it to the course. (not persisted yet)
*
* @param c course object
* @param shortTitle short title for node
* @param longTitle long title for node
* @return created course node
*/
public static final CourseNode createNode(ICourse course, final String shortTitle, final String longTitle, final String type) {
// create a node with default data
CourseNodeConfiguration nodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
CourseNode node = nodeConfig.getInstance();
node.setShortTitle(shortTitle);
node.setLongTitle(longTitle);
// append node to course
course = CourseFactory.openCourseEditSession(course.getResourceableId());
final CourseEditorTreeModel cetm = course.getEditorTreeModel();
final CourseNode rootNode = cetm.getCourseNode(course.getRunStructure().getRootNode().getIdent());
course.getEditorTreeModel().addCourseNode(node, rootNode);
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
OLog log = Tracing.createLoggerFor(CourseExtensionHelper.class);
if (log.isDebug())
log.debug("Created new course node: " + nodeConfig.getAlias());
return node;
}
Aggregations