use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.
the class QuestionListController method doExecuteExport.
private void doExecuteExport(UserRequest ureq, StepsRunContext runContext) {
ExportFormatOptions format = (ExportFormatOptions) runContext.get("format");
@SuppressWarnings("unchecked") List<QuestionItemShort> items = (List<QuestionItemShort>) runContext.get("itemsToExport");
MediaResource mr = qpoolService.export(items, format, getLocale());
if (mr != null) {
ureq.getDispatchResult().setResultingMediaResource(mr);
}
}
use of org.olat.modules.qpool.QuestionItemShort in project OpenOLAT by OpenOLAT.
the class QuestionListController method doConfirmConversion.
private void doConfirmConversion(UserRequest ureq, List<QuestionItemShort> items) {
Map<String, List<QuestionItemShort>> formatToItems = new HashMap<>();
List<QPoolSPI> spies = qpoolModule.getQuestionPoolProviders();
for (QuestionItemShort item : items) {
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<>(items.size());
formatToItems.put(sp.getFormat(), convertItems);
}
convertItems.add(item);
}
}
}
if (formatToItems.isEmpty()) {
showWarning("convert.item.not.possible");
} else {
conversionConfirmationCtrl = new ConversionConfirmationController(ureq, getWindowControl(), formatToItems, getSource());
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 OpenOLAT.
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 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.QuestionItemShort in project OpenOLAT by OpenOLAT.
the class MetadataBulkChangeController method formOK.
@Override
protected void formOK(UserRequest ureq) {
updatedItems = new ArrayList<>();
for (QuestionItemShort item : items) {
QuestionItem fullItem = qpoolService.loadItemById(item.getKey());
if (fullItem instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) fullItem;
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
builder.withBefore(itemImpl);
formOKGeneral(itemImpl);
formOKQuestion(itemImpl);
formOKTechnical(itemImpl);
formOKRights(itemImpl);
QuestionItem merged = qpoolService.updateItem(itemImpl);
builder.withAfter(itemImpl);
qpoolService.persist(builder.create());
updatedItems.add(merged);
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
Aggregations