//with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedRoot);
VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
//getDocument(..) ensures that InputStream is closed in every case.
Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
//if doc is null an error loading the document occured (IOException, qti.xml does not exist)
if (doc == null) return;
// extract title
Element el_assess = (Element)doc.selectSingleNode("questestinterop/assessment");
String title = el_assess.attributeValue("title");
if (title != null) addFormElement("qti.title", new StaticTextElement("qti.title", title));
else addFormElement("qti.title", new StaticTextElement("qti.title", "-"));
// extract objectives
HTMLTextAreaElement htmlTA = new HTMLTextAreaElement("qti.objectives", 10, 60);
htmlTA.setReadOnly(true);
Element el_objectives = (Element)doc.selectSingleNode("//questestinterop/assessment/objectives");
if (el_objectives != null) {
Element el_mat = (Element)el_objectives.selectSingleNode("material/mattext");
if (el_mat != null)
htmlTA.setValue(el_mat.getTextTrim());
} else htmlTA.setValue("-");
addFormElement("qti.objectives", htmlTA);
// extract num of questions
List items = doc.selectNodes("//item");
if (items.size() > 0)
addFormElement("qti.questions", new StaticTextElement("qti.questions", "" + items.size()));
else addFormElement("qti.questions", new StaticTextElement("qti.questions", "-"));
// extract time limit