use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.
the class ChooseNodeController method doCreateNode.
private void doCreateNode(String type) {
ICourse course = CourseFactory.getCourseEditSession(courseOres.getResourceableId());
// user chose a position to insert a new node
CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
createdNode = newNodeConfig.getInstance();
// Set some default values
String title = new String(newNodeConfig.getLinkText(getLocale()));
createdNode.setShortTitle(title);
createdNode.setNoAccessExplanation(translate("form.noAccessExplanation.default"));
// Insert it now
CourseEditorTreeModel editorTreeModel = course.getEditorTreeModel();
if (editorTreeModel.getRootNode().equals(currentNode)) {
// root, add as last child
int pos = currentNode.getChildCount();
CourseNode selectedNode = currentNode.getCourseNode();
editorTreeModel.insertCourseNodeAt(createdNode, selectedNode, pos);
} else {
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) currentNode.getParent();
CourseNode selectedNode = parentNode.getCourseNode();
int pos = currentNode.getPosition();
editorTreeModel.insertCourseNodeAt(createdNode, selectedNode, pos + 1);
}
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
}
use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.
the class QuickPublishController method doAutoPublish.
private boolean doAutoPublish() {
ICourse course = CourseFactory.loadCourse(courseOres);
CourseEditorTreeModel cetm = course.getEditorTreeModel();
PublishProcess publishProcess = PublishProcess.getInstance(course, cetm, getLocale());
PublishTreeModel publishTreeModel = publishProcess.getPublishTreeModel();
if (publishTreeModel.hasPublishableChanges()) {
List<String> nodeToPublish = new ArrayList<String>();
visitPublishModel(publishTreeModel.getRootNode(), publishTreeModel, nodeToPublish);
// only add selection if changes were possible
for (Iterator<String> selectionIt = nodeToPublish.iterator(); selectionIt.hasNext(); ) {
String ident = selectionIt.next();
TreeNode node = publishProcess.getPublishTreeModel().getNodeById(ident);
if (!publishTreeModel.isSelectable(node)) {
selectionIt.remove();
}
}
publishProcess.createPublishSetFor(nodeToPublish);
PublishSetInformations set = publishProcess.testPublishSet(getLocale());
StatusDescription[] status = set.getWarnings();
// publish not possible when there are errors
StringBuilder errMsg = new StringBuilder();
for (int i = 0; i < status.length; i++) {
if (status[i].isError()) {
errMsg.append(status[i].getLongDescription(getLocale()));
logError("Status error by publish: " + status[i].getLongDescription(getLocale()), null);
}
}
if (errMsg.length() > 0) {
getWindowControl().setWarning(errMsg.toString());
return false;
}
PublishEvents publishEvents = publishProcess.getPublishEvents();
try {
publishProcess.applyPublishSet(getIdentity(), getLocale(), false);
} catch (Exception e) {
logError("", e);
}
if (publishEvents.getPostPublishingEvents().size() > 0) {
for (MultiUserEvent event : publishEvents.getPostPublishingEvents()) {
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, courseOres);
}
}
}
return true;
}
use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.
the class NodeExportVisitor method load.
/**
* Load the course from disk/database, load the run structure from xml file etc.
*/
void load() {
/*
* remember that loading of the courseConfiguration is already done within
* the constructor !
*/
Object obj;
obj = readObject(RUNSTRUCTURE_XML);
if (!(obj instanceof Structure))
throw new AssertException("Error reading course run structure.");
runStructure = (Structure) obj;
initHasAssessableNodes();
obj = readObject(EDITORTREEMODEL_XML);
if (!(obj instanceof CourseEditorTreeModel))
throw new AssertException("Error reading course editor tree model.");
editorTreeModel = (CourseEditorTreeModel) obj;
}
use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.
the class NodeExportVisitor method postImport.
@Override
public void postImport(File importDirectory, CourseEnvironmentMapper envMapper) {
Structure importedStructure = getRunStructure();
visit(new NodePostImportVisitor(importDirectory, this, envMapper, Processing.runstructure), importedStructure.getRootNode());
saveRunStructure();
CourseEditorTreeModel importedEditorModel = getEditorTreeModel();
visit(new NodePostImportVisitor(importDirectory, this, envMapper, Processing.editor), importedEditorModel.getRootNode());
saveEditorTreeModel();
}
use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.
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;
}
Aggregations