Search in sources :

Example 61 with QuestionItemView

use of org.olat.modules.qpool.QuestionItemView in project openolat by klemens.

the class ItemListMyCompetencesController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (selectLink == source) {
        Set<Integer> selections = getItemsTable().getMultiSelectedIndex();
        if (!selections.isEmpty()) {
            List<QuestionItemView> items = getItemViews(selections);
            fireEvent(ureq, new QItemViewEvent("select-item", items));
        }
    } else if (myCompetenceLevelsEl == source) {
        String selectedKey = myCompetenceLevelsEl.getSelectedKey();
        if (StringHelper.isLong(selectedKey)) {
            doSelectLevel(ureq, selectedKey);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : QItemViewEvent(org.olat.modules.qpool.ui.events.QItemViewEvent) QuestionItemView(org.olat.modules.qpool.QuestionItemView)

Example 62 with QuestionItemView

use of org.olat.modules.qpool.QuestionItemView in project openolat by klemens.

the class ItemListMyListsController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (selectLink == source) {
        Set<Integer> selections = getItemsTable().getMultiSelectedIndex();
        if (!selections.isEmpty()) {
            List<QuestionItemView> items = getItemViews(selections);
            fireEvent(ureq, new QItemViewEvent("select-item", items));
        }
    } else if (myListEl == source) {
        String selectedCollKey = myListEl.getSelectedKey();
        if (StringHelper.isLong(selectedCollKey)) {
            Long collectionKey = Long.parseLong(selectedCollKey);
            doSelectCollection(ureq, collectionKey);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : QItemViewEvent(org.olat.modules.qpool.ui.events.QItemViewEvent) QuestionItemView(org.olat.modules.qpool.QuestionItemView)

Example 63 with QuestionItemView

use of org.olat.modules.qpool.QuestionItemView in project openolat by klemens.

the class ItemListMySharesController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (selectLink == source) {
        Set<Integer> selections = getItemsTable().getMultiSelectedIndex();
        if (!selections.isEmpty()) {
            List<QuestionItemView> items = getItemViews(selections);
            fireEvent(ureq, new QItemViewEvent("select-item", items));
        }
    } else if (myShareEl == source) {
        String selectedKey = myShareEl.getSelectedKey();
        if (selectedKey != null && selectedKey.length() > 4) {
            String key = selectedKey.substring(4);
            if (StringHelper.isLong(key)) {
                Long resourceKey = Long.parseLong(key);
                if (selectedKey.startsWith("pool")) {
                    doSelectPool(ureq, resourceKey);
                } else if (selectedKey.startsWith("grou")) {
                    doSelectBusinessGroup(ureq, resourceKey);
                }
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : QItemViewEvent(org.olat.modules.qpool.ui.events.QItemViewEvent) QuestionItemView(org.olat.modules.qpool.QuestionItemView)

Example 64 with QuestionItemView

use of org.olat.modules.qpool.QuestionItemView in project openolat by klemens.

the class AssessmentTestComposerController method doInsert.

private void doInsert(UserRequest ureq, List<QuestionItemView> items) {
    TreeNode selectedNode = menuTree.getSelectedNode();
    TreeNode sectionNode = getNearestSection(selectedNode);
    boolean allOk = true;
    String firstItemId = null;
    Map<AssessmentItemRef, AssessmentItem> flyingObjects = new HashMap<>();
    try {
        AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
        for (QuestionItemView item : items) {
            QuestionItemFull qItem = qti21QPoolServiceProvider.getFullQuestionItem(item);
            AssessmentItem assessmentItem = qti21QPoolServiceProvider.exportToQTIEditor(qItem, getLocale(), unzippedDirRoot);
            if (assessmentItem != null) {
                AssessmentItemRef itemRef = doInsert(section, assessmentItem);
                if (firstItemId == null) {
                    firstItemId = itemRef.getIdentifier().toString();
                }
                flyingObjects.put(itemRef, assessmentItem);
                ManifestMetadataBuilder metadata = manifestBuilder.getResourceBuilderByHref(itemRef.getHref().toString());
                metadata.appendMetadataFrom(qItem, assessmentItem, getLocale());
                metadata.setOpenOLATMetadataCopiedAt(new Date());
            } else {
                allOk &= false;
            }
        }
    } catch (IOException | URISyntaxException e) {
        showError("error.import.question");
        logError("", e);
    }
    if (!allOk) {
        showError("error.import.question");
    }
    if (firstItemId != null) {
        // persist metadata
        doSaveAssessmentTest(ureq, flyingObjects);
        doSaveManifest();
        updateTreeModel(false);
        TreeNode newItemNode = menuTree.getTreeModel().getNodeById(firstItemId);
        menuTree.setSelectedNode(newItemNode);
        menuTree.open(newItemNode);
        partEditorFactory(ureq, newItemNode);
    }
}
Also used : HashMap(java.util.HashMap) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) Date(java.util.Date) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) QuestionItemView(org.olat.modules.qpool.QuestionItemView)

Example 65 with QuestionItemView

use of org.olat.modules.qpool.QuestionItemView in project openolat by klemens.

the class QTIEditorMainController method doInsert.

private void doInsert(UserRequest ureq, TreePosition tp, Object toInsert) {
    // new node
    GenericQtiNode parentTargetNode = (GenericQtiNode) tp.getParentTreeNode();
    if (toInsert instanceof GenericQtiNode) {
        doInsert(parentTargetNode, (GenericQtiNode) toInsert, tp.getChildpos());
    } else if (toInsert instanceof QuestionItemView) {
        QuestionItemView item = (QuestionItemView) toInsert;
        GenericQtiNode insertNode = doConvertItemToQtiNode(item);
        doInsert(parentTargetNode, insertNode, tp.getChildpos());
    } else if (toInsert instanceof Collection) {
        int position = tp.getChildpos();
        @SuppressWarnings("unchecked") Collection<QuestionItemView> items = (Collection<QuestionItemView>) toInsert;
        for (QuestionItemView item : items) {
            GenericQtiNode insertNode = doConvertItemToQtiNode(item);
            doInsert(parentTargetNode, insertNode, position++);
        }
    } else if (toInsert instanceof ItemsPackage) {
        ItemsPackage itemsToImport = (ItemsPackage) toInsert;
        List<ItemAndMetadata> items = itemsToImport.getItems();
        int pos = tp.getChildpos();
        for (ItemAndMetadata item : items) {
            GenericQtiNode insertNode = new ItemNode(item.getItem(), qtiPackage);
            doInsert(parentTargetNode, insertNode, pos++);
        }
    }
    event(ureq, menuTree, new Event(MenuTree.COMMAND_TREENODE_CLICKED));
    qtiPackage.serializeQTIDocument();
    updateWarning();
}
Also used : ItemNode(org.olat.ims.qti.editor.tree.ItemNode) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode) Collection(java.util.Collection) QItemViewEvent(org.olat.modules.qpool.ui.events.QItemViewEvent) Event(org.olat.core.gui.control.Event) ArrayList(java.util.ArrayList) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) QuestionItemView(org.olat.modules.qpool.QuestionItemView) ItemsPackage(org.olat.ims.qti.questionimport.ItemsPackage)

Aggregations

QuestionItemView (org.olat.modules.qpool.QuestionItemView)118 Test (org.junit.Test)78 QuestionItem (org.olat.modules.qpool.QuestionItem)76 Identity (org.olat.core.id.Identity)72 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)62 ArrayList (java.util.ArrayList)34 QItemType (org.olat.modules.qpool.model.QItemType)18 BusinessGroup (org.olat.group.BusinessGroup)16 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)14 ItemWrapper (org.olat.modules.qpool.model.ItemWrapper)12 QItemViewEvent (org.olat.modules.qpool.ui.events.QItemViewEvent)12 SortKey (org.olat.core.commons.persistence.SortKey)10 MarkImpl (org.olat.core.commons.services.mark.impl.MarkImpl)10 Pool (org.olat.modules.qpool.Pool)10 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)10 Taxonomy (org.olat.modules.taxonomy.Taxonomy)8 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)8 SecurityGroupMembershipImpl (org.olat.basesecurity.SecurityGroupMembershipImpl)6 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)6 OLATResource (org.olat.resource.OLATResource)6