Search in sources :

Example 11 with GenericTreeNode

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);
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)

Example 12 with GenericTreeNode

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;
}
Also used : BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)

Example 13 with GenericTreeNode

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;
}
Also used : XPath(org.dom4j.XPath) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) Element(org.dom4j.Element)

Example 14 with GenericTreeNode

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;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode)

Example 15 with GenericTreeNode

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;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) HashMap(java.util.HashMap) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) ArrayList(java.util.ArrayList) TaxonomyLevelRow(org.olat.modules.taxonomy.ui.TaxonomyLevelRow)

Aggregations

GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)124 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)24 CourseNode (org.olat.course.nodes.CourseNode)10 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)10 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)10 HashMap (java.util.HashMap)8 INode (org.olat.core.util.nodes.INode)8 ArrayList (java.util.ArrayList)6 Element (org.dom4j.Element)6 XPath (org.dom4j.XPath)6 ExtManager (org.olat.core.extensions.ExtManager)6 Extension (org.olat.core.extensions.Extension)6 CatalogEntry (org.olat.repository.CatalogEntry)6 ActionExtension (org.olat.core.extensions.action.ActionExtension)4 GenericActionExtension (org.olat.core.extensions.action.GenericActionExtension)4 CourseNodeConfiguration (org.olat.course.nodes.CourseNodeConfiguration)4 QTI21QuestionType (org.olat.ims.qti21.model.QTI21QuestionType)4 Taxonomy (org.olat.modules.taxonomy.Taxonomy)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4