Search in sources :

Example 1 with QuestionItem

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

the class QTIQPoolServiceProvider method importRepositoryEntry.

public List<QuestionItem> importRepositoryEntry(Identity owner, RepositoryEntry repositoryEntry, Locale defaultLocale) {
    OLATResourceable ores = repositoryEntry.getOlatResource();
    FileResourceManager frm = FileResourceManager.getInstance();
    File testFile = frm.getFileResource(ores);
    List<QuestionItem> importedItem = importItems(owner, defaultLocale, testFile.getName(), testFile);
    if (importedItem != null && importedItem.size() > 0) {
        dbInstance.getCurrentEntityManager().flush();
    }
    return importedItem;
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) OLATResourceable(org.olat.core.id.OLATResourceable) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 2 with QuestionItem

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

the class QTIQPoolServiceProvider method createItem.

public QuestionItem createItem(Identity owner, QTI12ItemFactory.Type type, String title, Locale defaultLocale) {
    Translator trans = Util.createPackageTranslator(QTIEditorMainController.class, defaultLocale);
    Item item;
    switch(type) {
        case sc:
            item = QTIEditHelper.createSCItem(trans);
            break;
        case mc:
            item = QTIEditHelper.createMCItem(trans);
            break;
        case kprim:
            item = QTIEditHelper.createKPRIMItem(trans);
            break;
        case fib:
            item = QTIEditHelper.createFIBItem(trans);
            break;
        case essay:
            item = QTIEditHelper.createEssayItem(trans);
            break;
        default:
            return null;
    }
    item.setLabel(title);
    item.setTitle(title);
    QTIImportProcessor processor = new QTIImportProcessor(owner, defaultLocale);
    Document doc = QTIEditHelper.itemToXml(item);
    Element itemEl = (Element) doc.selectSingleNode("questestinterop/item");
    QuestionItemImpl qitem = processor.processItem(itemEl, "", null, "OpenOLAT", Settings.getVersion(), null, null);
    // save to file System
    VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
    VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
    QTIEditHelper.serialiazeDoc(doc, leaf);
    return qitem;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) QuestionItem(org.olat.modules.qpool.QuestionItem) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) Translator(org.olat.core.gui.translator.Translator) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) Element(org.dom4j.Element) VFSContainer(org.olat.core.util.vfs.VFSContainer) Document(org.dom4j.Document)

Example 3 with QuestionItem

use of org.olat.modules.qpool.QuestionItem 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 4 with QuestionItem

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

the class QTI12ItemFactory method createItem.

@Override
public QuestionItem createItem(Identity owner, String title, Locale locale) {
    QTIQPoolServiceProvider spi = CoreSpringFactory.getImpl(QTIQPoolServiceProvider.class);
    QuestionItem newItem = spi.createItem(owner, type, title, locale);
    return newItem;
}
Also used : QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 5 with QuestionItem

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

the class QTIImportProcessor method process.

private List<QuestionItem> process(DocInfos docInfos) {
    List<QuestionItem> qItems = new ArrayList<>();
    if (docInfos.doc != null) {
        List<ItemInfos> itemInfos = getItemList(docInfos);
        for (ItemInfos itemInfo : itemInfos) {
            QuestionItemImpl qItem = processItem(docInfos, itemInfo, null);
            if (qItem != null) {
                processFiles(qItem, itemInfo, docInfos);
                qItem = questionItemDao.merge(qItem);
                qItems.add(qItem);
            }
        }
    }
    return qItems;
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) ArrayList(java.util.ArrayList) QuestionItem(org.olat.modules.qpool.QuestionItem)

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