Search in sources :

Example 11 with ParserManager

use of org.olat.ims.qti.editor.beecom.parser.ParserManager in project openolat by klemens.

the class QTI12To21ConverterTest method loadDocument.

private QTIDocument loadDocument(String filename) {
    try (InputStream in = QTI12To21ConverterTest.class.getResourceAsStream(filename)) {
        XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
        Document doc = xmlParser.parse(in, true);
        ParserManager parser = new ParserManager();
        return (QTIDocument) parser.parse(doc);
    } catch (Exception e) {
        log.error("Exception when parsing input QTI input stream for " + filename, e);
        return null;
    }
}
Also used : ParserManager(org.olat.ims.qti.editor.beecom.parser.ParserManager) QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) InputStream(java.io.InputStream) XMLParser(org.olat.core.util.xml.XMLParser) Document(org.dom4j.Document) QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) IMSEntityResolver(org.olat.ims.resources.IMSEntityResolver) XmlResourceNotFoundException(uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException) URISyntaxException(java.net.URISyntaxException) BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) ImsManifestException(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ImsManifestException) IOException(java.io.IOException)

Example 12 with ParserManager

use of org.olat.ims.qti.editor.beecom.parser.ParserManager in project openolat by klemens.

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)

Aggregations

ParserManager (org.olat.ims.qti.editor.beecom.parser.ParserManager)12 Document (org.dom4j.Document)8 QTIDocument (org.olat.ims.qti.editor.beecom.objects.QTIDocument)8 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 Element (org.dom4j.Element)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 XMLParser (org.olat.core.util.xml.XMLParser)6 Item (org.olat.ims.qti.editor.beecom.objects.Item)6 IMSEntityResolver (org.olat.ims.resources.IMSEntityResolver)6 QuestionItem (org.olat.modules.qpool.QuestionItem)4 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)4 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 URISyntaxException (java.net.URISyntaxException)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 Metadata (org.olat.ims.qti.editor.beecom.objects.Metadata)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 BadResourceException (uk.ac.ed.ph.jqtiplus.provision.BadResourceException)2 ImsManifestException (uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ImsManifestException)2