Search in sources :

Example 26 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.

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 27 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.

the class QuestionItemDetailsController method doConfirmConversion.

private void doConfirmConversion(UserRequest ureq, QuestionItemShort item) {
    Map<String, List<QuestionItemShort>> formatToItems = new HashMap<>();
    List<QPoolSPI> spies = poolModule.getQuestionPoolProviders();
    for (QPoolSPI sp : spies) {
        if (sp != null && sp.isConversionPossible(item)) {
            List<QuestionItemShort> convertItems;
            if (formatToItems.containsKey(sp.getFormat())) {
                convertItems = formatToItems.get(sp.getFormat());
            } else {
                convertItems = new ArrayList<>(1);
                formatToItems.put(sp.getFormat(), Collections.singletonList(item));
            }
            convertItems.add(item);
        }
    }
    conversionConfirmationCtrl = new ConversionConfirmationController(ureq, getWindowControl(), formatToItems, itemSource);
    listenTo(conversionConfirmationCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), conversionConfirmationCtrl.getInitialComponent(), true, translate("convert.item"));
    cmc.activate();
    listenTo(cmc);
}
Also used : HashMap(java.util.HashMap) QPoolSPI(org.olat.modules.qpool.QPoolSPI) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) List(java.util.List) ArrayList(java.util.ArrayList)

Example 28 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.

the class QuestionPoolServiceImpl method convertItems.

@Override
public List<QuestionItem> convertItems(Identity cloner, List<QuestionItemShort> itemsToConvert, String format, Locale locale) {
    QPoolSPI sp = qpoolModule.getQuestionPoolProvider(format);
    List<QuestionItem> convertedQuestions = new ArrayList<>(itemsToConvert.size());
    for (QuestionItemShort item : itemsToConvert) {
        QuestionItem convertedQuestion = sp.convert(cloner, item, locale);
        licenseService.copy(item, convertedQuestion);
        if (convertedQuestion != null) {
            convertedQuestions.add(convertedQuestion);
        }
    }
    dbInstance.commit();
    index(convertedQuestions);
    return convertedQuestions;
}
Also used : QPoolSPI(org.olat.modules.qpool.QPoolSPI) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 29 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.

the class QuestionPoolServiceImpl method deleteItems.

@Override
public void deleteItems(List<? extends QuestionItemShort> items) {
    if (items == null || items.isEmpty()) {
        // nothing to do
        return;
    }
    List<SecurityGroup> secGroups = new ArrayList<>();
    for (QuestionItemShort item : items) {
        markManager.deleteMarks(item);
        commentAndRatingService.deleteAllIgnoringSubPath(item);
        licenseService.delete(item);
        QuestionItem loadedItem = loadItemById(item.getKey());
        if (loadedItem instanceof QuestionItemImpl) {
            QuestionItemImpl itemImpl = (QuestionItemImpl) loadedItem;
            qpoolFileStorage.deleteDir(itemImpl.getDirectory());
            secGroups.add(itemImpl.getOwnerGroup());
        }
        dbInstance.intermediateCommit();
    }
    poolDao.removeFromPools(items);
    questionItemDao.removeFromShares(items);
    collectionDao.deleteItemFromCollections(items);
    questionItemDao.delete(items);
    // Delete SecurityGroup after the item to avoid foreign key constraint violation.
    for (SecurityGroup secGroup : secGroups) {
        securityManager.deleteSecurityGroup(secGroup);
    }
    for (QuestionItemShort item : items) {
        lifeIndexer.deleteDocument(QItemDocument.TYPE, item.getKey());
    }
    // allow reload of data
    dbInstance.getCurrentEntityManager().flush();
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList) SecurityGroup(org.olat.basesecurity.SecurityGroup) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 30 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.

the class QuestionPoolServiceImpl method addItemToCollection.

@Override
public void addItemToCollection(List<? extends QuestionItemShort> items, List<QuestionItemCollection> collections) {
    List<Long> keys = new ArrayList<>(items.size());
    for (QuestionItemShort item : items) {
        collectionDao.addItemToCollection(item, collections);
        keys.add(item.getKey());
    }
    lifeIndexer.indexDocument(QItemDocument.TYPE, keys);
}
Also used : QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList)

Aggregations

QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)76 ArrayList (java.util.ArrayList)52 QuestionItem (org.olat.modules.qpool.QuestionItem)28 Identity (org.olat.core.id.Identity)14 List (java.util.List)12 BusinessGroup (org.olat.group.BusinessGroup)12 Test (org.junit.Test)10 QPoolSPI (org.olat.modules.qpool.QPoolSPI)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 QItemType (org.olat.modules.qpool.model.QItemType)8 HashMap (java.util.HashMap)6 ExportFormatOptions (org.olat.modules.qpool.ExportFormatOptions)6 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)6 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)6 QuestionItemView (org.olat.modules.qpool.QuestionItemView)6 QItemList (org.olat.modules.qpool.model.QItemList)6 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)6 QPoolEvent (org.olat.modules.qpool.ui.events.QPoolEvent)6 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)5 Path (javax.ws.rs.Path)4