Search in sources :

Example 1 with ItemAndMetadata

use of org.olat.ims.qti.questionimport.ItemAndMetadata in project OpenOLAT by OpenOLAT.

the class QTIQPoolServiceProvider method importBeecomItem.

public List<QuestionItem> importBeecomItem(Identity owner, List<ItemAndMetadata> items, Locale defaultLocale) {
    int count = 0;
    List<QuestionItem> qItems = new ArrayList<>(items.size());
    for (ItemAndMetadata item : items) {
        QuestionItem qItem = importBeecomItem(owner, item, null, defaultLocale);
        qItems.add(qItem);
        if (++count % 10 == 0) {
            dbInstance.commitAndCloseSession();
        }
    }
    return qItems;
}
Also used : ArrayList(java.util.ArrayList) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 2 with ItemAndMetadata

use of org.olat.ims.qti.questionimport.ItemAndMetadata in project OpenOLAT by OpenOLAT.

the class QTIEditorMainController method doExportQItem.

private void doExportQItem() {
    GenericQtiNode selectedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
    if (selectedNode instanceof ItemNode) {
        ItemNode itemNode = (ItemNode) selectedNode;
        QTIObject qtiObject = itemNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Item) {
            ItemAndMetadata item = new ItemAndMetadata((Item) qtiObject);
            VFSContainer editorContainer = qtiPackage.getBaseDir();
            qtiQpoolServiceProvider.importBeecomItem(getIdentity(), item, editorContainer, getLocale());
            showInfo("export.qpool.successful", "1");
        }
    } else if (selectedNode instanceof SectionNode) {
        SectionNode sectionNode = (SectionNode) selectedNode;
        QTIObject qtiObject = sectionNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Section) {
            int count = doExportSection((Section) qtiObject);
            showInfo("export.qpool.successful", Integer.toString(count));
        }
    } else if (selectedNode instanceof AssessmentNode) {
        AssessmentNode assessmentNode = (AssessmentNode) selectedNode;
        QTIObject qtiObject = assessmentNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Assessment) {
            int count = doExportAssessment((Assessment) qtiObject);
            showInfo("export.qpool.successful", Integer.toString(count));
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) AssessmentNode(org.olat.ims.qti.editor.tree.AssessmentNode) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) SectionNode(org.olat.ims.qti.editor.tree.SectionNode) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 3 with ItemAndMetadata

use of org.olat.ims.qti.questionimport.ItemAndMetadata in project OpenOLAT by OpenOLAT.

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)

Example 4 with ItemAndMetadata

use of org.olat.ims.qti.questionimport.ItemAndMetadata in project openolat by klemens.

the class QuestionListController method doOpenExcelImportQTI12.

private void doOpenExcelImportQTI12(UserRequest ureq) {
    removeAsListenerAndDispose(excelImportWizard);
    final ItemsPackage importPackage = new ItemsPackage();
    Step additionalStep = null;
    if (getSource().askEditable()) {
        additionalStep = new EditableStep(ureq);
    }
    final org.olat.ims.qti.questionimport.ImportOptions options = new org.olat.ims.qti.questionimport.ImportOptions();
    options.setShuffle(true);
    Step start = new org.olat.ims.qti.questionimport.QImport_1_InputStep(ureq, importPackage, options, additionalStep);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            List<ItemAndMetadata> itemsToImport = importPackage.getItems();
            QTIQPoolServiceProvider spi = CoreSpringFactory.getImpl(QTIQPoolServiceProvider.class);
            List<QuestionItem> importItems = spi.importBeecomItem(getIdentity(), itemsToImport, getLocale());
            for (QuestionItem item : importItems) {
                QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_IMPORT);
                builder.withAfter(item);
                qpoolService.persist(builder.create());
            }
            boolean editable = true;
            if (getSource().askEditable()) {
                Object editableCtx = runContext.get("editable");
                editable = (editableCtx instanceof Boolean) ? ((Boolean) editableCtx).booleanValue() : false;
            }
            qpoolService.index(importItems);
            int postImported = getSource().postImport(importItems, editable);
            if (postImported > 0) {
                getItemsTable().reset();
            }
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    excelImportWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("import.excellike.12"), "o_sel_qpool_excel_import_wizard");
    listenTo(excelImportWizard);
    getWindowControl().pushAsModalDialog(excelImportWizard.getInitialComponent());
}
Also used : QImport_1_InputStep(org.olat.ims.qti21.questionimport.QImport_1_InputStep) Step(org.olat.core.gui.control.generic.wizard.Step) Export_1_TypeStep(org.olat.modules.qpool.ui.wizard.Export_1_TypeStep) ImportAuthor_1_ChooseMemberStep(org.olat.modules.qpool.ui.wizard.ImportAuthor_1_ChooseMemberStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) QImport_1_InputStep(org.olat.ims.qti21.questionimport.QImport_1_InputStep) QTIQPoolServiceProvider(org.olat.ims.qti.qpool.QTIQPoolServiceProvider) UserRequest(org.olat.core.gui.UserRequest) AssessmentItemsPackage(org.olat.ims.qti21.questionimport.AssessmentItemsPackage) ItemsPackage(org.olat.ims.qti.questionimport.ItemsPackage) QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) AssessmentItemAndMetadata(org.olat.ims.qti21.questionimport.AssessmentItemAndMetadata) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) QuestionItem(org.olat.modules.qpool.QuestionItem) ImportOptions(org.olat.ims.qti21.questionimport.ImportOptions) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback)

Example 5 with ItemAndMetadata

use of org.olat.ims.qti.questionimport.ItemAndMetadata 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

ItemAndMetadata (org.olat.ims.qti.questionimport.ItemAndMetadata)10 ArrayList (java.util.ArrayList)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 Item (org.olat.ims.qti.editor.beecom.objects.Item)4 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)4 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)4 ItemsPackage (org.olat.ims.qti.questionimport.ItemsPackage)4 QuestionItem (org.olat.modules.qpool.QuestionItem)4 Collection (java.util.Collection)2 List (java.util.List)2 UserRequest (org.olat.core.gui.UserRequest)2 Event (org.olat.core.gui.control.Event)2 WindowControl (org.olat.core.gui.control.WindowControl)2 Step (org.olat.core.gui.control.generic.wizard.Step)2 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)2 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)2 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)2 ContactList (org.olat.core.util.mail.ContactList)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)2