Search in sources :

Example 41 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.

the class QuestionPoolServiceImpl method removeItemsInPool.

@Override
public void removeItemsInPool(List<QuestionItemShort> items, Pool pool) {
    poolDao.removeFromPool(items, pool);
    List<Long> keys = new ArrayList<>(items.size());
    for (QuestionItemShort item : items) {
        keys.add(item.getKey());
    }
    lifeIndexer.indexDocument(QItemDocument.TYPE, keys);
}
Also used : QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList)

Example 42 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.

the class QuestionPoolServiceImpl method index.

@Override
public void index(List<? extends QuestionItemShort> items) {
    if (items == null || items.isEmpty())
        return;
    List<Long> keys = new ArrayList<>();
    for (QuestionItemShort item : items) {
        keys.add(item.getKey());
    }
    lifeIndexer.indexDocument(QItemDocument.TYPE, keys);
}
Also used : QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList)

Example 43 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.

the class QuestionPoolServiceImpl method shareItemsWithGroups.

@Override
public void shareItemsWithGroups(List<? extends QuestionItemShort> items, List<BusinessGroup> groups, boolean editable) {
    if (items == null || items.isEmpty() || groups == null || groups.isEmpty()) {
        // nothing to do
        return;
    }
    List<OLATResource> resources = new ArrayList<OLATResource>(groups.size());
    for (BusinessGroup group : groups) {
        resources.add(group.getResource());
    }
    for (QuestionItemShort item : items) {
        questionItemDao.share(item, resources, editable);
    }
    index(items);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList) OLATResource(org.olat.resource.OLATResource)

Example 44 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.

the class QuestionPoolServiceImpl method createCollection.

@Override
public QuestionItemCollection createCollection(Identity owner, String collectionName, List<QuestionItemShort> initialItems) {
    QuestionItemCollection coll = collectionDao.createCollection(collectionName, owner);
    List<Long> keys = new ArrayList<>(initialItems.size());
    for (QuestionItemShort item : initialItems) {
        collectionDao.addItemToCollection(item, Collections.singletonList(coll));
        keys.add(item.getKey());
    }
    lifeIndexer.indexDocument(QItemDocument.TYPE, keys);
    return coll;
}
Also used : QuestionItemCollection(org.olat.modules.qpool.QuestionItemCollection) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList)

Example 45 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.

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)

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