Search in sources :

Example 16 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class AbstractCourseNodeWebService method createCourseNode.

private CourseNodeVO createCourseNode(String type, String shortTitle, String longTitle, String learningObjectives, String visibilityExpertRules, String accessExpertRules, CustomConfigDelegate delegateConfig, CourseEditSession editSession, CourseNode parentNode, Integer position) {
    CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
    CourseNode insertedNode = newNodeConfig.getInstance();
    insertedNode.setShortTitle(shortTitle);
    insertedNode.setLongTitle(longTitle);
    insertedNode.setLearningObjectives(learningObjectives);
    insertedNode.setNoAccessExplanation("You don't have access");
    if (StringHelper.containsNonWhitespace(visibilityExpertRules)) {
        Condition cond = this.createExpertCondition(CONDITION_ID_VISIBILITY, visibilityExpertRules);
        insertedNode.setPreConditionVisibility(cond);
    }
    if (StringHelper.containsNonWhitespace(accessExpertRules) && insertedNode instanceof AbstractAccessableCourseNode) {
        Condition cond = createExpertCondition(CONDITION_ID_ACCESS, accessExpertRules);
        ((AbstractAccessableCourseNode) insertedNode).setPreConditionAccess(cond);
    }
    ICourse course = editSession.getCourse();
    if (delegateConfig != null) {
        ModuleConfiguration moduleConfig = insertedNode.getModuleConfiguration();
        delegateConfig.configure(course, insertedNode, moduleConfig);
    }
    if (position == null || position.intValue() < 0) {
        course.getEditorTreeModel().addCourseNode(insertedNode, parentNode);
    } else {
        course.getEditorTreeModel().insertCourseNodeAt(insertedNode, parentNode, position);
    }
    CourseEditorTreeNode editorNode = course.getEditorTreeModel().getCourseEditorNodeContaining(insertedNode);
    CourseNodeVO vo = get(insertedNode);
    vo.setParentId(editorNode.getParent() == null ? null : editorNode.getParent().getIdent());
    return vo;
}
Also used : Condition(org.olat.course.condition.Condition) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CourseNodeVO(org.olat.restapi.support.vo.CourseNodeVO) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode) ICourse(org.olat.course.ICourse) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) CourseNode(org.olat.course.nodes.CourseNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode)

Example 17 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class MultiSPController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (nodeSelections.contains(source)) {
        MultipleSelectionElement nodeSelection = (MultipleSelectionElement) source;
        if (nodeSelection.isMultiselect()) {
            selectRec(nodeSelection, nodeSelection.isSelected(0));
        }
    } else if (source == selectAll) {
        for (MultipleSelectionElement nodeSelection : nodeSelections) {
            if (nodeSelection.isMultiselect() && !nodeSelection.isSelected(0)) {
                SelectNodeObject treeNode = (SelectNodeObject) nodeSelection.getUserObject();
                String id = treeNode.getId();
                nodeSelection.select(id, true);
            }
        }
    } else if (source == deselectAll) {
        for (MultipleSelectionElement nodeSelection : nodeSelections) {
            if (nodeSelection.isMultiselect() && nodeSelection.isSelected(0)) {
                SelectNodeObject treeNode = (SelectNodeObject) nodeSelection.getUserObject();
                String id = treeNode.getId();
                nodeSelection.select(id, false);
            }
        }
    } else if (source == asChild) {
        position = -1;
        ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
        create(rootSelection, course, selectedNode.getCourseNode());
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (source == sameLevel) {
        ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
        CourseEditorTreeNode parentNode = (CourseEditorTreeNode) selectedNode.getParent();
        position = 0;
        for (position = parentNode.getChildCount(); position-- > 0; ) {
            if (selectedNode.getIdent().equals(parentNode.getChildAt(position).getIdent())) {
                position++;
                break;
            }
        }
        create(rootSelection, course, parentNode.getCourseNode());
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else {
        super.formInnerEvent(ureq, source, event);
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ICourse(org.olat.course.ICourse)

Example 18 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_0_0 method compareCourseNodeAssessment.

private boolean compareCourseNodeAssessment(AssessmentEntryImpl entry, NewCachePersistingAssessmentManager assessmentManager, ICourse course, RepositoryEntry courseEntry) {
    CourseNode node = course.getRunStructure().getNode(entry.getSubIdent());
    if (node == null) {
        CourseEditorTreeNode editorNode = course.getEditorTreeModel().getCourseEditorNodeById(entry.getSubIdent());
        if (editorNode != null) {
            node = editorNode.getCourseNode();
        }
    }
    boolean allOk = true;
    if (node instanceof AssessableCourseNode && !(node instanceof STCourseNode)) {
        Identity assessedIdentity = entry.getIdentity();
        Integer attempts = assessmentManager.getNodeAttempts(node, assessedIdentity);
        if ((attempts == null && entry.getAttempts() == null) || (attempts != null && entry.getAttempts() != null && attempts.equals(entry.getAttempts()))) {
        // ok
        } else {
            log.audit("ERROR number of attempts: " + attempts + " / " + entry.getAttempts() + getErrorAt(courseEntry, node));
            allOk &= false;
        }
        Boolean passed = assessmentManager.getNodePassed(node, assessedIdentity);
        if ((passed == null && entry.getPassed() == null) || (passed != null && entry.getPassed() != null && passed.equals(entry.getPassed()))) {
        // ok
        } else {
            log.audit("ERROR passed: " + passed + " / " + entry.getPassed() + getErrorAt(courseEntry, node));
            allOk &= false;
        }
        Boolean fullyAssessed = assessmentManager.getNodeFullyAssessed(node, assessedIdentity);
        if ((fullyAssessed == null && entry.getFullyAssessed() == null) || (fullyAssessed != null && entry.getFullyAssessed() != null && fullyAssessed.equals(entry.getFullyAssessed()))) {
        // ok
        } else {
            log.audit("ERROR fullyAssessed: " + fullyAssessed + " / " + entry.getFullyAssessed() + getErrorAt(courseEntry, node));
            allOk &= false;
        }
        Float score = assessmentManager.getNodeScore(node, assessedIdentity);
        if ((score == null && entry.getScore() == null) || (score != null && entry.getScore() != null && Math.abs(score.floatValue() - entry.getScore().floatValue()) < 0.00001f)) {
        // ok
        } else {
            log.audit("ERROR score: " + score + " / " + entry.getScore() + getErrorAt(courseEntry, node));
            allOk &= false;
        }
    }
    return allOk;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) STCourseNode(org.olat.course.nodes.STCourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity)

Example 19 with CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

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 CourseEditorTreeNode

use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.

the class PublishProcess method checkRefs.

/**
 * Checks references of coursenodes.
 *
 * @param courseEditorTreeNodes
 * @return boolean
 */
private List<StatusDescription> checkRefs(List<CourseEditorTreeNode> courseEditorTreeNodes) {
    // course Editor Nodes With Damaged Reference
    List<StatusDescription> cetnDamaged = new ArrayList<StatusDescription>();
    for (Iterator<CourseEditorTreeNode> iter = courseEditorTreeNodes.iterator(); iter.hasNext(); ) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        /*
			 * for those coursenodes which need a reference to a repository entry to
			 * function properly, check that the reference is valid
			 */
        if (cn.needsReferenceToARepositoryEntry()) {
            RepositoryEntry referencedEntry = cn.getReferencedRepositoryEntry();
            if (referencedEntry == null) {
                cetnDamaged.add(new StatusDescription(ValidationStatus.ERROR, "pbl.error.refs", "pbl.error.refs", new String[] { cetn.getTitle() + "(id:" + cetn.getIdent() + " )" }, PACKAGE));
            }
        }
    }
    return cetnDamaged;
}
Also used : ArrayList(java.util.ArrayList) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)88 CourseNode (org.olat.course.nodes.CourseNode)54 ICourse (org.olat.course.ICourse)38 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)24 INode (org.olat.core.util.nodes.INode)22 Test (org.junit.Test)20 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Identity (org.olat.core.id.Identity)14 TreeVisitor (org.olat.core.util.tree.TreeVisitor)14 Visitor (org.olat.core.util.tree.Visitor)14 CourseNodeVO (org.olat.restapi.support.vo.CourseNodeVO)12 TreeNode (org.olat.core.gui.components.tree.TreeNode)10 STCourseNode (org.olat.course.nodes.STCourseNode)10 ArrayList (java.util.ArrayList)9 File (java.io.File)8 URI (java.net.URI)8 HttpResponse (org.apache.http.HttpResponse)8 HttpPut (org.apache.http.client.methods.HttpPut)8 Structure (org.olat.course.Structure)8 BCCourseNode (org.olat.course.nodes.BCCourseNode)8