use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.
the class AssessmentTestEditorAndComposerTreeModel method buildRecursively.
private void buildRecursively(TestPart part, int pos, TreeNode parentNode) {
GenericTreeNode partNode = new GenericTreeNode(part.getIdentifier().toString());
partNode.setTitle(pos + ". Test part");
partNode.setIconCssClass("o_icon o_qtiassessment_icon");
partNode.setUserObject(part);
parentNode.addChild(partNode);
List<AssessmentSection> sections = part.getAssessmentSections();
for (AssessmentSection section : sections) {
buildRecursively(section, partNode);
}
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.
the class AssessmentTestEditorAndComposerTreeModel method buildRecursively.
private TreeNode buildRecursively(AssessmentItemRef itemRef, TreeNode parentNode) {
GenericTreeNode itemNode = new GenericTreeNode(itemRef.getIdentifier().toString());
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (resolvedAssessmentItem == null || resolvedAssessmentItem.getItemLookup() == null || resolvedAssessmentItem.getItemLookup().getRootNodeHolder() == null) {
itemNode.setTitle("ERROR - Not found");
itemNode.setIconCssClass("o_icon o_icon_error");
itemNode.setUserObject(itemRef);
parentNode.addChild(itemNode);
} else {
BadResourceException ex = resolvedAssessmentItem.getItemLookup().getBadResourceException();
if (ex != null) {
itemNode.setTitle("ERROR");
itemNode.setIconCssClass("o_icon o_icon_error");
itemNode.setUserObject(itemRef);
parentNode.addChild(itemNode);
} else {
AssessmentItem assessmentItem = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
itemNode.setTitle(assessmentItem.getTitle());
QTI21QuestionType type = QTI21QuestionType.getType(assessmentItem);
if (type != null) {
itemNode.setIconCssClass("o_icon ".concat(type.getCssClass()));
} else {
itemNode.setIconCssClass("o_icon o_mi_qtiunkown");
}
itemNode.setUserObject(itemRef);
parentNode.addChild(itemNode);
}
}
return itemNode;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.
the class ScormCPManifestTreeModel method buildNode.
private GenericTreeNode buildNode(Element item) {
GenericTreeNode treeNode = new GenericTreeNode();
// extract title
String title = item.elementText("title");
if (title == null)
title = item.attributeValue("identifier");
treeNode.setAltText(title);
treeNode.setTitle(title);
if (item.getName().equals("organization")) {
treeNode.setIconCssClass("o_scorm_org");
treeNode.setAccessible(false);
} else if (item.getName().equals("item")) {
scormIdToNode.put(new Integer(nodeId).toString(), treeNode);
nodeToId.put(treeNode, new Integer(nodeId));
// set node images according to scorm sco status
String itemStatusDesc = itemStatus.get(Integer.toString(nodeId));
treeNode.setIconCssClass("o_scorm_item");
if (itemStatusDesc != null && !"not_attempted".equals(itemStatusDesc)) {
// add icon decorator for current status
String decorator = "o_scorm_" + itemStatusDesc;
treeNode.setIconDecorator1CssClass(decorator);
}
nodeId++;
// set resolved file path directly
String identifierref = item.attributeValue("identifierref");
XPath meta = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
meta.setNamespaceURIs(nsuris);
String href = resources.get(identifierref);
if (href != null) {
treeNode.setUserObject(href);
// allow lookup of a treenode given a href so we can quickly adjust the menu if the user clicks on hyperlinks within the text
hrefToTreeNode.put(href, treeNode);
} else
treeNode.setAccessible(false);
}
List<Element> chds = item.elements("item");
int childcnt = chds.size();
for (int i = 0; i < childcnt; i++) {
Element childitem = chds.get(i);
GenericTreeNode gtnchild = buildNode(childitem);
treeNode.addChild(gtnchild);
}
return treeNode;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.
the class ScormCPManifestTreeModel method buildTreeNodes.
private GenericTreeNode buildTreeNodes(List<Element> organizations) {
GenericTreeNode gtn = new GenericTreeNode();
// 0 is a valid index since List is testet be be not empty above
String rootNode = organizations.get(0).getParent().elementText("default");
// if only one organization avoid too much hierarchy levels...
if (organizations.size() == 1) {
return buildNode(organizations.get(0));
}
// FIXME: localize "Content:"
gtn.setTitle((rootNode == null) ? "Content:" : rootNode);
gtn.setIconCssClass("o_scorm_org");
gtn.setAccessible(false);
for (int i = 0; i < organizations.size(); ++i) {
GenericTreeNode gtnchild = buildNode(organizations.get(i));
gtn.addChild(gtnchild);
}
return gtn;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.
the class TaxonomyAllTreesBuilder method toTree.
public List<TaxonomyLevelRow> toTree(List<TaxonomyLevelRow> taxonomyLevels) {
GenericTreeNode rootNode = new GenericTreeNode();
Map<Long, GenericTreeNode> fieldKeyToNode = new HashMap<Long, GenericTreeNode>();
for (TaxonomyLevelRow taxonomyLevel : taxonomyLevels) {
Long key = taxonomyLevel.getKey();
GenericTreeNode node = fieldKeyToNode.get(key);
if (node == null) {
node = new GenericTreeNode(nodeKey(taxonomyLevel));
node.setUserObject(taxonomyLevel);
fieldKeyToNode.put(key, node);
}
TaxonomyLevelRow parentLevel = taxonomyLevel.getParent();
if (parentLevel == null) {
// this is a root
rootNode.addChild(node);
} else {
Long parentKey = parentLevel.getKey();
GenericTreeNode parentNode = fieldKeyToNode.get(parentKey);
if (parentNode == null) {
parentNode = new GenericTreeNode("level-" + parentLevel.getKey());
parentNode.setUserObject(parentLevel);
fieldKeyToNode.put(parentKey, parentNode);
}
parentNode.addChild(node);
}
}
List<TreeNode> nodeList = new ArrayList<>();
TreeHelper.makeTreeFlat(rootNode, nodeList);
List<TaxonomyLevelRow> sortedRows = new ArrayList<>();
for (TreeNode node : nodeList) {
if (node.getUserObject() != null) {
sortedRows.add((TaxonomyLevelRow) node.getUserObject());
}
}
return sortedRows;
}
Aggregations