Search in sources :

Example 36 with QuestionItem

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

the class QuestionListController method doCreateNewItem.

private void doCreateNewItem(UserRequest ureq, String title, TaxonomyLevel taxonomyLevel, QItemFactory factory) {
    QuestionItem item = factory.createItem(getIdentity(), title, getLocale());
    List<QuestionItem> newItems = Collections.singletonList(item);
    getSource().postImport(newItems, false);
    if (taxonomyLevel != null && item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        itemImpl.setTaxonomyLevel(taxonomyLevel);
        qpoolService.updateItem(itemImpl);
    }
    if (licenseModule.isEnabled(licenseHandler)) {
        // The QItemFactory may create a no license as part of the import process.
        // But for new question items the default license should be created.
        // So delete the no license first, so that the default license can be created.
        licenseService.delete(item);
        licenseService.createDefaultLicense(item, licenseHandler, getIdentity());
    }
    getItemsTable().reset();
    dbInstance.commit();
    qpoolService.index(newItems);
    QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_NEW);
    builder.withAfter(item);
    qpoolService.persist(builder.create());
    QPoolEvent qce = new QPoolEvent(QPoolEvent.ITEM_CREATED);
    fireEvent(ureq, qce);
    doOpenDetails(ureq, item);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 37 with QuestionItem

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

the class AbstractItemListController method getIndex.

public List<Integer> getIndex(Collection<QuestionItem> items) {
    Set<Long> itemKeys = new HashSet<>();
    for (QuestionItem item : items) {
        itemKeys.add(item.getKey());
    }
    List<Integer> index = new ArrayList<>(items.size());
    for (int i = model.getObjects().size(); i-- > 0; ) {
        ItemRow row = model.getObject(i);
        if (row != null && itemKeys.contains(row.getKey())) {
            index.add(i);
        }
    }
    return index;
}
Also used : ArrayList(java.util.ArrayList) QuestionItem(org.olat.modules.qpool.QuestionItem) HashSet(java.util.HashSet)

Example 38 with QuestionItem

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

the class AbstractItemListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == itemsTable) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if ("rSelect".equals(se.getCommand())) {
                ItemRow row = model.getObject(se.getIndex());
                if (row != null) {
                    doClick(ureq, row);
                }
            } else if ("select-item".equals(se.getCommand())) {
                ItemRow row = getModel().getObject(se.getIndex());
                if (row != null) {
                    doSelect(ureq, row);
                }
            } else if ("quick-view".equals(se.getCommand())) {
                int rowIndex = se.getIndex();
                if (rowIndex >= 0) {
                    if (itemsTable.isDetailsExpended(rowIndex)) {
                        itemsTable.collapseDetails(rowIndex);
                    } else {
                        itemsTable.collapseAllDetails();
                        ItemRow row = getModel().getObject(rowIndex);
                        if (row != null) {
                            itemsTable.expandDetails(rowIndex);
                            QuestionItem item = qpoolService.loadItemById(row.getKey());
                            previewCtrl.updateItem(ureq, item);
                            quickViewMetadataCtrl.setItem(ureq, item);
                        }
                    }
                }
            }
        }
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        if ("select".equals(link.getCmd())) {
            ItemRow row = (ItemRow) link.getUserObject();
            doSelect(ureq, row);
        } else if ("mark".equals(link.getCmd())) {
            ItemRow row = (ItemRow) link.getUserObject();
            if (doMark(row)) {
                link.setIconLeftCSS(Mark.MARK_CSS_LARGE);
            } else {
                link.setIconLeftCSS(Mark.MARK_ADD_CSS_LARGE);
            }
            link.getComponent().setDirty(true);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 39 with QuestionItem

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

the class CopyConfirmationController method logAudit.

private void logAudit(List<QuestionItem> items) {
    for (QuestionItem item : items) {
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_COPY);
        builder.withAfter(item);
        qpoolService.persist(builder.create());
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 40 with QuestionItem

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

the class QuestionPoolMainEditorController method activateQuestionItem.

private void activateQuestionItem(UserRequest ureq, Long itemKey, List<ContextEntry> entries) {
    QuestionItem item = qpoolService.loadItemById(itemKey);
    if (item == null)
        return;
    List<Identity> authors = qpoolService.getAuthors(item);
    if (authors.contains(getIdentity())) {
        activateNode(ureq, treeModel.getMyQuestionsNode(), entries);
        return;
    }
    if (item.getTaxonomyLevel() != null && item.getQuestionStatus() != null && QuestionStatus.finalVersion.equals(item.getQuestionStatus()) && treeModel.getFinalNode() != null) {
        TreeNode levelNode = treeModel.getFinalTanonomyLevelNode(item.getTaxonomyLevel());
        if (levelNode != null) {
            activateNode(ureq, levelNode, entries);
            return;
        }
    }
    if (treeModel.getSharesNode() != null) {
        List<QuestionItem2Resource> shares = qpoolService.getSharedResourceInfosByItem(item);
        for (QuestionItem2Resource share : shares) {
            TreeNode levelNode = treeModel.getShareNode(share);
            if (levelNode != null) {
                activateNode(ureq, levelNode, entries);
                return;
            }
        }
        List<QuestionItem2Pool> pools = qpoolService.getPoolInfosByItem(item);
        for (QuestionItem2Pool pool : pools) {
            TreeNode levelNode = treeModel.getShareNode(pool);
            if (levelNode != null) {
                activateNode(ureq, levelNode, entries);
                return;
            }
        }
    }
}
Also used : 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) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) QuestionItem2Resource(org.olat.modules.qpool.QuestionItem2Resource)

Aggregations

QuestionItem (org.olat.modules.qpool.QuestionItem)260 Test (org.junit.Test)160 Identity (org.olat.core.id.Identity)122 QItemType (org.olat.modules.qpool.model.QItemType)82 QuestionItemView (org.olat.modules.qpool.QuestionItemView)76 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)54 ArrayList (java.util.ArrayList)42 File (java.io.File)32 BusinessGroup (org.olat.group.BusinessGroup)32 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)32 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)30 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)28 URL (java.net.URL)24 Pool (org.olat.modules.qpool.Pool)20 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)16 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)16 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)14 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 VFSItem (org.olat.core.util.vfs.VFSItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)12