Search in sources :

Example 51 with QuestionItemShort

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);
    }
}
Also used : ExportFormatOptions(org.olat.modules.qpool.ExportFormatOptions) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QItemList(org.olat.modules.qpool.model.QItemList) List(java.util.List) ArrayList(java.util.ArrayList) MediaResource(org.olat.core.gui.media.MediaResource)

Example 52 with QuestionItemShort

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);
    }
}
Also used : HashMap(java.util.HashMap) QPoolSPI(org.olat.modules.qpool.QPoolSPI) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QItemList(org.olat.modules.qpool.model.QItemList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 53 with QuestionItemShort

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);
}
Also used : CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent)

Example 54 with QuestionItemShort

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);
    }
}
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 55 with QuestionItemShort

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);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QuestionItem(org.olat.modules.qpool.QuestionItem)

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