Search in sources :

Example 6 with GenericQtiNode

use of org.olat.ims.qti.editor.tree.GenericQtiNode in project openolat by klemens.

the class QTIEditorMainController method doConvertItemToQtiNode.

private GenericQtiNode doConvertItemToQtiNode(QuestionItemView qitemv) {
    VFSContainer editorContainer = qtiPackage.getBaseDir();
    Item theItem = qtiQpoolServiceProvider.exportToQTIEditor(qitemv, editorContainer);
    GenericQtiNode node = new ItemNode(theItem, qtiPackage);
    return node;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode)

Example 7 with GenericQtiNode

use of org.olat.ims.qti.editor.tree.GenericQtiNode in project openolat by klemens.

the class QTIEditorMainController method doMove.

private void doMove(TreePosition tp) {
    // user chose a position to insert a new node
    GenericQtiNode parentTargetNode = (GenericQtiNode) tp.getParentTreeNode();
    int targetPos = tp.getChildpos();
    GenericQtiNode selectedNode = (GenericQtiNode) menuTree.getSelectedNode();
    int selectedPos = selectedNode.getPosition();
    GenericQtiNode parentSelectedNode = (GenericQtiNode) selectedNode.getParent();
    if (parentTargetNode == parentSelectedNode) {
        // if we're on the same subnode
        if (targetPos > selectedNode.getPosition()) {
            // if we're moving after our current position
            targetPos--;
        // decrease insert pos since we're going to be removed from the
        // parent before re-insert
        }
    }
    // insert into menutree (insert on GenericNode do a remove from parent)
    parentTargetNode.insert(selectedNode, targetPos);
    // insert into model (remove from parent needed prior to insert)
    QTIObject subject = parentSelectedNode.removeQTIObjectAt(selectedPos);
    parentTargetNode.insertQTIObjectAt(subject, targetPos);
    qtiPackage.serializeQTIDocument();
    parentSelectedNode.childNodeChanges();
    parentTargetNode.childNodeChanges();
}
Also used : QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode)

Example 8 with GenericQtiNode

use of org.olat.ims.qti.editor.tree.GenericQtiNode in project openolat by klemens.

the class QTIEditorMainController method doDelete.

private void doDelete(GenericQtiNode clickedNode) {
    // check if any media to delete as well
    if (clickedNode.getUnderlyingQTIObject() instanceof Item) {
        Item selectedItem = (Item) clickedNode.getUnderlyingQTIObject();
        deletableMediaFiles = QTIEditHelper.getDeletableMedia(qtiPackage.getQTIDocument(), selectedItem);
    }
    // remove from underlying model
    GenericQtiNode parentNode = (GenericQtiNode) clickedNode.getParent();
    parentNode.removeQTIObjectAt(clickedNode.getPosition());
    // remove from tree model
    clickedNode.removeFromParent();
    qtiPackage.serializeQTIDocument();
    menuTree.setSelectedNodeId(clickedNode.getParent().getIdent());
    parentNode.childNodeChanges();
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode)

Example 9 with GenericQtiNode

use of org.olat.ims.qti.editor.tree.GenericQtiNode in project openolat by klemens.

the class QTIEditorMainController method doInsert.

private void doInsert(UserRequest ureq, TreePosition tp, Object toInsert) {
    // new node
    GenericQtiNode parentTargetNode = (GenericQtiNode) tp.getParentTreeNode();
    if (toInsert instanceof GenericQtiNode) {
        doInsert(parentTargetNode, (GenericQtiNode) toInsert, tp.getChildpos());
    } else if (toInsert instanceof QuestionItemView) {
        QuestionItemView item = (QuestionItemView) toInsert;
        GenericQtiNode insertNode = doConvertItemToQtiNode(item);
        doInsert(parentTargetNode, insertNode, tp.getChildpos());
    } else if (toInsert instanceof Collection) {
        int position = tp.getChildpos();
        @SuppressWarnings("unchecked") Collection<QuestionItemView> items = (Collection<QuestionItemView>) toInsert;
        for (QuestionItemView item : items) {
            GenericQtiNode insertNode = doConvertItemToQtiNode(item);
            doInsert(parentTargetNode, insertNode, position++);
        }
    } else if (toInsert instanceof ItemsPackage) {
        ItemsPackage itemsToImport = (ItemsPackage) toInsert;
        List<ItemAndMetadata> items = itemsToImport.getItems();
        int pos = tp.getChildpos();
        for (ItemAndMetadata item : items) {
            GenericQtiNode insertNode = new ItemNode(item.getItem(), qtiPackage);
            doInsert(parentTargetNode, insertNode, pos++);
        }
    }
    event(ureq, menuTree, new Event(MenuTree.COMMAND_TREENODE_CLICKED));
    qtiPackage.serializeQTIDocument();
    updateWarning();
}
Also used : ItemNode(org.olat.ims.qti.editor.tree.ItemNode) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode) Collection(java.util.Collection) QItemViewEvent(org.olat.modules.qpool.ui.events.QItemViewEvent) Event(org.olat.core.gui.control.Event) ArrayList(java.util.ArrayList) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) QuestionItemView(org.olat.modules.qpool.QuestionItemView) ItemsPackage(org.olat.ims.qti.questionimport.ItemsPackage)

Example 10 with GenericQtiNode

use of org.olat.ims.qti.editor.tree.GenericQtiNode in project OpenOLAT by OpenOLAT.

the class QTIEditorMainController method doConvertItemToQtiNode.

private GenericQtiNode doConvertItemToQtiNode(QuestionItemView qitemv) {
    VFSContainer editorContainer = qtiPackage.getBaseDir();
    Item theItem = qtiQpoolServiceProvider.exportToQTIEditor(qitemv, editorContainer);
    GenericQtiNode node = new ItemNode(theItem, qtiPackage);
    return node;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode)

Aggregations

GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)16 Item (org.olat.ims.qti.editor.beecom.objects.Item)10 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)10 Event (org.olat.core.gui.control.Event)6 QItemViewEvent (org.olat.modules.qpool.ui.events.QItemViewEvent)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)4 Section (org.olat.ims.qti.editor.beecom.objects.Section)4 AssessmentNode (org.olat.ims.qti.editor.tree.AssessmentNode)4 SectionNode (org.olat.ims.qti.editor.tree.SectionNode)4 ItemAndMetadata (org.olat.ims.qti.questionimport.ItemAndMetadata)4 ItemsPackage (org.olat.ims.qti.questionimport.ItemsPackage)4 QuestionItemView (org.olat.modules.qpool.QuestionItemView)4 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 Component (org.olat.core.gui.components.Component)2 JSAndCSSComponent (org.olat.core.gui.components.htmlheader.jscss.JSAndCSSComponent)2 Panel (org.olat.core.gui.components.panel.Panel)2 TooledStackedPanel (org.olat.core.gui.components.stack.TooledStackedPanel)2