Search in sources :

Example 11 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class QTIWordExport method renderItem.

public static void renderItem(Item item, OpenXMLDocument document, boolean withResponses, Translator translator) {
    Element el = DocumentFactory.getInstance().createElement("dummy");
    item.addToElement(el);
    Element itemEl = (Element) el.elements().get(0);
    org.olat.ims.qti.container.qtielements.Item foo = new org.olat.ims.qti.container.qtielements.Item(itemEl);
    RenderInstructions renderInstructions = new RenderInstructions();
    renderInstructions.put(RenderInstructions.KEY_STATICS_PATH, "/");
    renderInstructions.put(RenderInstructions.KEY_LOCALE, translator.getLocale());
    renderInstructions.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.TRUE);
    if (item.getQuestion() != null) {
        Map<String, String> iinput = new HashMap<String, String>();
        String questionType = null;
        String questionScore = null;
        Question question = item.getQuestion();
        if (question instanceof ChoiceQuestion) {
            ChoiceQuestion choice = (ChoiceQuestion) question;
            if (question.getType() == Question.TYPE_SC) {
                questionType = translator.translate("item.type.sc");
                fetchPointsOfMultipleChoices(itemEl, choice, iinput);
            } else if (question.getType() == Question.TYPE_MC) {
                questionType = translator.translate("item.type.mc");
                fetchPointsOfMultipleChoices(itemEl, choice, iinput);
            } else if (question.getType() == Question.TYPE_KPRIM) {
                questionType = translator.translate("item.type.kprim");
                fetchPointsOfKPrim(itemEl, choice, iinput);
            }
        } else if (question instanceof FIBQuestion) {
            questionType = translator.translate("item.type.sc");
            for (Response response : question.getResponses()) {
                FIBResponse fibResponse = (FIBResponse) response;
                if ("BLANK".equals(fibResponse.getType())) {
                    iinput.put(fibResponse.getIdent(), fibResponse.getCorrectBlank());
                }
            }
        } else if (question instanceof EssayQuestion) {
            questionType = translator.translate("item.type.essay");
        }
        if (question != null && question.getMaxValue() > 0.0f) {
            questionScore = AssessmentHelper.getRoundedScore(question.getMaxValue());
            questionScore = translator.translate("item.score.long", new String[] { questionScore });
        }
        renderInstructions.put(RenderInstructions.KEY_RENDER_CORRECT_RESPONSES, new Boolean(withResponses));
        renderInstructions.put(RenderInstructions.KEY_CORRECT_RESPONSES_MAP, iinput);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_TYPE, questionType);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_SCORE, questionScore);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_OO_TYPE, new Integer(question.getType()));
    }
    foo.renderOpenXML(document, renderInstructions);
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) HashMap(java.util.HashMap) Element(org.dom4j.Element) RenderInstructions(org.olat.ims.qti.container.qtielements.RenderInstructions) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Item(org.olat.ims.qti.editor.beecom.objects.Item) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion)

Example 12 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class ItemParser method parse.

/**
 * @see org.olat.ims.qti.editor.beecom.parser.IParser#parse(org.dom4j.Element)
 */
public Object parse(Element element) {
    // assert element.getName().equalsIgnoreCase("item");
    Item item = new Item();
    Attribute tmp = element.attribute("ident");
    if (tmp != null)
        item.setIdent(tmp.getValue());
    else
        item.setIdent("" + CodeHelper.getRAMUniqueID());
    tmp = element.attribute("title");
    if (tmp != null)
        item.setTitle(tmp.getValue());
    tmp = element.attribute("label");
    if (tmp != null)
        item.setLabel(tmp.getValue());
    tmp = element.attribute("maxattempts");
    if (tmp != null) {
        try {
            item.setMaxattempts(Integer.parseInt(tmp.getValue()));
        } catch (NumberFormatException nfe) {
            item.setMaxattempts(0);
        }
    }
    // if editor can't handle type of item, just keep raw XML
    if (!(item.getIdent().startsWith(ITEM_PREFIX_SCQ) || item.getIdent().startsWith(ITEM_PREFIX_MCQ) || item.getIdent().startsWith(ITEM_PREFIX_FIB) || item.getIdent().startsWith(ITEM_PREFIX_ESSAY) || item.getIdent().startsWith(ITEM_PREFIX_KPRIM))) {
        item.setRawXML(new QTIXMLWrapper(element));
        return item;
    }
    // for render_fib that contains rows attribute and convert them to essay
    if (item.getIdent().startsWith(ITEM_PREFIX_FIB) && element.selectNodes(".//render_fib[@rows]").size() > 0) {
        item.setIdent(item.getIdent().replaceFirst("FIB", "ESSAY"));
    }
    // DURATION
    Duration duration = (Duration) parserManager.parse(element.element("duration"));
    item.setDuration(duration);
    // CONTROLS
    List itemcontrolsXML = element.elements("itemcontrol");
    List itemcontrols = new ArrayList();
    for (Iterator i = itemcontrolsXML.iterator(); i.hasNext(); ) {
        itemcontrols.add(parserManager.parse((Element) i.next()));
    }
    if (itemcontrols.size() == 0) {
        itemcontrols.add(new Control());
    }
    item.setItemcontrols(itemcontrols);
    // OBJECTIVES
    Element mattext = (Element) element.selectSingleNode("./objectives/material/mattext");
    if (mattext != null)
        item.setObjectives(mattext.getTextTrim());
    // QUESTIONS
    if (item.getIdent().startsWith(ITEM_PREFIX_SCQ))
        item.setQuestion(ChoiceQuestion.getInstance(element));
    else if (item.getIdent().startsWith(ITEM_PREFIX_MCQ))
        item.setQuestion(ChoiceQuestion.getInstance(element));
    else if (item.getIdent().startsWith(ITEM_PREFIX_FIB))
        item.setQuestion(FIBQuestion.getInstance(element));
    else if (item.getIdent().startsWith(ITEM_PREFIX_ESSAY))
        item.setQuestion(EssayQuestion.getInstance(element));
    else if (item.getIdent().startsWith(ITEM_PREFIX_KPRIM))
        item.setQuestion(ChoiceQuestion.getInstance(element));
    // FEEDBACKS
    List feedbacksXML = element.elements("itemfeedback");
    List feedbacks = new ArrayList();
    item.setItemfeedbacks(feedbacks);
    Question question = item.getQuestion();
    for (Iterator i = feedbacksXML.iterator(); i.hasNext(); ) {
        Element el_feedback = (Element) i.next();
        if (el_feedback.element("solution") != null) {
            // fetch solution
            Element el_solution = el_feedback.element("solution");
            question.setSolutionText(getMaterialAsString(el_solution));
        } else if (el_feedback.element("hint") != null) {
            // fetch hint
            Element el_hint = el_feedback.element("hint");
            question.setHintText(getMaterialAsString(el_hint));
        } else {
            QTIObject tmpObj = (QTIObject) parserManager.parse(el_feedback);
            if (tmpObj != null)
                feedbacks.add(tmpObj);
        }
    }
    return item;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) Control(org.olat.ims.qti.editor.beecom.objects.Control) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) Attribute(org.dom4j.Attribute) QTIXMLWrapper(org.olat.ims.qti.editor.beecom.objects.QTIXMLWrapper) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Duration(org.olat.ims.qti.editor.beecom.objects.Duration) ArrayList(java.util.ArrayList) List(java.util.List) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion)

Example 13 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class QTIEditorMainController method doExportQItem.

private void doExportQItem() {
    GenericQtiNode selectedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
    if (selectedNode instanceof ItemNode) {
        ItemNode itemNode = (ItemNode) selectedNode;
        QTIObject qtiObject = itemNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Item) {
            ItemAndMetadata item = new ItemAndMetadata((Item) qtiObject);
            VFSContainer editorContainer = qtiPackage.getBaseDir();
            qtiQpoolServiceProvider.importBeecomItem(getIdentity(), item, editorContainer, getLocale());
            showInfo("export.qpool.successful", "1");
        }
    } else if (selectedNode instanceof SectionNode) {
        SectionNode sectionNode = (SectionNode) selectedNode;
        QTIObject qtiObject = sectionNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Section) {
            int count = doExportSection((Section) qtiObject);
            showInfo("export.qpool.successful", Integer.toString(count));
        }
    } else if (selectedNode instanceof AssessmentNode) {
        AssessmentNode assessmentNode = (AssessmentNode) selectedNode;
        QTIObject qtiObject = assessmentNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Assessment) {
            int count = doExportAssessment((Assessment) qtiObject);
            showInfo("export.qpool.successful", Integer.toString(count));
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) AssessmentNode(org.olat.ims.qti.editor.tree.AssessmentNode) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) SectionNode(org.olat.ims.qti.editor.tree.SectionNode) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 14 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class QTIEditorMainController method createChangeMessage.

/**
 * helper method to create the change log message
 *
 * @return
 */
private String createChangeMessage() {
    // FIXME:pb:break down into smaller pieces
    final StringBuilder result = new StringBuilder();
    if (isRestrictedEdit()) {
        Visitor v = new Visitor() {

            /*
				 * a history key is built as follows
				 * sectionkey+"/"+itemkey+"/"+questionkey+"/"+responsekey
				 */
            String sectionKey = null;

            Map<String, String> itemMap = new HashMap<>();

            public void visit(INode node) {
                if (node instanceof AssessmentNode) {
                    AssessmentNode an = (AssessmentNode) node;
                    String key = "null/null/null/null";
                    if (history.containsKey(key)) {
                        // some assessment top level data changed
                        Memento mem = history.get(key);
                        result.append("---+ Changes in test " + formatVariable(startedWithTitle) + ":");
                        result.append(an.createChangeMessage(mem));
                    }
                } else if (node instanceof SectionNode) {
                    SectionNode sn = (SectionNode) node;
                    String tmpKey = ((Section) sn.getUnderlyingQTIObject()).getIdent();
                    String key = tmpKey + "/null/null/null";
                    if (history.containsKey(key)) {
                        // some section only data changed
                        Memento mem = history.get(key);
                        result.append("\n---++ Section " + formatVariable(sn.getAltText()) + " changes:");
                        result.append(sn.createChangeMessage(mem));
                    }
                } 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;
                    if (!itemMap.containsKey(itemKey)) {
                        Memento questMem = null;
                        Memento respMem = null;
                        if (history.containsKey(key)) {
                            // question changed!
                            questMem = history.get(key);
                            hasChanges = true;
                        }
                        // if(!hasChanges){
                        // check if a response changed
                        // new prefix for responses
                        prefixKey += "/null/";
                        // list contains org.olat.ims.qti.editor.beecom.objects.Response
                        List<Response> responses = question != null ? question.getResponses() : null;
                        if (responses != null && responses.size() > 0) {
                            // check for changes in each response
                            for (Iterator<Response> iter = responses.iterator(); iter.hasNext(); ) {
                                Response resp = iter.next();
                                if (history.containsKey(prefixKey + resp.getIdent())) {
                                    // this response changed!
                                    Memento tmpMem = history.get(prefixKey + resp.getIdent());
                                    if (respMem != null) {
                                        respMem = respMem.getTimestamp() > tmpMem.getTimestamp() ? tmpMem : respMem;
                                    } else {
                                        hasChanges = true;
                                        respMem = tmpMem;
                                    }
                                }
                            }
                        }
                        // output message
                        if (hasChanges) {
                            Memento mem = null;
                            if (questMem != null && respMem != null) {
                                // use the earlier memento
                                mem = questMem.getTimestamp() > respMem.getTimestamp() ? respMem : questMem;
                            } else if (questMem != null) {
                                mem = questMem;
                            } else if (respMem != null) {
                                mem = respMem;
                            }
                            changeMessage.append(in.createChangeMessage(mem));
                            itemMap.put(itemKey, itemKey);
                            if (!parentSectkey.equals(sectionKey)) {
                                // either this item belongs to a new section or no section
                                // is active
                                result.append("\n---++ Section " + formatVariable(sn.getAltText()) + " changes:");
                                result.append("\n").append(changeMessage);
                                sectionKey = parentSectkey;
                            } else {
                                result.append("\n").append(changeMessage);
                            }
                        }
                    }
                }
            }

            private String formatVariable(String var) {
                if (StringHelper.containsNonWhitespace(var)) {
                    return var;
                }
                return "[no entry]";
            }
        };
        TreeVisitor tv = new TreeVisitor(v, menuTreeModel.getRootNode(), false);
        tv.visitAll();
    }
    /*
		 * 
		 */
    return result.toString();
}
Also used : INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) AssessmentNode(org.olat.ims.qti.editor.tree.AssessmentNode) SectionNode(org.olat.ims.qti.editor.tree.SectionNode) Section(org.olat.ims.qti.editor.beecom.objects.Section) Response(org.olat.ims.qti.editor.beecom.objects.Response) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Memento(org.olat.core.util.memento.Memento) Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) Map(java.util.Map) HashMap(java.util.HashMap)

Example 15 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class QTIEditorMainController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Component source, Event event) {
    // 
    if (source == menuTree) {
        // catch menu tree clicks
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            GenericQtiNode clickedNode;
            clickedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
            Component tabbedPane = clickedNode.createEditTabbedPane(ureq, getWindowControl(), getTranslator(), this);
            if (tabbedPane != null) {
                main.put("tabbedPane", tabbedPane);
            } else {
                VelocityContainer itemNotEditable = createVelocityContainer("tab_itemAlien");
                main.put("tabbedPane", itemNotEditable);
                return;
            }
            // only available in full edit mode
            if (clickedNode instanceof AssessmentNode) {
                deleteLink.setEnabled(false);
                moveLink.setEnabled(false);
                copyLink.setEnabled(false);
                stackedPanel.setDirty(true);
            } else {
                deleteLink.setEnabled(true && !restrictedEdit);
                moveLink.setEnabled(true && !restrictedEdit);
                if (clickedNode instanceof ItemNode) {
                    copyLink.setEnabled(true && !restrictedEdit);
                } else {
                    copyLink.setEnabled(false);
                }
                stackedPanel.setDirty(true);
            }
        }
    } else if (source == exitVC) {
        if (CMD_EXIT_SAVE.equals(event.getCommand())) {
            if (isRestrictedEdit() && history.size() > 0) {
                // changes were recorded
                // start work flow:
                // -sending an e-mail to everybody being a stake holder of this qti
                // resource
                // -email with change message
                // -after sending email successfully -> saveNexit is called.
                chngMsgFormVC = createVelocityContainer("changeMsgForm");
                // FIXME:pb:a Bitte diesen Velocity container entfernen und statt
                // dessen den
                // ContentOnlyController verwenden. Es ist äusserst wichtig dass das
                // Layout nie selber gemacht
                // wird sondern immer die Layout controller verwendet werden, d.h. den
                // ContentOnlyController oder
                // den MenuAndToolController. Dort kann das Tool übrigens auch null
                // sein wenn man nur ein Menü braucht.
                // TODO:pb:a extend ContentOnlyController to work also if menu and
                // tool are null, hence only content is desired
                String userN = UserManager.getInstance().getUserDisplayEmail(ureq.getIdentity(), ureq.getLocale());
                String lastN = ureq.getIdentity().getUser().getProperty(UserConstants.LASTNAME, ureq.getLocale());
                String firstN = ureq.getIdentity().getUser().getProperty(UserConstants.FIRSTNAME, ureq.getLocale());
                String changeMsg = "Changed by: " + firstN + " " + lastN + " [" + userN + "]\n";
                changeMsg += createChangeMessage();
                changeEmail.setBodyText(changeMsg);
                chngMsgFormVC.contextPut("chngMsg", changeEmail.getBodyText());
                removeAsListenerAndDispose(chngMsgFrom);
                chngMsgFrom = new ChangeMessageForm(ureq, getWindowControl());
                listenTo(chngMsgFrom);
                chngMsgFormVC.put("chngMsgForm", chngMsgFrom.getInitialComponent());
                exitPanel.setContent(chngMsgFormVC);
                return;
            } else {
                // remove modal dialog and proceed with exit process
                cmcExit.deactivate();
                removeAsListenerAndDispose(cmcExit);
                cmcExit = null;
                // remove lock, clean tmp dir, fire done event to close editor
                saveAndExit(ureq);
            }
        } else if (CMD_EXIT_DISCARD.equals(event.getCommand())) {
            // remove modal dialog and proceed with exit process
            cmcExit.deactivate();
            removeAsListenerAndDispose(cmcExit);
            cmcExit = null;
            // cleanup, so package does not get resumed
            qtiPackage.cleanupTmpPackageDir();
            // remove lock
            removeLocksAndExit(ureq);
        } else if (CMD_EXIT_CANCEL.equals(event.getCommand())) {
            // remove modal dialog and go back to edit mode
            cmcExit.deactivate();
            removeAsListenerAndDispose(cmcExit);
            cmcExit = null;
        }
    } else if (source == notEditableButton) {
        // close editor
        fireEvent(ureq, Event.DONE_EVENT);
    } else if (closeLink == source) {
        // exitVC hook:
        // save package back to repository
        exitVC = createVelocityContainer("exitDialog");
        exitPanel = new Panel("exitPanel");
        exitPanel.setContent(exitVC);
        cmcExit = new CloseableModalController(getWindowControl(), translate("editor.preview.close"), exitPanel, true, translate("exit.header"));
        cmcExit.activate();
        listenTo(cmcExit);
        return;
    } else if (previewLink == source) {
        // preview
        previewController = CoreSpringFactory.getImpl(IQManager.class).createIQDisplayController(new QTIEditorResolver(qtiPackage), qtiPackage.getQTIDocument().isSurvey() ? AssessmentInstance.QMD_ENTRY_TYPE_SURVEY : AssessmentInstance.QMD_ENTRY_TYPE_SELF, new IQPreviewSecurityCallback(), ureq, getWindowControl());
        if (previewController.isReady()) {
            // in case previewController was unable to initialize, a message was
            // set by displayController
            // this is the case if no more attempts or security check was
            // unsuccessfull
            previewController.addControllerListener(this);
            cmcPrieview = new CloseableModalController(getWindowControl(), translate("editor.preview.close"), previewController.getInitialComponent());
            cmcPrieview.activate();
            listenTo(cmcPrieview);
        } else {
            getWindowControl().setWarning(translate("error.preview"));
        }
    } else if (deleteLink == source) {
        // multi return in Firefox
        if (deleteDialog != null)
            return;
        GenericQtiNode clickedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
        String msg = "";
        if (clickedNode instanceof SectionNode) {
            if (QTIEditHelper.countSections(qtiPackage.getQTIDocument().getAssessment()) == 1) {
                // At least one section
                getWindowControl().setError(translate("error.atleastonesection"));
                return;
            }
            msg = translate("delete.section", clickedNode.getTitle());
        } else if (clickedNode instanceof ItemNode) {
            if (((SectionNode) clickedNode.getParent()).getChildCount() == 1) {
                // At least one item
                getWindowControl().setError(translate("error.atleastoneitem"));
                return;
            }
            msg = translate("delete.item", clickedNode.getTitle());
        }
        deleteDialog = activateYesNoDialog(ureq, null, msg, deleteDialog);
        deleteDialog.setUserObject(clickedNode);
        return;
    } else if (moveLink == source) {
        // cannot move the last item
        GenericQtiNode clickedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
        if (clickedNode instanceof ItemNode && ((SectionNode) clickedNode.getParent()).getChildCount() == 1) {
            getWindowControl().setError(translate("error.move.atleastoneitem"));
        } else {
            TreeNode selectedNode = menuTree.getSelectedNode();
            int type = (selectedNode instanceof SectionNode) ? InsertItemTreeModel.INSTANCE_ASSESSMENT : InsertItemTreeModel.INSTANCE_SECTION;
            InsertItemTreeModel treeModel = new InsertItemTreeModel(menuTreeModel, selectedNode, type);
            moveCtrl = new InsertNodeController(ureq, getWindowControl(), treeModel);
            listenTo(moveCtrl);
            cmc = new CloseableModalController(getWindowControl(), "close", moveCtrl.getInitialComponent(), true, translate("title.move"));
            cmc.activate();
            listenTo(cmc);
        }
    } else if (copyLink == source) {
        InsertItemTreeModel treeModel = new InsertItemTreeModel(menuTreeModel, menuTree.getSelectedNode(), InsertItemTreeModel.INSTANCE_SECTION);
        copyCtrl = new InsertNodeController(ureq, getWindowControl(), treeModel);
        listenTo(copyCtrl);
        cmc = new CloseableModalController(getWindowControl(), "close", copyCtrl.getInitialComponent(), true, translate("title.copy"));
        cmc.activate();
        listenTo(cmc);
    } else if (addPoolLink == source) {
        doSelectQItem(ureq);
    } else if (exportPoolLink == source) {
        doExportQItem();
    } else if (exportDocLink == source) {
        doExportDocx(ureq);
    } else if (convertQTI21Link == source) {
        doConvertToQTI21(ureq);
    } else if (importTableLink == source) {
        doImportTable(ureq);
    } else if (addSectionLink == source) {
        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);
        doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_SECTION, scNode);
    } else if (addSCLink == source) {
        ItemNode insertObject = new ItemNode(QTIEditHelper.createSCItem(getTranslator()), qtiPackage);
        doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_SINGLECHOICE, insertObject);
    } else if (addMCLink == source) {
        ItemNode insertObject = new ItemNode(QTIEditHelper.createMCItem(getTranslator()), qtiPackage);
        doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_MULTIPLECHOICE, insertObject);
    } else if (addKPrimLink == source) {
        ItemNode insertObject = new ItemNode(QTIEditHelper.createKPRIMItem(getTranslator()), qtiPackage);
        doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_KPRIM, insertObject);
    } else if (addFIBLink == source) {
        ItemNode insertObject = new ItemNode(QTIEditHelper.createFIBItem(getTranslator()), qtiPackage);
        doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_FIB, insertObject);
    } else if (addEssayLink == source) {
        ItemNode insertObject = new ItemNode(QTIEditHelper.createEssayItem(getTranslator()), qtiPackage);
        doSelectInsertionPoint(ureq, CMD_TOOLS_ADD_FREETEXT, insertObject);
    }
}
Also used : AssessmentNode(org.olat.ims.qti.editor.tree.AssessmentNode) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode) QTIEditorResolver(org.olat.ims.qti.process.QTIEditorResolver) SectionNode(org.olat.ims.qti.editor.tree.SectionNode) Section(org.olat.ims.qti.editor.beecom.objects.Section) IQPreviewSecurityCallback(org.olat.modules.iq.IQPreviewSecurityCallback) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) Panel(org.olat.core.gui.components.panel.Panel) Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) InsertItemTreeModel(org.olat.ims.qti.editor.tree.InsertItemTreeModel) TreeNode(org.olat.core.gui.components.tree.TreeNode) Component(org.olat.core.gui.components.Component) JSAndCSSComponent(org.olat.core.gui.components.htmlheader.jscss.JSAndCSSComponent)

Aggregations

Item (org.olat.ims.qti.editor.beecom.objects.Item)92 VFSItem (org.olat.core.util.vfs.VFSItem)38 Section (org.olat.ims.qti.editor.beecom.objects.Section)28 ArrayList (java.util.ArrayList)24 VFSContainer (org.olat.core.util.vfs.VFSContainer)18 Control (org.olat.ims.qti.editor.beecom.objects.Control)18 Element (org.dom4j.Element)16 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)16 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)16 Translator (org.olat.core.gui.translator.Translator)14 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)14 Response (org.olat.ims.qti.editor.beecom.objects.Response)14 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)14 File (java.io.File)12 QuestionItem (org.olat.modules.qpool.QuestionItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)10 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)10 SectionNode (org.olat.ims.qti.editor.tree.SectionNode)10 StatisticItem (org.olat.ims.qti.statistics.model.StatisticItem)10