Search in sources :

Example 16 with Structure

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;
}
Also used : CourseNode(org.olat.course.nodes.CourseNode) Structure(org.olat.course.Structure)

Example 17 with 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;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) PersistingCourseGroupManager(org.olat.course.groupsandrights.PersistingCourseGroupManager) RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) FileNotFoundException(java.io.FileNotFoundException) OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryImport(org.olat.repository.RepositoryEntryImportExport.RepositoryEntryImport) FileInputStream(java.io.FileInputStream) Structure(org.olat.course.Structure) File(java.io.File) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) RepositoryService(org.olat.repository.RepositoryService)

Example 18 with Structure

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;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ArrayList(java.util.ArrayList) CourseNode(org.olat.course.nodes.CourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) Structure(org.olat.course.Structure)

Example 19 with Structure

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();
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) Structure(org.olat.course.Structure)

Example 20 with Structure

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);
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) Structure(org.olat.course.Structure)

Aggregations

Structure (org.olat.course.Structure)22 ICourse (org.olat.course.ICourse)8 CourseNode (org.olat.course.nodes.CourseNode)8 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)8 ArrayList (java.util.ArrayList)6 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 HashSet (java.util.HashSet)4 AssessmentManager (org.olat.course.assessment.AssessmentManager)4 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)4 CourseConfig (org.olat.course.config.CourseConfig)4 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)4 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)4 BusinessGroup (org.olat.group.BusinessGroup)4 BGArea (org.olat.group.area.BGArea)4 DENCourseNode (de.bps.course.nodes.DENCourseNode)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 Date (java.util.Date)2