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;
}
}
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);
}
}
Aggregations