Search in sources :

Example 41 with Pool

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

the class ItemListMySharesController method doSelectPool.

private void doSelectPool(UserRequest ureq, Long poolKey) {
    Pool myPool = null;
    for (Pool pool : myPools) {
        if (poolKey.equals(pool.getKey())) {
            myPool = pool;
        }
    }
    if (myPool == null) {
        updateSource(new EmptyItemsSource());
    } else {
        PoolItemsSource source = new PoolItemsSource(getIdentity(), ureq.getUserSession().getRoles(), myPool);
        source.getDefaultParams().setFormat(restrictToFormat);
        updateSource(source);
    }
}
Also used : PoolItemsSource(org.olat.modules.qpool.ui.datasource.PoolItemsSource) EmptyItemsSource(org.olat.modules.qpool.ui.datasource.EmptyItemsSource) Pool(org.olat.modules.qpool.Pool)

Example 42 with Pool

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

the class QuestionPoolMainEditorController method doDrop.

private void doDrop(UserRequest ureq, String targetId, String dropId) {
    try {
        int lastIndex = dropId.lastIndexOf('-');
        String rowStr = dropId.substring(lastIndex + 1, dropId.length());
        int row = Integer.parseInt(rowStr);
        QuestionItemShort item = ((QuestionsController) currentCtrl).getQuestionAt(row);
        TreeNode node = menuTree.getTreeModel().getNodeById(targetId);
        if (node != null) {
            Object userObj = node.getUserObject();
            if (userObj instanceof BusinessGroup) {
                doShareItemsOptions(ureq, singletonList(item), singletonList((BusinessGroup) userObj), null);
            } else if (userObj instanceof Pool) {
                doShareItemsOptions(ureq, singletonList(item), null, singletonList((Pool) userObj));
            } else if (userObj instanceof QuestionItemCollection) {
                qpoolService.addItemToCollection(singletonList(item), singletonList((QuestionItemCollection) userObj));
                showInfo("item.collectioned", item.getTitle());
            } else if (node instanceof MyQuestionsTreeNode) {
                doCopyToMyConfirmation(ureq, item);
            } else if (node instanceof MarkedQuestionsTreeNode) {
                String businessPath = "[QuestionItem:" + item.getKey() + "]";
                markManager.setMark(item, getIdentity(), null, businessPath);
                QItemMarkedEvent event = new QItemMarkedEvent("marked", item.getKey(), true);
                ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(event, QITEM_MARKED);
            }
        }
    } catch (Exception e) {
        logError("Cannot drop with id: " + dropId, e);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) QuestionItemCollection(org.olat.modules.qpool.QuestionItemCollection) MarkedQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode) QItemMarkedEvent(org.olat.modules.qpool.ui.events.QItemMarkedEvent) MyQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode) ControllerTreeNode(org.olat.modules.qpool.ui.tree.ControllerTreeNode) CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) MarkedQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) MyQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool)

Example 43 with Pool

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

the class ItemListMySharesController method initButtons.

@Override
protected void initButtons(UserRequest ureq, FormItemContainer formLayout) {
    getItemsTable().setMultiSelect(true);
    selectLink = uifactory.addFormLink("select-to-import", "select", null, formLayout, Link.BUTTON);
    Roles roles = ureq.getUserSession().getRoles();
    if (qpoolModule.isPoolsEnabled()) {
        myPools = qpoolService.getPools(getIdentity(), roles);
    } else {
        myPools = Collections.emptyList();
    }
    if (qpoolModule.isSharesEnabled()) {
        myGroups = qpoolService.getResourcesWithSharedItems(getIdentity());
    } else {
        myGroups = Collections.emptyList();
    }
    String[] myShareKeys;
    String[] myShareValues;
    if (myPools.isEmpty() && myGroups.isEmpty()) {
        myShareKeys = new String[1];
        myShareValues = new String[1];
        myShareKeys[0] = "";
        myShareValues[0] = "";
    } else {
        int numOfShares = myPools.size() + myGroups.size();
        myShareKeys = new String[numOfShares];
        myShareValues = new String[numOfShares];
        int pos = 0;
        for (Pool myPool : myPools) {
            myShareKeys[pos] = "pool" + myPool.getKey().toString();
            myShareValues[pos++] = myPool.getName();
        }
        for (BusinessGroup group : myGroups) {
            myShareKeys[pos] = "grou" + group.getKey().toString();
            myShareValues[pos++] = group.getName();
        }
    }
    myShareEl = uifactory.addDropdownSingleselect("source.selector", "my.list", formLayout, myShareKeys, myShareValues, null);
    myShareEl.setDomReplacementWrapperRequired(false);
    myShareEl.getLabelC().setDomReplaceable(false);
    myShareEl.addActionListener(FormEvent.ONCHANGE);
    if (myPools.isEmpty() && myGroups.isEmpty()) {
        myShareEl.setEnabled(false);
    } else {
        myShareEl.select(myShareKeys[0], true);
        if (myPools.size() > 0) {
            Pool firstPool = myPools.get(0);
            PoolItemsSource source = new PoolItemsSource(getIdentity(), roles, firstPool);
            source.getDefaultParams().setFormat(restrictToFormat);
            updateSource(source);
        } else if (myGroups.size() > 0) {
            BusinessGroup firstGroup = myGroups.get(0);
            SharedItemsSource source = new SharedItemsSource(firstGroup, getIdentity(), roles, false);
            source.setRestrictToFormat(restrictToFormat);
            updateSource(source);
        }
    }
}
Also used : PoolItemsSource(org.olat.modules.qpool.ui.datasource.PoolItemsSource) SharedItemsSource(org.olat.modules.qpool.ui.datasource.SharedItemsSource) BusinessGroup(org.olat.group.BusinessGroup) Roles(org.olat.core.id.Roles) Pool(org.olat.modules.qpool.Pool)

Example 44 with Pool

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

the class ItemListMySharesController method doSelectPool.

private void doSelectPool(UserRequest ureq, Long poolKey) {
    Pool myPool = null;
    for (Pool pool : myPools) {
        if (poolKey.equals(pool.getKey())) {
            myPool = pool;
        }
    }
    if (myPool == null) {
        updateSource(new EmptyItemsSource());
    } else {
        PoolItemsSource source = new PoolItemsSource(getIdentity(), ureq.getUserSession().getRoles(), myPool);
        source.getDefaultParams().setFormat(restrictToFormat);
        updateSource(source);
    }
}
Also used : PoolItemsSource(org.olat.modules.qpool.ui.datasource.PoolItemsSource) EmptyItemsSource(org.olat.modules.qpool.ui.datasource.EmptyItemsSource) Pool(org.olat.modules.qpool.Pool)

Example 45 with Pool

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

the class PoolsAdminController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == createPool) {
        doEditPool(ureq, null);
    } else if (source == poolTable) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if ("edit-pool".equals(se.getCommand())) {
                Pool row = model.getObject(se.getIndex());
                doEditPool(ureq, row);
            } else if ("delete-pool".equals(se.getCommand())) {
                Pool row = model.getObject(se.getIndex());
                doConfirmDelete(ureq, row);
            } else if ("owners-pool".equals(se.getCommand())) {
                Pool row = model.getObject(se.getIndex());
                doManageOwners(ureq, row);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) Pool(org.olat.modules.qpool.Pool)

Aggregations

Pool (org.olat.modules.qpool.Pool)52 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)32 Test (org.junit.Test)30 Identity (org.olat.core.id.Identity)22 QuestionItem (org.olat.modules.qpool.QuestionItem)20 QItemType (org.olat.modules.qpool.model.QItemType)12 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)12 QuestionItemView (org.olat.modules.qpool.QuestionItemView)10 BusinessGroup (org.olat.group.BusinessGroup)8 ArrayList (java.util.ArrayList)6 List (java.util.List)4 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)4 TreeNode (org.olat.core.gui.components.tree.TreeNode)4 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)4 PoolItemsSource (org.olat.modules.qpool.ui.datasource.PoolItemsSource)4 Date (java.util.Date)2 Set (java.util.Set)2 StringTokenizer (java.util.StringTokenizer)2 Document (org.apache.lucene.document.Document)2 StringField (org.apache.lucene.document.StringField)2