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);
}
}
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);
}
}
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);
}
}
}
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);
}
}
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);
}
Aggregations