use of org.olat.ims.qti.editor.beecom.objects.QTIDocument in project OpenOLAT by OpenOLAT.
the class QTIDocumentParser method parse.
public Object parse(Element element) {
// assert element.getName().equalsIgnoreCase("questestinterop");
QTIDocument qtiDocument = new QTIDocument();
Object tmp = null;
Element qticomment = element.element("qticomment");
qtiDocument.setQticomment((QTIObject) parserManager.parse(qticomment));
Element objectbank = element.element("objectbank");
tmp = parserManager.parse(objectbank);
if (tmp != null) {
qtiDocument.setObjectbank((QTIObject) tmp);
}
Element assesment = element.element("assessment");
tmp = parserManager.parse(assesment);
if (tmp != null) {
qtiDocument.setAssessment((Assessment) tmp);
}
return qtiDocument;
}
use of org.olat.ims.qti.editor.beecom.objects.QTIDocument 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;
}
}
use of org.olat.ims.qti.editor.beecom.objects.QTIDocument in project OpenOLAT by OpenOLAT.
the class TestFileResource method getQTIEditorPackageReader.
public static QTIReaderPackage getQTIEditorPackageReader(OLATResource resource) {
VFSContainer baseDir = FileResourceManager.getInstance().unzipContainerResource(resource);
QTIDocument document = getQTIDocument(resource);
return new QTIReaderPackage(baseDir, document);
}
use of org.olat.ims.qti.editor.beecom.objects.QTIDocument in project OpenOLAT by OpenOLAT.
the class QTI12ResultDetailsController method checkEssay.
private boolean checkEssay() {
QTIDocument doc = TestFileResource.getQTIDocument(repositoryEntry.getOlatResource());
if (doc != null && doc.getAssessment() != null) {
Assessment ass = doc.getAssessment();
// Sections with their Items
List<Section> sections = ass.getSections();
for (Section section : sections) {
List<Item> items = section.getItems();
for (Item item : items) {
String ident = item.getIdent();
if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
return true;
}
}
}
}
return false;
}
use of org.olat.ims.qti.editor.beecom.objects.QTIDocument 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;
}
}
Aggregations