Search in sources :

Example 1 with IQPreviewSecurityCallback

use of org.olat.modules.iq.IQPreviewSecurityCallback 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)

Example 2 with IQPreviewSecurityCallback

use of org.olat.modules.iq.IQPreviewSecurityCallback in project openolat by klemens.

the class IQConfigurationController method doPreview.

private void doPreview(UserRequest ureq) {
    removeAsListenerAndDispose(previewLayoutCtr);
    RepositoryEntry re = getIQReference();
    if (re != null) {
        Controller previewController;
        if (OnyxModule.isOnyxTest(re.getOlatResource())) {
            showError("error.onyx");
        } else if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
            // clean up last session
            cleanUpQti21PreviewSession();
            // need to clean up the assessment test session
            QTI21DeliveryOptions deliveryOptions = qti21service.getDeliveryOptions(re);
            QTI21OverrideOptions overrideOptions = QTI21OverrideOptions.nothingOverriden();
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            previewQTI21Ctrl = new AssessmentTestDisplayController(ureq, getWindowControl(), new InMemoryOutcomeListener(), re, courseEntry, courseNode.getIdent(), deliveryOptions, overrideOptions, true, true, true);
            listenTo(previewQTI21Ctrl);
            stackPanel.pushController(translate("preview"), previewQTI21Ctrl);
        } else {
            long courseResId = course.getResourceableId().longValue();
            previewController = iqManager.createIQDisplayController(moduleConfiguration, new IQPreviewSecurityCallback(), ureq, getWindowControl(), courseResId, courseNode.getIdent(), null);
            previewLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), previewController);
            stackPanel.pushController(translate("preview"), previewLayoutCtr);
        }
    }
}
Also used : QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions) InMemoryOutcomeListener(org.olat.ims.qti21.model.InMemoryOutcomeListener) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) QTI21OverrideOptions(org.olat.ims.qti21.ui.QTI21OverrideOptions) AssessmentTestDisplayController(org.olat.ims.qti21.ui.AssessmentTestDisplayController) RepositoryEntry(org.olat.repository.RepositoryEntry) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) ReferencableEntriesSearchController(org.olat.repository.controllers.ReferencableEntriesSearchController) NodeEditController(org.olat.course.editor.NodeEditController) BasicController(org.olat.core.gui.control.controller.BasicController) Controller(org.olat.core.gui.control.Controller) AssessmentTestDisplayController(org.olat.ims.qti21.ui.AssessmentTestDisplayController) IQPreviewSecurityCallback(org.olat.modules.iq.IQPreviewSecurityCallback)

Example 3 with IQPreviewSecurityCallback

use of org.olat.modules.iq.IQPreviewSecurityCallback in project OpenOLAT by OpenOLAT.

the class IQConfigurationController method doPreview.

private void doPreview(UserRequest ureq) {
    removeAsListenerAndDispose(previewLayoutCtr);
    RepositoryEntry re = getIQReference();
    if (re != null) {
        Controller previewController;
        if (OnyxModule.isOnyxTest(re.getOlatResource())) {
            showError("error.onyx");
        } else if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
            // clean up last session
            cleanUpQti21PreviewSession();
            // need to clean up the assessment test session
            QTI21DeliveryOptions deliveryOptions = qti21service.getDeliveryOptions(re);
            QTI21OverrideOptions overrideOptions = QTI21OverrideOptions.nothingOverriden();
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            previewQTI21Ctrl = new AssessmentTestDisplayController(ureq, getWindowControl(), new InMemoryOutcomeListener(), re, courseEntry, courseNode.getIdent(), deliveryOptions, overrideOptions, true, true, true);
            listenTo(previewQTI21Ctrl);
            stackPanel.pushController(translate("preview"), previewQTI21Ctrl);
        } else {
            long courseResId = course.getResourceableId().longValue();
            previewController = iqManager.createIQDisplayController(moduleConfiguration, new IQPreviewSecurityCallback(), ureq, getWindowControl(), courseResId, courseNode.getIdent(), null);
            previewLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), previewController);
            stackPanel.pushController(translate("preview"), previewLayoutCtr);
        }
    }
}
Also used : QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions) InMemoryOutcomeListener(org.olat.ims.qti21.model.InMemoryOutcomeListener) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) QTI21OverrideOptions(org.olat.ims.qti21.ui.QTI21OverrideOptions) AssessmentTestDisplayController(org.olat.ims.qti21.ui.AssessmentTestDisplayController) RepositoryEntry(org.olat.repository.RepositoryEntry) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) ReferencableEntriesSearchController(org.olat.repository.controllers.ReferencableEntriesSearchController) NodeEditController(org.olat.course.editor.NodeEditController) BasicController(org.olat.core.gui.control.controller.BasicController) Controller(org.olat.core.gui.control.Controller) AssessmentTestDisplayController(org.olat.ims.qti21.ui.AssessmentTestDisplayController) IQPreviewSecurityCallback(org.olat.modules.iq.IQPreviewSecurityCallback)

Example 4 with IQPreviewSecurityCallback

use of org.olat.modules.iq.IQPreviewSecurityCallback in project openolat by klemens.

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

CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 IQPreviewSecurityCallback (org.olat.modules.iq.IQPreviewSecurityCallback)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)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 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 NodeEditController (org.olat.course.editor.NodeEditController)2 Item (org.olat.ims.qti.editor.beecom.objects.Item)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 AssessmentNode (org.olat.ims.qti.editor.tree.AssessmentNode)2 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)2 InsertItemTreeModel (org.olat.ims.qti.editor.tree.InsertItemTreeModel)2 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)2 SectionNode (org.olat.ims.qti.editor.tree.SectionNode)2 QTIEditorResolver (org.olat.ims.qti.process.QTIEditorResolver)2