use of org.olat.ims.qti.editor.beecom.parser.ParserManager 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);
}
}
use of org.olat.ims.qti.editor.beecom.parser.ParserManager 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;
}
use of org.olat.ims.qti.editor.beecom.parser.ParserManager in project OpenOLAT by OpenOLAT.
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 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 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;
}
Aggregations