use of org.olat.course.Structure in project OpenOLAT by OpenOLAT.
the class CourseEditorTreeModel method createStructureForPreview.
/**
* @return a deep clone of the current (run) structure of this editortreemodel
*/
public Structure createStructureForPreview() {
CourseEditorTreeNode cetn = (CourseEditorTreeNode) getRootNode();
CourseNode clone = buildUp(cetn);
Structure structure = new Structure();
structure.setRootNode(clone);
return structure;
}
use of org.olat.course.Structure in project openolat by klemens.
the class CourseHandler method importResource.
@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String filename) {
OLATResource newCourseResource = OLATResourceManager.getInstance().createOLATResourceInstance(CourseModule.class);
ICourse course = CourseFactory.importCourseFromZip(newCourseResource, file);
// cfc.release();
if (course == null) {
return null;
}
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, newCourseResource, RepositoryEntry.ACC_OWNERS);
DBFactory.getInstance().commit();
// create empty run structure
course = CourseFactory.openCourseEditSession(course.getResourceableId());
Structure runStructure = course.getRunStructure();
runStructure.getRootNode().removeAllChildren();
CourseFactory.saveCourse(course.getResourceableId());
// import references
CourseEditorTreeNode rootNode = (CourseEditorTreeNode) course.getEditorTreeModel().getRootNode();
importReferences(rootNode, course, initialAuthor, locale, withReferences);
if (withReferences && course.getCourseConfig().hasCustomSharedFolder()) {
importSharedFolder(course, initialAuthor);
}
if (withReferences && course.getCourseConfig().hasGlossary()) {
importGlossary(course, initialAuthor);
}
// create group management / import groups
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
File fImportBaseDirectory = course.getCourseExportDataDir().getBasefile();
CourseEnvironmentMapper envMapper = cgm.importCourseBusinessGroups(fImportBaseDirectory);
envMapper.setAuthor(initialAuthor);
// upgrade course
course = CourseFactory.loadCourse(cgm.getCourseResource());
course.postImport(fImportBaseDirectory, envMapper);
// rename root nodes, but only when user modified the course title
boolean doUpdateTitle = true;
File repoConfigXml = new File(fImportBaseDirectory, "repo.xml");
if (repoConfigXml.exists()) {
RepositoryEntryImport importConfig;
try {
importConfig = RepositoryEntryImportExport.getConfiguration(new FileInputStream(repoConfigXml));
if (importConfig != null) {
if (displayname.equals(importConfig.getDisplayname())) {
// do not update if title was not modified during import
// user does not expect to have an updated title and there is a chance
// the root node title is not the same as the course title
doUpdateTitle = false;
}
}
} catch (FileNotFoundException e) {
// ignore
}
}
if (doUpdateTitle) {
// do not use truncate!
course.getRunStructure().getRootNode().setShortTitle(Formatter.truncateOnly(displayname, 25));
course.getRunStructure().getRootNode().setLongTitle(displayname);
}
// course.saveRunStructure();
CourseEditorTreeNode editorRootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode());
// do not use truncate!
editorRootNode.getCourseNode().setShortTitle(Formatter.truncateOnly(displayname, 25));
editorRootNode.getCourseNode().setLongTitle(displayname);
// mark entire structure as dirty/new so the user can re-publish
markDirtyNewRecursively(editorRootNode);
// root has already been created during export. Unmark it.
editorRootNode.setNewnode(false);
// save and close edit session
CourseFactory.saveCourse(course.getResourceableId());
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
RepositoryEntryImportExport imp = new RepositoryEntryImportExport(fImportBaseDirectory);
if (imp.anyExportedPropertiesAvailable()) {
re = imp.importContent(re, getMediaContainer(re));
}
// import reminders
importReminders(re, fImportBaseDirectory, envMapper, initialAuthor);
// clean up export folder
cleanExportAfterImport(fImportBaseDirectory);
return re;
}
use of org.olat.course.Structure in project openolat by klemens.
the class AssessmentNotificationsHandler method getCourseTestNodes.
/**
* Utility method.<br>
* Build (recursively) the list of all test nodes belonging to the specified
* <code>ICourse</code>.<br>
* The returned <code>List</code> is empty if course has no
* AssessableCourseNode. Structure course node are excluded from the list.<br>
* <br>
* <b>PRE CONDITIONS</b>
* <ul>
* <li> <code>course != null</code>
* </ul>
* <br>
* <b>POST CONDITIONS</b>
* <ul>
* <li> The returned list, if not empty, contains ONLY instances of type
* <code>AssessableCourseNode</code>
* </ul>
*/
private List<AssessableCourseNode> getCourseTestNodes(ICourse course) {
List<AssessableCourseNode> assessableNodes = new ArrayList<AssessableCourseNode>();
Structure courseStruct = course.getRunStructure();
CourseNode rootNode = courseStruct.getRootNode();
getCourseTestNodes(rootNode, assessableNodes);
return assessableNodes;
}
use of org.olat.course.Structure in project openolat by klemens.
the class PublishProcess method calculatePublishSet.
/**
* @param nodesIdsToPublish
* @param resultingCourseRun
* @param editorModelDeletedNodes
* @param editorModelInsertedNodes
* @param editorModelModifiedNodes
*/
private void calculatePublishSet(List<String> nodesIdsToPublish) {
/*
* START NEW STYLE PUBLISH ................................................. -
* visit each node (breadth first) - if node is selected to be published ->
* publish and take into account if the node exists already in the
* runstructure (keep ident or not). And also if node should get deleted add
* it to a list of nodes to be deleted. This is needed for a later clean-up
* and archive. ............................. - if node is not selected to
* be published, but exists already in the runstructure it must be added to
* the tmp-runstructure as it is in the existing runstructure.
* ..................................................
*/
// start point for node publish visitor
CourseEditorTreeNode editorRoot = (CourseEditorTreeNode) editorTreeModel.getRootNode();
// the active runstructure and the new created runstructure
Structure existingCourseRun = course.getRunStructure();
// breadth first!
boolean visitChildrenFirst = false;
/*
* the tree is visited and the book keeping lists are filled. the visitor
* itself does not delete or modify neither runstructure nor editor tree
* model. The whole complexity of published is encapsulated in the visitor.
*/
Visitor nodePublishV = new NodePublishVisitor(editorRoot, nodesIdsToPublish, existingCourseRun);
TreeVisitor tv = new TreeVisitor(nodePublishV, editorRoot, visitChildrenFirst);
tv.visitAll();
}
use of org.olat.course.Structure in project openolat by klemens.
the class PublishProcess method createPublishSetFor.
/**
* first step in publishing course editor nodes.<br>
* next step is testPublishSet, see method for more details.
* @param nodeIdsToPublish
*/
public void createPublishSetFor(List<String> nodeIdsToPublish) {
this.originalNodeIdsToPublish = nodeIdsToPublish;
// append new nodes' subnodes
int selectCount = nodeIdsToPublish.size();
for (int i = 0; i < selectCount; i++) {
// avoid using iterator here so we can modify the Collection
String nodeId = nodeIdsToPublish.get(i);
CourseEditorTreeNode cetn = editorTreeModel.getCourseEditorNodeById(nodeId);
if (cetn.isNewnode() || cetn.isDeleted() || publishTreeModel.isMoved(cetn))
appendPublishableSubnodeIds(cetn, nodeIdsToPublish);
}
/*
* generatePublishSet, testPublishSet, applyPublishSet
*/
/*
* several book keeping lists which are also used to modify the course
* editor model after the new runstructure is generated into ram.
*/
editorModelDeletedNodes = new ArrayList<CourseEditorTreeNode>();
editorModelInsertedNodes = new ArrayList<CourseEditorTreeNode>();
editorModelModifiedNodes = new ArrayList<CourseEditorTreeNode>();
resultingCourseRun = new Structure();
// has side effect on the above editorModelxxxNodes and the
// resultingCourseRun;
calculatePublishSet(nodeIdsToPublish);
}
Aggregations