Search in sources :

Example 1 with TreeWalkNodeHandler

use of uk.ac.ed.ph.jqtiplus.utils.TreeWalkNodeHandler in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doExportPool.

private void doExportPool() {
    TreeNode selectedNode = menuTree.getSelectedNode();
    if (selectedNode == null)
        return;
    AtomicInteger counter = new AtomicInteger();
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof AssessmentItemRef) {
        doExportPool((AssessmentItemRef) uobject);
        counter.incrementAndGet();
    } else if (uobject instanceof QtiNode) {
        QtiNode qtiNode = (QtiNode) uobject;
        QueryUtils.walkTree(new TreeWalkNodeHandler() {

            @Override
            public boolean handleNode(QtiNode node) {
                if (node instanceof AssessmentItemRef) {
                    doExportPool((AssessmentItemRef) node);
                    counter.incrementAndGet();
                }
                return true;
            }
        }, qtiNode);
    }
    if (counter.get() > 0) {
        showInfo("export.qpool.successful", counter.toString());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TreeWalkNodeHandler(uk.ac.ed.ph.jqtiplus.utils.TreeWalkNodeHandler) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Example 2 with TreeWalkNodeHandler

use of uk.ac.ed.ph.jqtiplus.utils.TreeWalkNodeHandler in project openolat by klemens.

the class AssessmentTestComposerController method doExportPool.

private void doExportPool() {
    TreeNode selectedNode = menuTree.getSelectedNode();
    if (selectedNode == null)
        return;
    AtomicInteger counter = new AtomicInteger();
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof AssessmentItemRef) {
        doExportPool((AssessmentItemRef) uobject);
        counter.incrementAndGet();
    } else if (uobject instanceof QtiNode) {
        QtiNode qtiNode = (QtiNode) uobject;
        QueryUtils.walkTree(new TreeWalkNodeHandler() {

            @Override
            public boolean handleNode(QtiNode node) {
                if (node instanceof AssessmentItemRef) {
                    doExportPool((AssessmentItemRef) node);
                    counter.incrementAndGet();
                }
                return true;
            }
        }, qtiNode);
    }
    if (counter.get() > 0) {
        showInfo("export.qpool.successful", counter.toString());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TreeWalkNodeHandler(uk.ac.ed.ph.jqtiplus.utils.TreeWalkNodeHandler) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 QtiNode (uk.ac.ed.ph.jqtiplus.node.QtiNode)2 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)2 TreeWalkNodeHandler (uk.ac.ed.ph.jqtiplus.utils.TreeWalkNodeHandler)2