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