use of org.olat.ims.qti.editor.beecom.objects.Item 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.objects.Item in project openolat by klemens.
the class QTIEditHelper method getFeedbacks.
/**
* @param object
* @return
*/
private static List<Feedback> getFeedbacks(QTIObject object) {
List<Feedback> feedbacks = null;
if (Item.class.isAssignableFrom(object.getClass())) {
Item item = (Item) object;
feedbacks = item.getItemfeedbacks();
} else if (Section.class.isAssignableFrom(object.getClass())) {
Section section = (Section) object;
feedbacks = section.getSectionfeedbacks();
} else if (Assessment.class.isAssignableFrom(object.getClass())) {
Assessment assessment = (Assessment) object;
feedbacks = assessment.getAssessfeedbacks();
}
return feedbacks;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.
the class QTIEditHelper method getMediaReferences.
/**
* Retrieves all referenced media by thisItem if filterOut is false,
* or all referenced media by other items if filterOut is true.
* <p>
* Iterates over all sections, items, etc. </br>
* -> if filterOut is true gets all references except those for thisItem.
* -> if filterOut is false gets all references for thisItem.
*
* @param qtiDocument
* @param thisItem
* @param filterOut
* @return Returns empty set if no reference found.
*/
private static Set<String> getMediaReferences(QTIDocument qtiDocument, Item thisItem, boolean filterOut) {
HashSet<String> returnSet = new HashSet<String>();
// sections
List sectionList = qtiDocument.getAssessment().getSections();
Iterator sectionIterator = sectionList.iterator();
while (sectionIterator.hasNext()) {
// section
Section section = (Section) sectionIterator.next();
List itemList = section.getItems();
Iterator listIterator = itemList.iterator();
while (listIterator.hasNext()) {
// item
Item item = (Item) listIterator.next();
if ((filterOut && thisItem.getIdent().equals(item.getIdent())) || (!filterOut && !thisItem.getIdent().equals(item.getIdent()))) {
continue;
}
// question
Material material = item.getQuestion().getQuestion();
if (material != null) {
String htmlContent = material.renderAsHtmlForEditor();
// parse filenames
returnSet.addAll(getMediaFileNames(htmlContent));
}
// responses
List responseList = item.getQuestion().getResponses();
Iterator responseIterator = responseList.iterator();
while (responseIterator.hasNext()) {
Response response = (Response) responseIterator.next();
Material responseMat = response.getContent();
// parse filenames
if (responseMat != null) {
returnSet.addAll(getMediaFileNames(responseMat.renderAsHtmlForEditor()));
}
// response-level feedback
Material responseFeedbackMat = QTIEditHelper.getFeedbackOlatRespMaterial(item, response.getIdent());
if (responseFeedbackMat != null) {
returnSet.addAll(getMediaFileNames(responseFeedbackMat.renderAsHtmlForEditor()));
}
}
// feedback
Material masteryMat = QTIEditHelper.getFeedbackMasteryMaterial(item);
if (masteryMat != null) {
returnSet.addAll(getMediaFileNames(masteryMat.renderAsHtmlForEditor()));
}
Material failureMat = QTIEditHelper.getFeedbackFailMaterial(item);
if (failureMat != null) {
returnSet.addAll(getMediaFileNames(failureMat.renderAsHtmlForEditor()));
}
}
}
return returnSet;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.
the class QTIEditorMainController method doConvertItemToQtiNode.
private GenericQtiNode doConvertItemToQtiNode(QuestionItemView qitemv) {
VFSContainer editorContainer = qtiPackage.getBaseDir();
Item theItem = qtiQpoolServiceProvider.exportToQTIEditor(qitemv, editorContainer);
GenericQtiNode node = new ItemNode(theItem, qtiPackage);
return node;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.
the class QTIEditorMainController method doDelete.
private void doDelete(GenericQtiNode clickedNode) {
// check if any media to delete as well
if (clickedNode.getUnderlyingQTIObject() instanceof Item) {
Item selectedItem = (Item) clickedNode.getUnderlyingQTIObject();
deletableMediaFiles = QTIEditHelper.getDeletableMedia(qtiPackage.getQTIDocument(), selectedItem);
}
// remove from underlying model
GenericQtiNode parentNode = (GenericQtiNode) clickedNode.getParent();
parentNode.removeQTIObjectAt(clickedNode.getPosition());
// remove from tree model
clickedNode.removeFromParent();
qtiPackage.serializeQTIDocument();
menuTree.setSelectedNodeId(clickedNode.getParent().getIdent());
parentNode.childNodeChanges();
}
Aggregations