use of org.olat.ims.qti.editor.beecom.parser.ParserManager in project openolat by klemens.
the class TestFileResource method getQTIDocument.
public static QTIDocument getQTIDocument(OLATResource resource) {
File packageDir = FileResourceManager.getInstance().unzipFileResource(resource);
File qtiFile = new File(packageDir, ImsRepositoryResolver.QTI_FILE);
try (InputStream in = new FileInputStream(qtiFile)) {
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
Document doc = xmlParser.parse(in, true);
ParserManager parser = new ParserManager();
QTIDocument document = (QTIDocument) parser.parse(doc);
return document;
} catch (Exception e) {
log.error("Exception when parsing input QTI input stream for ", e);
return null;
}
}
use of org.olat.ims.qti.editor.beecom.parser.ParserManager in project openolat by klemens.
the class QTIEditHelper method readItemXml.
public static Item readItemXml(VFSLeaf leaf) {
Document doc = null;
try {
InputStream is = leaf.getInputStream();
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
doc = xmlParser.parse(is, false);
Element item = (Element) doc.selectSingleNode("questestinterop/item");
ParserManager parser = new ParserManager();
Item qtiItem = (Item) parser.parse(item);
is.close();
return qtiItem;
} catch (Exception e) {
log.error("", e);
return null;
}
}
use of org.olat.ims.qti.editor.beecom.parser.ParserManager in project openolat by klemens.
the class QTIEditorPackageImpl method getQTIDocument.
/**
* @return Reutrns the QTIDocument structure
*/
public QTIDocument getQTIDocument() {
if (qtiDocument == null) {
if (hasSerializedQTIDocument()) {
qtiDocument = loadSerializedQTIDocument();
resumed = true;
} else {
unzipPackage();
Document doc = loadQTIDocument();
if (doc != null) {
ParserManager parser = new ParserManager();
qtiDocument = (QTIDocument) parser.parse(doc);
// grab assessment type
Metadata meta = qtiDocument.getAssessment().getMetadata();
String assessType = meta.getField(AssessmentInstance.QMD_LABEL_TYPE);
if (assessType != null) {
qtiDocument.setSurvey(assessType.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY));
}
resumed = false;
} else {
qtiDocument = null;
}
}
}
return qtiDocument;
}
use of org.olat.ims.qti.editor.beecom.parser.ParserManager in project OpenOLAT by OpenOLAT.
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;
}
}
use of org.olat.ims.qti.editor.beecom.parser.ParserManager in project OpenOLAT by OpenOLAT.
the class TestFileResource method getQTIDocument.
public static QTIDocument getQTIDocument(OLATResource resource) {
File packageDir = FileResourceManager.getInstance().unzipFileResource(resource);
File qtiFile = new File(packageDir, ImsRepositoryResolver.QTI_FILE);
try (InputStream in = new FileInputStream(qtiFile)) {
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
Document doc = xmlParser.parse(in, true);
ParserManager parser = new ParserManager();
QTIDocument document = (QTIDocument) parser.parse(doc);
return document;
} catch (Exception e) {
log.error("Exception when parsing input QTI input stream for ", e);
return null;
}
}
Aggregations