Search in sources :

Example 26 with QPoolEvent

use of org.olat.modules.qpool.ui.events.QPoolEvent in project OpenOLAT by OpenOLAT.

the class QuestionListController method doRenameItemCollection.

private void doRenameItemCollection(UserRequest ureq, String newName) {
    itemCollection = qpoolService.renameCollection(itemCollection, newName);
    fireEvent(ureq, new QPoolEvent(QPoolEvent.COLL_CHANGED, itemCollection.getKey()));
}
Also used : QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent)

Example 27 with QPoolEvent

use of org.olat.modules.qpool.ui.events.QPoolEvent in project OpenOLAT by OpenOLAT.

the class QuestionPoolMainEditorController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (shareItemsCtrl == source) {
        if (QPoolEvent.ITEM_SHARED.equals(event.getCommand())) {
            List<QuestionItemShort> items = shareItemsCtrl.getItems();
            if (items.size() > 0) {
                // can only drop one item
                QuestionItemShort item = items.get(0);
                if (shareItemsCtrl.getGroups() != null) {
                    showInfo("item.shared", item.getTitle());
                } else if (shareItemsCtrl.getPools() != null) {
                    showInfo("item.pooled", item.getTitle());
                }
            }
            treeModel.buildShareSubTreeModel();
            menuTree.setDirty(true);
        }
        cmc.deactivate();
        cleanUp();
    } else if (event instanceof QPoolEvent) {
        if (QPoolEvent.ITEM_SHARED.equals(event.getCommand())) {
            treeModel.buildShareSubTreeModel();
            menuTree.setDirty(true);
        } else if (QPoolEvent.COLL_CREATED.equals(event.getCommand()) || QPoolEvent.COLL_CHANGED.equals(event.getCommand())) {
            treeModel.buildMySubTreeModel();
            Long collKey = ((QPoolEvent) event).getObjectKey();
            CollectionTreeNode qNode = (CollectionTreeNode) findNodeByPersistableUserObject(treeModel.getMyNode(), collKey);
            if (qNode != null) {
                menuTree.setSelectedNode(qNode);
                doSelectQuestionsNode(ureq, qNode, null, null);
            }
            menuTree.setDirty(true);
        } else if (QPoolEvent.COLL_DELETED.equals(event.getCommand())) {
            treeModel.buildMySubTreeModel();
            menuTree.setSelectedNode(treeModel.getMyNode());
            doSelectControllerTreeNode(ureq, treeModel.getMyNode(), null, null);
        } else if (QPoolEvent.POOL_CREATED.equals(event.getCommand()) || QPoolEvent.POOL_DELETED.equals(event.getCommand())) {
            treeModel.buildShareSubTreeModel();
            menuTree.setDirty(true);
        } else if (QPoolEvent.ITEMS_RELOADED.equals(event.getCommand())) {
            treeModel.reloadReviewCounts();
        }
    } else if (copyToMyCtrl == source) {
        if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
            QuestionItemShort item = (QuestionItemShort) copyToMyCtrl.getUserObject();
            doCopyToMy(item);
        }
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent)

Example 28 with QPoolEvent

use of org.olat.modules.qpool.ui.events.QPoolEvent in project openolat by klemens.

the class QuestionListController method doPostConvert.

private void doPostConvert(UserRequest ureq, Event event) {
    if (event instanceof QItemsProcessedEvent) {
        QItemsProcessedEvent ipEvent = (QItemsProcessedEvent) event;
        int numberOfCopies = ipEvent.getNumberOfItems();
        int numberOfFails = ipEvent.getNumberOfFails();
        if (numberOfFails == 0) {
            showInfo("convert.item.successful", new String[] { Integer.toString(numberOfCopies) });
        } else {
            showWarning("convert.item.warning", new String[] { Integer.toString(numberOfFails), Integer.toString(numberOfCopies) });
        }
        getItemsTable().reset();
        fireEvent(ureq, new QPoolEvent(QPoolEvent.EDIT));
    }
}
Also used : QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent) QItemsProcessedEvent(org.olat.modules.qpool.ui.events.QItemsProcessedEvent)

Example 29 with QPoolEvent

use of org.olat.modules.qpool.ui.events.QPoolEvent in project openolat by klemens.

the class QuestionListController method doCreateNewItem.

private void doCreateNewItem(UserRequest ureq, String title, TaxonomyLevel taxonomyLevel, QItemFactory factory) {
    QuestionItem item = factory.createItem(getIdentity(), title, getLocale());
    List<QuestionItem> newItems = Collections.singletonList(item);
    getSource().postImport(newItems, false);
    if (taxonomyLevel != null && item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        itemImpl.setTaxonomyLevel(taxonomyLevel);
        qpoolService.updateItem(itemImpl);
    }
    if (licenseModule.isEnabled(licenseHandler)) {
        // The QItemFactory may create a no license as part of the import process.
        // But for new question items the default license should be created.
        // So delete the no license first, so that the default license can be created.
        licenseService.delete(item);
        licenseService.createDefaultLicense(item, licenseHandler, getIdentity());
    }
    getItemsTable().reset();
    dbInstance.commit();
    qpoolService.index(newItems);
    QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_NEW);
    builder.withAfter(item);
    qpoolService.persist(builder.create());
    QPoolEvent qce = new QPoolEvent(QPoolEvent.ITEM_CREATED);
    fireEvent(ureq, qce);
    doOpenDetails(ureq, item);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 30 with QPoolEvent

use of org.olat.modules.qpool.ui.events.QPoolEvent in project openolat by klemens.

the class QuestionListController method doRenameItemCollection.

private void doRenameItemCollection(UserRequest ureq, String newName) {
    itemCollection = qpoolService.renameCollection(itemCollection, newName);
    fireEvent(ureq, new QPoolEvent(QPoolEvent.COLL_CHANGED, itemCollection.getKey()));
}
Also used : QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent)

Aggregations

QPoolEvent (org.olat.modules.qpool.ui.events.QPoolEvent)38 QuestionItem (org.olat.modules.qpool.QuestionItem)6 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)6 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)6 List (java.util.List)4 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)4 QItemsProcessedEvent (org.olat.modules.qpool.ui.events.QItemsProcessedEvent)4 ArrayList (java.util.ArrayList)2 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)2 IdentitiesRemoveEvent (org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent)2 PopEvent (org.olat.core.gui.components.stack.PopEvent)2 Controller (org.olat.core.gui.control.Controller)2 CloseableCalloutWindowController (org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 DialogBoxController (org.olat.core.gui.control.generic.modal.DialogBoxController)2 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)2 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)2 Identity (org.olat.core.id.Identity)2 BusinessGroup (org.olat.group.BusinessGroup)2 BusinessGroupSelectionEvent (org.olat.group.model.BusinessGroupSelectionEvent)2