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;
}
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();
}
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();
}
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();
}
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;
}
Aggregations