Search in sources :

Example 1 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class QTIQPoolServiceProvider method importBeecomItem.

public QuestionItemImpl importBeecomItem(Identity owner, ItemAndMetadata itemAndMetadata, VFSContainer sourceDir, Locale defaultLocale) {
    QTIImportProcessor processor = new QTIImportProcessor(owner, defaultLocale);
    String editor = null;
    String editorVersion = null;
    Item item = itemAndMetadata.getItem();
    if (!item.isAlient()) {
        editor = "OpenOLAT";
        editorVersion = Settings.getVersion();
    }
    Document doc = QTIEditHelper.itemToXml(item);
    Element itemEl = (Element) doc.selectSingleNode("questestinterop/item");
    QuestionItemImpl qitem = processor.processItem(itemEl, "", null, editor, editorVersion, null, itemAndMetadata);
    // save to file System
    VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
    VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
    QTIEditHelper.serialiazeDoc(doc, leaf);
    if (sourceDir != null) {
        List<String> materials = processor.getMaterials(itemEl);
        // copy materials
        for (String material : materials) {
            VFSItem sourceItem = sourceDir.resolve(material);
            if (sourceItem instanceof VFSLeaf) {
                VFSLeaf targetItem = baseDir.createChildLeaf(material);
                VFSManager.copyContent((VFSLeaf) sourceItem, targetItem);
            }
        }
    }
    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) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) Element(org.dom4j.Element) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Document(org.dom4j.Document)

Example 2 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class QTIQPoolServiceProvider method exportToEditorPackage.

public void exportToEditorPackage(QTIEditorPackageImpl editorPackage, List<QuestionItemShort> items, boolean newTest) {
    VFSContainer editorContainer = editorPackage.getBaseDir();
    List<Long> itemKeys = toKeys(items);
    List<QuestionItemFull> fullItems = questionItemDao.loadByIds(itemKeys);
    Section section = editorPackage.getQTIDocument().getAssessment().getSections().get(0);
    if (newTest) {
        // remove autogenerated question
        section.getItems().clear();
    }
    QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage);
    for (QuestionItemFull fullItem : fullItems) {
        Element itemEl = processor.exportToQTIEditor(fullItem, editorContainer);
        Item item = (Item) new ParserManager().parse(itemEl);
        item.setIdent(QTIEditHelper.generateNewIdent(item.getIdent()));
        section.getItems().add(item);
    }
}
Also used : ParserManager(org.olat.ims.qti.editor.beecom.parser.ParserManager) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) VFSContainer(org.olat.core.util.vfs.VFSContainer) Element(org.dom4j.Element) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 3 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class QTIQPoolServiceProvider method exportToQTIEditor.

/**
 * Export to QTI editor an item from the pool. The ident of the item
 * is always regenerated as an UUID.
 * @param qitem
 * @param editorContainer
 * @return
 */
public Item exportToQTIEditor(QuestionItemShort qitem, VFSContainer editorContainer) {
    QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage);
    QuestionItemFull fullItem = questionItemDao.loadById(qitem.getKey());
    Element itemEl = processor.exportToQTIEditor(fullItem, editorContainer);
    Item exportedItem = (Item) new ParserManager().parse(itemEl);
    exportedItem.setIdent(QTIEditHelper.generateNewIdent(exportedItem.getIdent()));
    return exportedItem;
}
Also used : ParserManager(org.olat.ims.qti.editor.beecom.parser.ParserManager) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) Element(org.dom4j.Element)

Example 4 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item 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 5 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.

the class CSVToQuestionConverter method processFeedbackCorrectAnswer.

private void processFeedbackCorrectAnswer(String[] parts) {
    if (currentItem == null || parts.length < 2)
        return;
    String feedback = parts[1];
    if (StringHelper.containsNonWhitespace(feedback)) {
        Item item = currentItem.getItem();
        Control control = QTIEditHelper.getControl(item);
        if (control.getFeedback() != 1) {
            control.setFeedback(1);
        }
        QTIEditHelper.setFeedbackMastery(item, feedback);
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) Control(org.olat.ims.qti.editor.beecom.objects.Control)

Aggregations

Item (org.olat.ims.qti.editor.beecom.objects.Item)92 VFSItem (org.olat.core.util.vfs.VFSItem)38 Section (org.olat.ims.qti.editor.beecom.objects.Section)28 ArrayList (java.util.ArrayList)24 VFSContainer (org.olat.core.util.vfs.VFSContainer)18 Control (org.olat.ims.qti.editor.beecom.objects.Control)18 Element (org.dom4j.Element)16 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)16 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)16 Translator (org.olat.core.gui.translator.Translator)14 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)14 Response (org.olat.ims.qti.editor.beecom.objects.Response)14 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)14 File (java.io.File)12 QuestionItem (org.olat.modules.qpool.QuestionItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)10 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)10 SectionNode (org.olat.ims.qti.editor.tree.SectionNode)10 StatisticItem (org.olat.ims.qti.statistics.model.StatisticItem)10