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();
}
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();
}
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();
}
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;
}
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;
}
Aggregations