use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class PublishProcessTest method testPublishNewNodeNotMarkedAsSuchAndNotPublished.
/**
* Publish a course with a node marked as not new but
* the node doesn't exist in the run structure. The node
* itself is not published.
*
* @throws URISyntaxException
*/
@Test
public void testPublishNewNodeNotMarkedAsSuchAndNotPublished() throws URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAdmin("publisher-" + UUID.randomUUID().toString());
RepositoryEntry re = deployTestCourse("simple_course_err5_not_new_or_published.zip");
// change node 1
ICourse course = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
CourseEditorTreeModel cetm = course.getEditorTreeModel();
// 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(cetm.getRootNode().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.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method getGTACourseNode.
private GTACourseNode getGTACourseNode(RepositoryEntry courseEntry) {
ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
for (int i = rootNode.getChildCount(); i-- > 0; ) {
INode child = rootNode.getChildAt(i);
if (child instanceof GTACourseNode) {
return ((GTACourseNode) child);
}
}
return null;
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class EditorMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
try {
ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
if (source == nodeEditCntrllr) {
// event from the tabbed pane (any tab)
if (event == NodeEditController.NODECONFIG_CHANGED_EVENT) {
// if the user changed the name of the node, we need to update the tree also.
// the event is too generic to find out what happened -> update tree in all cases (applies to ajax mode only)
menuTree.setDirty(true);
cetm.nodeConfigChanged(menuTree.getSelectedNode());
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
}
} else if (source == statusCtr) {
if (event.getCommand().startsWith(NLS_START_HELP_WIZARD)) {
doStartHelpWizard(ureq, event);
}
calloutCtrl.deactivate();
cleanUp();
} else if (source == chooseNodeTypeCtr) {
cmc.deactivate();
String cmd = event.getCommand();
if (cmd.startsWith(TB_ACTION)) {
CourseNode newNode = chooseNodeTypeCtr.getCreatedNode();
cleanUp();
doInsert(ureq, newNode);
} else if (CMD_MULTI_SP.equals(cmd)) {
cleanUp();
launchSinglePagesWizard(ureq, course);
} else if (CMD_MULTI_CHECKLIST.equals(cmd)) {
cleanUp();
launchChecklistsWizard(ureq);
}
} else if (source == publishStepsController) {
getWindowControl().pop();
Object requestOnClose = publishStepsController.getRunContext().get("requestOnClose");
removeAsListenerAndDispose(publishStepsController);
publishStepsController = null;
// reset to root node... may have published a deleted node -> this
// resets the view
// else Event.DONE -> nothing changed / else Event.CANCELLED -> cancelled wizard
updateAfterPublishing(ureq, course, event == Event.CHANGED_EVENT);
if (Boolean.TRUE.equals(requestOnClose)) {
fireEvent(ureq, Event.DONE_EVENT);
}
} else if (source == quickPublishCtr) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
fireEvent(ureq, Event.DONE_EVENT);
} else if (event == MANUAL_PUBLISH) {
cmc.deactivate();
launchPublishingWizard(ureq, course, true);
} else if (event == Event.CHANGED_EVENT) {
updateAfterPublishing(ureq, course, event == Event.CHANGED_EVENT);
cleanUpNodeController();
cmc.deactivate();
fireEvent(ureq, Event.DONE_EVENT);
}
} else if (source == previewController) {
if (event == Event.DONE_EVENT) {
// no need to deactivate preview controller, already done internally
removeAsListenerAndDispose(previewController);
previewController = null;
}
} else if (source == checklistWizard) {
if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
getWindowControl().pop();
removeAsListenerAndDispose(checklistWizard);
checklistWizard = null;
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
menuTree.setDirty(true);
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
}
}
} else if (source == cmc) {
cleanUp();
} else if (source == moveCopyController) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
// setDirty when moving
menuTree.setDirty(true);
// Repositioning to move/copy course node
String nodeId = moveCopyController.getCopyNodeId();
if (nodeId != null) {
menuTree.setSelectedNodeId(nodeId);
euce.getCourseEditorEnv().setCurrentCourseNodeId(nodeId);
CourseNode copyNode = cetm.getCourseNode(nodeId);
initNodeEditor(ureq, copyNode);
}
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
} else if (event == Event.FAILED_EVENT) {
getWindowControl().setError("Error in copy of subtree.");
} else if (event == Event.CANCELLED_EVENT) {
// user canceled
}
// aggressive clean-up
cleanUp();
} else if (source == deleteDialogController) {
removeAsListenerAndDispose(deleteDialogController);
deleteDialogController = null;
if (DialogBoxUIFactory.isYesEvent(event)) {
// delete confirmed
String ident = menuTree.getSelectedNode().getIdent();
// udpate the current node in the course editor environment
doDelete(course, ident);
} else {
tabbedNodeConfig.setVisible(true);
}
} else if (source == multiSPChooserCtr) {
cmc.deactivate();
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(multiSPChooserCtr);
cmc = null;
if (event == Event.CHANGED_EVENT) {
menuTree.setDirty(true);
euce.getCourseEditorEnv().validateCourse();
StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
updateCourseStatusMessages(ureq.getLocale(), courseStatus);
}
} else if (source == alternateCtr) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
CourseNode chosenNode = alternateCtr.getCourseNode();
String selectAlternative = alternateCtr.getSelectedAlternative();
doCreateAlternateBuildingBlock(ureq, course, chosenNode, selectAlternative);
}
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(alternateCtr);
cmc = null;
alternateCtr = null;
}
} catch (RuntimeException e) {
log.warn(RELEASE_LOCK_AT_CATCH_EXCEPTION + " [in event(UserRequest,Controller,Event)]", e);
this.dispose();
throw e;
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class EditorMainController method doCreateAlternateBuildingBlock.
/**
* The following operation are done:
* <ul>
* <li>create a new instance of the replacement type
* <li>add the new element below the original element
* <li>copy the element title, description and the generic configuration options
* <li>copy the access, visibility and scoring rules (easy and expert)
* <li>optionally copy some other configuration if this is possible at all
* <li>move all child elements from the original to the replacement element
* <li>mark the original element as deleted
* </ul>
*
* @param chosenNode
* @param selectAlternative
*/
private void doCreateAlternateBuildingBlock(UserRequest ureq, ICourse course, CourseNode chosenNode, String selectAlternative) {
if (!StringHelper.containsNonWhitespace(selectAlternative))
return;
// create the alternative node
CourseNodeConfiguration newConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(selectAlternative);
CourseNode newNode = newConfig.getInstance();
// copy configurations
chosenNode.copyConfigurationTo(newNode, course);
// insert the node
CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(chosenNode.getIdent());
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) cetn.getParent();
int position = cetn.getPosition() + 1;
CourseEditorTreeNode newCetn = course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode.getCourseNode(), position);
doInsert(ureq, newNode);
// copy the children
while (cetn.getChildCount() > 0) {
CourseEditorTreeNode childNode = (CourseEditorTreeNode) cetn.getChildAt(0);
newCetn.addChild(childNode);
}
// set all dirty
TreeVisitor tv = new TreeVisitor(new Visitor() {
public void visit(INode node) {
((CourseEditorTreeNode) node).setDirty(true);
}
}, newCetn, true);
tv.visitAll();
// mark as deleted
doDelete(course, chosenNode.getIdent());
// save
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class EditorMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
try {
ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
if (source == menuTree) {
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
// goto node in edit mode
TreeEvent te = (TreeEvent) event;
String nodeId = te.getNodeId();
updateViewForSelectedNodeId(ureq, nodeId);
} else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_DROP)) {
TreeDropEvent te = (TreeDropEvent) event;
dropNodeAsChild(ureq, course, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild(), te.isAtTheEnd());
}
} else if (source == main) {
if (event.getCommand().startsWith(NLS_START_HELP_WIZARD)) {
doStartHelpWizard(ureq, event);
}
} else if (source == undelButton) {
doUndelete(ureq, course);
} else if (source == alternativeLink) {
CourseNode chosenNode = (CourseNode) alternativeLink.getUserObject();
askForAlternative(ureq, chosenNode);
} else if (previewLink == source) {
launchPreview(ureq, course);
} else if (publishLink == source) {
launchPublishingWizard(ureq, course, false);
} else if (closeLink == source) {
doReleaseEditLock();
fireEvent(ureq, Event.DONE_EVENT);
} else if (createNodeLink == source) {
doOpenNodeTypeChooser(ureq);
} else if (deleteNodeLink == source) {
doDeleteNode(ureq);
} else if (moveNodeLink == source) {
doMove(ureq, course, false);
} else if (copyNodeLink == source) {
doMove(ureq, course, true);
} else if (statusLink == source) {
doOpenStatusOverview(ureq);
}
} catch (RuntimeException e) {
log.warn(RELEASE_LOCK_AT_CATCH_EXCEPTION + " [in event(UserRequest,Component,Event)]", e);
dispose();
throw e;
}
}
Aggregations