Search in sources :

Example 26 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (event instanceof AssessmentTestEvent) {
        AssessmentTestEvent ate = (AssessmentTestEvent) event;
        if (ate == AssessmentTestEvent.ASSESSMENT_TEST_CHANGED_EVENT) {
            doSaveAssessmentTest(ureq, null);
        }
    } else if (event instanceof AssessmentTestPartEvent) {
        AssessmentTestPartEvent atpe = (AssessmentTestPartEvent) event;
        if (atpe == AssessmentTestPartEvent.ASSESSMENT_TEST_PART_CHANGED_EVENT) {
            doSaveAssessmentTest(ureq, null);
        }
    } else if (event instanceof AssessmentSectionEvent) {
        AssessmentSectionEvent ase = (AssessmentSectionEvent) event;
        if (AssessmentSectionEvent.ASSESSMENT_SECTION_CHANGED.equals(ase.getCommand())) {
            doSaveAssessmentTest(ureq, null);
            doUpdate(ase.getSection().getIdentifier(), ase.getSection().getTitle());
            doSaveManifest();
        }
    } else if (event instanceof AssessmentItemEvent) {
        AssessmentItemEvent aie = (AssessmentItemEvent) event;
        if (AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED.equals(aie.getCommand())) {
            assessmentChanged(ureq);
            doSaveAssessmentTest(ureq, null);
            doUpdate(aie.getAssessmentItemRef().getIdentifier(), aie.getAssessmentItem().getTitle());
            doSaveManifest();
        } else if (AssessmentItemEvent.ASSESSMENT_ITEM_METADATA_CHANGED.equals(aie.getCommand())) {
            doSaveManifest();
        } else if (AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD.equals(aie.getCommand())) {
            doReloadItem(ureq);
        }
    } else if (event instanceof DetachFromPoolEvent) {
        DetachFromPoolEvent dfpe = (DetachFromPoolEvent) event;
        doDetachItemFromPool(ureq, dfpe.getItemRef());
    } else if (selectQItemCtrl == source) {
        cmc.deactivate();
        cleanUp();
        if (event instanceof QItemViewEvent) {
            QItemViewEvent e = (QItemViewEvent) event;
            List<QuestionItemView> items = e.getItemList();
            doInsert(ureq, items);
        }
    } else if (importTableWizard == source) {
        AssessmentItemsPackage importPackage = (AssessmentItemsPackage) importTableWizard.getRunContext().get("importPackage");
        getWindowControl().pop();
        cleanUp();
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            doInsert(ureq, importPackage);
        }
    } else if (confirmDeleteCtrl == source) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            // yes, delete
            doDelete(ureq, (TreeNode) confirmDeleteCtrl.getUserObject());
        }
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : AssessmentTestEvent(org.olat.ims.qti21.ui.editor.events.AssessmentTestEvent) DetachFromPoolEvent(org.olat.ims.qti21.ui.editor.events.DetachFromPoolEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentItemsPackage(org.olat.ims.qti21.questionimport.AssessmentItemsPackage) ArrayList(java.util.ArrayList) List(java.util.List) QItemViewEvent(org.olat.modules.qpool.ui.events.QItemViewEvent) AssessmentSectionEvent(org.olat.ims.qti21.ui.editor.events.AssessmentSectionEvent) AssessmentTestPartEvent(org.olat.ims.qti21.ui.editor.events.AssessmentTestPartEvent) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 27 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doDrop.

private void doDrop(UserRequest ureq, String droppedNodeId, String targetnodeId, boolean asChild) {
    TreeNode droppedNode = menuTree.getTreeModel().getNodeById(droppedNodeId);
    TreeNode targetNode = menuTree.getTreeModel().getNodeById(targetnodeId);
    if (droppedNode == null || targetNode == null)
        return;
    Object droppedObject = droppedNode.getUserObject();
    Object targetObject = targetNode.getUserObject();
    if (droppedObject == null || targetObject == null || droppedObject == targetObject)
        return;
    if (asChild) {
        if (droppedObject instanceof AssessmentItemRef && (targetObject instanceof AssessmentSection || targetObject instanceof AssessmentItemRef)) {
            AssessmentItemRef droppedItemRef = (AssessmentItemRef) droppedObject;
            droppedItemRef.getParentSection().getSectionParts().remove(droppedItemRef);
            if (targetObject instanceof AssessmentSection) {
                AssessmentSection targetSection = (AssessmentSection) targetObject;
                targetSection.getSectionParts().add(droppedItemRef);
            } else if (targetObject instanceof AssessmentItemRef) {
                AssessmentItemRef targetItemRef = (AssessmentItemRef) targetObject;
                AssessmentSection targetSection = targetItemRef.getParentSection();
                int pos = targetSection.getChildAbstractParts().indexOf(targetItemRef);
                targetSection.getChildAbstractParts().add(pos, droppedItemRef);
            }
        } else if (droppedObject instanceof AssessmentSection && (targetObject instanceof AssessmentSection || targetObject instanceof TestPart || (targetObject instanceof AssessmentTest && ((AssessmentTest) targetObject).getTestParts().size() == 1))) {
            AssessmentSection droppedSection = (AssessmentSection) droppedObject;
            if (droppedSection.getParentSection() != null) {
                droppedSection.getParentSection().getSectionParts().remove(droppedSection);
            } else {
                droppedSection.getParent().getChildAbstractParts().remove(droppedSection);
            }
            if (targetObject instanceof AssessmentSection) {
                AssessmentSection targetSection = (AssessmentSection) targetObject;
                targetSection.getChildAbstractParts().add(droppedSection);
            } else if (targetObject instanceof TestPart) {
                TestPart targetTestPart = (TestPart) targetObject;
                targetTestPart.getAssessmentSections().add(droppedSection);
            } else if (targetObject instanceof AssessmentTest) {
                TestPart targetTestPart = ((AssessmentTest) targetObject).getTestParts().get(0);
                targetTestPart.getAssessmentSections().add(droppedSection);
            }
        }
    } else {
        if (droppedObject instanceof AssessmentItemRef && targetObject instanceof AssessmentItemRef) {
            AssessmentItemRef droppedItemRef = (AssessmentItemRef) droppedObject;
            droppedItemRef.getParentSection().getSectionParts().remove(droppedItemRef);
            AssessmentItemRef targetItemRef = (AssessmentItemRef) targetObject;
            AssessmentSection targetSection = targetItemRef.getParentSection();
            int pos = targetSection.getChildAbstractParts().indexOf(targetItemRef) + 1;
            if (pos < 0) {
                targetSection.getChildAbstractParts().add(droppedItemRef);
            } else if (pos >= targetSection.getChildAbstractParts().size()) {
                targetSection.getChildAbstractParts().add(droppedItemRef);
            } else {
                targetSection.getChildAbstractParts().add(pos, droppedItemRef);
            }
        } else if (droppedObject instanceof AssessmentSection && targetObject instanceof AssessmentSection) {
            AssessmentSection droppedSection = (AssessmentSection) droppedObject;
            if (droppedSection.getParentSection() != null) {
                droppedSection.getParentSection().getSectionParts().remove(droppedSection);
            } else {
                droppedSection.getParent().getChildAbstractParts().remove(droppedSection);
            }
            AssessmentSection targetSection = (AssessmentSection) targetObject;
            if (targetSection.getParentSection() != null) {
                AssessmentSection targetParentSection = targetSection.getParentSection();
                int pos = targetParentSection.getChildAbstractParts().indexOf(targetSection) + 1;
                if (pos >= targetParentSection.getChildAbstractParts().size()) {
                    targetParentSection.getChildAbstractParts().add(droppedSection);
                } else {
                    targetParentSection.getChildAbstractParts().add(pos, droppedSection);
                }
            } else if (targetSection.getParent() instanceof TestPart) {
                TestPart targetTestPart = (TestPart) targetSection.getParent();
                int pos = targetTestPart.getChildAbstractParts().indexOf(targetSection) + 1;
                if (pos >= targetTestPart.getChildAbstractParts().size()) {
                    targetTestPart.getChildAbstractParts().add(droppedSection);
                } else {
                    targetTestPart.getChildAbstractParts().add(pos, droppedSection);
                }
            }
        }
    }
    // quickly saved the assessment test with wrong parent
    doSaveAssessmentTest(ureq, null);
    // reload a clean instance
    updateTreeModel(false);
    TreeNode droppedItemNode = menuTree.getTreeModel().getNodeById(droppedNode.getIdent());
    if (droppedItemNode != null) {
        menuTree.setSelectedNode(droppedItemNode);
        menuTree.open(droppedItemNode);
        partEditorFactory(ureq, droppedItemNode);
    }
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)

Example 28 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doNewTestPart.

/**
 * Create a new test part and a section. Test part need a section,
 * section ref as children, it's mandatory.
 *
 * @param ureq
 */
private void doNewTestPart(UserRequest ureq) {
    TestPart testPart = AssessmentTestFactory.createTestPart(assessmentTestBuilder.getAssessmentTest());
    AssessmentTestFactory.appendAssessmentSection(translate("new.section"), testPart);
    // save the test
    doSaveAssessmentTest(ureq, null);
    // reload the test
    updateTreeModel(false);
    TreeNode newTestPartNode = menuTree.getTreeModel().getNodeById(testPart.getIdentifier().toString());
    menuTree.setSelectedNode(newTestPartNode);
    menuTree.open(newTestPartNode);
    partEditorFactory(ureq, newTestPartNode);
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Example 29 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doNewSection.

private void doNewSection(UserRequest ureq, TreeNode selectedNode) {
    AbstractPart parentPart;
    TreeNode sectionNode = getNearestSection(selectedNode);
    if (sectionNode != null) {
        AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
        parentPart = section.getParent();
    } else if (selectedNode.getUserObject() instanceof TestPart) {
        parentPart = (TestPart) selectedNode.getUserObject();
    } else {
        TreeNode rootNode = menuTree.getTreeModel().getRootNode();
        AssessmentTest assessmentTest = (AssessmentTest) rootNode.getUserObject();
        List<TestPart> parts = assessmentTest.getTestParts();
        if (parts != null && parts.size() > 0) {
            parentPart = parts.get(0);
        } else {
            showWarning("error.cannot.create.section");
            return;
        }
    }
    AssessmentSection newSection;
    if (parentPart instanceof TestPart) {
        newSection = AssessmentTestFactory.appendAssessmentSection(translate("new.section"), (TestPart) parentPart);
    } else if (parentPart instanceof AssessmentSection) {
        newSection = AssessmentTestFactory.appendAssessmentSection(translate("new.section"), (AssessmentSection) parentPart);
    } else {
        showWarning("error.cannot.create.section");
        return;
    }
    // save the test
    URI testUri = resolvedAssessmentTest.getTestLookup().getSystemId();
    File testFile = new File(testUri);
    qtiService.updateAssesmentObject(testFile, resolvedAssessmentTest);
    assessmentChanged(ureq);
    // reload the test
    updateTreeModel(false);
    TreeNode newSectionNode = menuTree.getTreeModel().getNodeById(newSection.getIdentifier().toString());
    menuTree.setSelectedNode(newSectionNode);
    menuTree.open(newSectionNode);
    partEditorFactory(ureq, newSectionNode);
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AbstractPart(uk.ac.ed.ph.jqtiplus.node.test.AbstractPart) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) ArrayList(java.util.ArrayList) List(java.util.List) URI(java.net.URI) File(java.io.File)

Example 30 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class QTI21StatisticResourceResult method getController.

public Controller getController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, TreeNode selectedNode, boolean printMode) {
    if (selectedNode instanceof StatisticResourceNode) {
        return createAssessmentController(ureq, wControl, stackPanel, printMode);
    } else {
        Object uobject = selectedNode.getUserObject();
        if (uobject instanceof AssessmentItemRef) {
            TreeNode parentNode = (TreeNode) selectedNode.getParent();
            String sectionTitle = parentNode.getTitle();
            return createAssessmentItemController(ureq, wControl, (AssessmentItemRef) uobject, sectionTitle, printMode);
        } else if (uobject instanceof AssessmentTest) {
            return createAssessmentController(ureq, wControl, stackPanel, printMode);
        }
    }
    return null;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) StatisticResourceNode(org.olat.course.statistic.StatisticResourceNode) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)

Aggregations

TreeNode (org.olat.core.gui.components.tree.TreeNode)296 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)146 ArrayList (java.util.ArrayList)44 CourseNode (org.olat.course.nodes.CourseNode)38 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)32 ContextEntry (org.olat.core.id.context.ContextEntry)30 Controller (org.olat.core.gui.control.Controller)28 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)24 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)22 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)20 INode (org.olat.core.util.nodes.INode)20 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)20 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)20 ICourse (org.olat.course.ICourse)18 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)16 OLATResourceable (org.olat.core.id.OLATResourceable)16 List (java.util.List)14 TreeModel (org.olat.core.gui.components.tree.TreeModel)14 WindowControl (org.olat.core.gui.control.WindowControl)14 AssertException (org.olat.core.logging.AssertException)14