Package org.olat.ims.qti.editor.beecom.objects

Examples of org.olat.ims.qti.editor.beecom.objects.Item


        ItemNode selectedNode = (ItemNode) menuTree.getSelectedNode();
        // only items are moveable
        // use XStream instead of ObjectCloner
        // Item qtiItem =
        // (Item)xstream.fromXML(xstream.toXML(selectedNode.getUnderlyingQTIObject()));
        Item toClone = (Item) selectedNode.getUnderlyingQTIObject();
        Item qtiItem = (Item) XStreamHelper.xstreamClone(toClone);
        // copy flow label class too, olat-2791
        Question orgQuestion = toClone.getQuestion();
        if (orgQuestion instanceof ChoiceQuestion) {
          String flowLabelClass = ((ChoiceQuestion)orgQuestion).getFlowLabelClass();
          Question copyQuestion =  qtiItem.getQuestion();
          if (copyQuestion instanceof ChoiceQuestion) {
            ((ChoiceQuestion)copyQuestion).setFlowLabelClass(flowLabelClass);
          } else {
            throw new AssertException("Could not copy flow-label-class, wrong type of copy question , must be 'ChoiceQuestion' but is " +copyQuestion);
          }
        }
        String editorIdentPrefix = "";
        if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_SCQ)) editorIdentPrefix = ItemParser.ITEM_PREFIX_SCQ;
        else if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_MCQ)) editorIdentPrefix = ItemParser.ITEM_PREFIX_MCQ;
        else if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_KPRIM)) editorIdentPrefix = ItemParser.ITEM_PREFIX_KPRIM;
        else if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_FIB)) editorIdentPrefix = ItemParser.ITEM_PREFIX_FIB;
        else if (qtiItem.getIdent().startsWith(ItemParser.ITEM_PREFIX_ESSAY)) editorIdentPrefix = ItemParser.ITEM_PREFIX_ESSAY;
        // set new ident... this is all it needs for our engine to recognise it
        // as a new item.
        qtiItem.setIdent(editorIdentPrefix + CodeHelper.getForeverUniqueID());
        // insert into menutree (insert on GenericNode do a remove from parent)
        GenericQtiNode parentTargetNode = (GenericQtiNode) tp.getParentTreeNode();
        GenericQtiNode newNode = new ItemNode(qtiItem, qtiPackage);
        parentTargetNode.insert(newNode, targetPos);
        // insert into model
View Full Code Here


       
      } else if (cmd.startsWith(CMD_TOOLS_ADD_PREFIX)) { // add new object
        // fetch new object
        if (cmd.equals(CMD_TOOLS_ADD_SECTION)) {
          Section newSection = QTIEditHelper.createSection(getTranslator());
          Item newItem = QTIEditHelper.createSCItem(getTranslator());
          newSection.getItems().add(newItem);
          SectionNode scNode = new SectionNode(newSection, qtiPackage);
          ItemNode itemNode = new ItemNode(newItem, qtiPackage);
          scNode.addChild(itemNode);
          insertObject = scNode;
        } else if (cmd.equals(CMD_TOOLS_ADD_SINGLECHOICE)) insertObject = new ItemNode(QTIEditHelper.createSCItem(getTranslator()), qtiPackage);
        else if (cmd.equals(CMD_TOOLS_ADD_MULTIPLECHOICE)) insertObject = new ItemNode(QTIEditHelper.createMCItem(getTranslator()), qtiPackage);
        else if (cmd.equals(CMD_TOOLS_ADD_KPRIM)) insertObject = new ItemNode(QTIEditHelper.createKPRIMItem(getTranslator()), qtiPackage);
        else if (cmd.equals(CMD_TOOLS_ADD_FIB)) insertObject = new ItemNode(QTIEditHelper.createFIBItem(getTranslator()), qtiPackage);
        else if (cmd.equals(CMD_TOOLS_ADD_FREETEXT)) insertObject = new ItemNode(QTIEditHelper.createEssayItem(getTranslator()), qtiPackage);

        // prepare insert tree
        insertTree = new SelectionTree("insertTree", getTranslator());
        insertTree.setFormButtonKey("submit");
        if (cmd.equals(CMD_TOOLS_ADD_SECTION)) insertTreeModel = new InsertItemTreeModel(menuTreeModel,
            InsertItemTreeModel.INSTANCE_ASSESSMENT);
        else insertTreeModel = new InsertItemTreeModel(menuTreeModel, InsertItemTreeModel.INSTANCE_SECTION);
        insertTree.setTreeModel(insertTreeModel);
        insertTree.addListener(this);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), insertTree, true, translate("title.add") );
        cmc.activate();
        listenTo(cmc);
      }
    } else if (source == deleteDialog) { // event from delete dialog
      if (DialogBoxUIFactory.isYesEvent(event)) { // yes, delete
        GenericQtiNode clickedNode = (GenericQtiNode) deleteDialog.getUserObject();
        //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) clickedNode.getParent()).removeQTIObjectAt(clickedNode.getPosition());
View Full Code Here

            }
          } else if (node instanceof ItemNode) {
            ItemNode in = (ItemNode) node;
            SectionNode sn = (SectionNode) in.getParent();
            String parentSectkey = ((Section) ((SectionNode) in.getParent()).getUnderlyingQTIObject()).getIdent();
            Item item = (Item) in.getUnderlyingQTIObject();
            Question question = item.getQuestion();
            String itemKey = item.getIdent();
            String prefixKey = "null/" + itemKey;
            String questionIdent = question != null ? question.getQuestion().getId() : "null";
            String key = prefixKey + "/" + questionIdent + "/null";
            StringBuilder changeMessage = new StringBuilder();
            boolean hasChanges = false;
View Full Code Here

TOP

Related Classes of org.olat.ims.qti.editor.beecom.objects.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.