Search in sources :

Example 11 with QuestionItemShort

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

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)

Example 12 with QuestionItemShort

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

the class QuestionItemDAO method removeFromShares.

public int removeFromShares(List<? extends QuestionItemShort> items) {
    List<Long> keys = new ArrayList<>();
    for (QuestionItemShort item : items) {
        keys.add(item.getKey());
    }
    StringBuilder sb = new StringBuilder();
    sb.append("delete from qshareitem share where share.item.key in (:itemKeys)");
    return dbInstance.getCurrentEntityManager().createQuery(sb.toString()).setParameter("itemKeys", keys).executeUpdate();
}
Also used : QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList)

Example 13 with QuestionItemShort

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

the class QuestionItemDAO method removeFromShare.

public int removeFromShare(List<QuestionItemShort> items, OLATResource resource) {
    List<Long> keys = new ArrayList<>();
    for (QuestionItemShort item : items) {
        keys.add(item.getKey());
    }
    StringBuilder sb = new StringBuilder();
    sb.append("delete from qshareitem share where share.item.key in (:itemKeys) and share.resource.key=:resourceKey");
    return dbInstance.getCurrentEntityManager().createQuery(sb.toString()).setParameter("itemKeys", keys).setParameter("resourceKey", resource.getKey()).executeUpdate();
}
Also used : QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList)

Example 14 with QuestionItemShort

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

the class CollectionDAO method removeItemFromCollection.

public int removeItemFromCollection(List<QuestionItemShort> items, QuestionItemCollection collection) {
    // noting to do
    if (items == null || items.isEmpty())
        return 0;
    List<Long> keys = new ArrayList<>();
    for (QuestionItemShort item : items) {
        keys.add(item.getKey());
    }
    StringBuilder sb = new StringBuilder();
    sb.append("delete from qcollection2item coll2item where coll2item.item.key in (:itemKeys) and coll2item.collection.key=:collectionKey");
    return dbInstance.getCurrentEntityManager().createQuery(sb.toString()).setParameter("itemKeys", keys).setParameter("collectionKey", collection.getKey()).executeUpdate();
}
Also used : QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList)

Example 15 with QuestionItemShort

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

the class RightsMetadataEditController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == groupController) {
        if (event instanceof IdentitiesAddEvent) {
            IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
            List<Identity> list = identitiesAddedEvent.getAddIdentities();
            qpoolService.addAuthors(list, Collections.<QuestionItemShort>singletonList(item));
            identitiesAddedEvent.getAddedIdentities().addAll(list);
        } else if (event instanceof IdentitiesRemoveEvent) {
            IdentitiesRemoveEvent identitiesRemoveEvent = (IdentitiesRemoveEvent) event;
            List<Identity> list = identitiesRemoveEvent.getRemovedIdentities();
            qpoolService.removeAuthors(list, Collections.<QuestionItemShort>singletonList(item));
        }
        reloadAuthors();
    // cmc.deactivate();
    // cleanUp();
    } else if (source == cmc) {
        fireEvent(ureq, new QItemEdited(item));
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity)

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