Search in sources :

Example 16 with TreeVisitor

use of org.olat.core.util.tree.TreeVisitor in project openolat by klemens.

the class ScoreAccounting method evaluateAll.

public boolean evaluateAll(boolean update) {
    Identity identity = userCourseEnvironment.getIdentityEnvironment().getIdentity();
    List<AssessmentEntry> entries = userCourseEnvironment.getCourseEnvironment().getAssessmentManager().getAssessmentEntries(identity);
    AssessableTreeVisitor visitor = new AssessableTreeVisitor(entries, update);
    // collect all assessable nodes and eval 'em
    CourseNode root = userCourseEnvironment.getCourseEnvironment().getRunStructure().getRootNode();
    // breadth first traversal gives an easier order of evaluation for debugging
    // however, for live it is absolutely mandatory to use depth first since using breadth first
    // the score accoutings local cache hash map will never be used. this can slow down things like
    // crazy (course with 10 tests, 300 users and some crazy score and passed calculations will have
    // 10 time performance differences)
    cachedScoreEvals.clear();
    for (AssessmentEntry entry : entries) {
        String nodeIdent = entry.getSubIdent();
        CourseNode courseNode = userCourseEnvironment.getCourseEnvironment().getRunStructure().getNode(nodeIdent);
        if (courseNode instanceof AssessableCourseNode) {
            AssessableCourseNode acn = (AssessableCourseNode) courseNode;
            AssessmentEvaluation se = AssessmentEvaluation.toAssessmentEvalutation(entry, acn);
            cachedScoreEvals.put(acn, se);
        }
    }
    // true=depth first
    TreeVisitor tv = new TreeVisitor(visitor, root, true);
    tv.visitAll();
    return visitor.hasChanges();
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) PersistentAssessableCourseNode(org.olat.course.nodes.PersistentAssessableCourseNode) CalculatedAssessableCourseNode(org.olat.course.nodes.CalculatedAssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) PersistentAssessableCourseNode(org.olat.course.nodes.PersistentAssessableCourseNode) CalculatedAssessableCourseNode(org.olat.course.nodes.CalculatedAssessableCourseNode) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 17 with TreeVisitor

use of org.olat.core.util.tree.TreeVisitor in project openolat by klemens.

the class HomeCalendarManager method isCourseCalendarEnabled.

private boolean isCourseCalendarEnabled(ICourse course) {
    if (course.getCourseConfig().isCalendarEnabled()) {
        return true;
    }
    CourseNode rootNode = course.getRunStructure().getRootNode();
    CalCourseNodeVisitor v = new CalCourseNodeVisitor();
    new TreeVisitor(v, rootNode, true).visitAll();
    return v.isFound();
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) CourseNode(org.olat.course.nodes.CourseNode) CalCourseNode(org.olat.course.nodes.CalCourseNode)

Example 18 with TreeVisitor

use of org.olat.core.util.tree.TreeVisitor in project openolat by klemens.

the class ForumArchiveManager method formatForum.

/**
 * @param topNodeList
 * @param forumFormatter
 * @param metaInfo
 * @return
 */
private String formatForum(List<MessageNode> topNodeList, ForumFormatter forumFormatter, Long forumId) {
    forumFormatter.setForumKey(forumId);
    StringBuilder formattedForum = new StringBuilder();
    forumFormatter.openForum();
    for (Iterator<MessageNode> iterTop = topNodeList.iterator(); iterTop.hasNext(); ) {
        MessageNode mn = iterTop.next();
        // a new top thread starts, inform formatter
        forumFormatter.openThread();
        TreeVisitor tv = new TreeVisitor(forumFormatter, mn, false);
        tv.visitAll();
        // commit
        formattedForum.append(forumFormatter.closeThread());
    }
    return formattedForum.append(forumFormatter.closeForum().toString()).toString();
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor)

Example 19 with TreeVisitor

use of org.olat.core.util.tree.TreeVisitor in project openolat by klemens.

the class CourseEditorEnvImpl method validateCourse.

/**
 * @see org.olat.course.editor.CourseEditorEnv#validateCourse()
 */
@Override
public void validateCourse() {
    /*
		 * collect all condition error messages and soft references collect all
		 * configuration errors.
		 */
    String currentNodeWas = currentCourseNodeId;
    // reset all
    softRefs = new HashMap<String, List<ConditionExpression>>();
    Visitor v = new CollectConditionExpressionsVisitor();
    (new TreeVisitor(v, cetm.getRootNode(), true)).visitAll();
    // refresh,create status descriptions of the course
    statusDescs = new HashMap<String, List<StatusDescription>>();
    v = new CollectStatusDescriptionVisitor(this);
    (new TreeVisitor(v, cetm.getRootNode(), true)).visitAll();
    // 
    currentCourseNodeId = currentNodeWas;
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) ArrayList(java.util.ArrayList) List(java.util.List)

Example 20 with TreeVisitor

use of org.olat.core.util.tree.TreeVisitor in project openolat by klemens.

the class CourseEditorEnvImpl method checkFolderNodes.

private List<StatusDescription> checkFolderNodes(INode rootNode, ICourse course, List<StatusDescription> descriptions) {
    List<StatusDescription> descriptionsI = descriptions;
    Visitor visitor = new Visitor() {

        @Override
        public void visit(INode node) {
            CourseEditorTreeNode courseNode = (CourseEditorTreeNode) course.getEditorTreeModel().getNodeById(node.getIdent());
            if (!courseNode.isDeleted() && courseNode.getCourseNode() instanceof BCCourseNode) {
                BCCourseNode bcNode = (BCCourseNode) courseNode.getCourseNode();
                if (bcNode.isSharedFolder()) {
                    String translPackage = Util.getPackageName(BCCourseNodeEditController.class);
                    StatusDescription status = new StatusDescription(StatusDescription.ERROR, "warning.no.sharedfolder", "warning.no.sharedfolder", null, translPackage);
                    status.setDescriptionForUnit(bcNode.getIdent());
                    // set which pane is affected by error
                    status.setActivateableViewIdentifier(BCCourseNodeEditController.PANE_TAB_FOLDER);
                    descriptionsI.add(status);
                }
            }
        }
    };
    TreeVisitor v = new TreeVisitor(visitor, rootNode, false);
    v.visitAll();
    return descriptionsI;
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) INode(org.olat.core.util.nodes.INode) BCCourseNode(org.olat.course.nodes.BCCourseNode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode)

Aggregations

TreeVisitor (org.olat.core.util.tree.TreeVisitor)52 Visitor (org.olat.core.util.tree.Visitor)42 INode (org.olat.core.util.nodes.INode)30 CourseNode (org.olat.course.nodes.CourseNode)24 ArrayList (java.util.ArrayList)14 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)14 Identity (org.olat.core.id.Identity)10 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)10 ICourse (org.olat.course.ICourse)7 File (java.io.File)6 HashMap (java.util.HashMap)6 List (java.util.List)6 BCCourseNode (org.olat.course.nodes.BCCourseNode)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)5 STCourseNode (org.olat.course.nodes.STCourseNode)5 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)5 TACourseNode (org.olat.course.nodes.TACourseNode)5 IOException (java.io.IOException)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 CorruptedCourseException (org.olat.course.CorruptedCourseException)4