use of org.olat.ims.qti.editor.beecom.objects.QTIObject 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.QTIObject in project OpenOLAT by OpenOLAT.
the class SectionParser method parse.
public Object parse(Element element) {
// assert element.getName().equalsIgnoreCase("questestinterop");
Section section = new Section();
// attributes
section.setIdent(element.attribute("ident").getValue());
section.setTitle(element.attribute("title").getValue());
// elements
// DURATION
Duration duration = (Duration) parserManager.parse(element.element("duration"));
section.setDuration(duration);
List sectioncontrolsXML = element.elements("sectioncontrol");
List<Object> sectioncontrols = new ArrayList<>();
for (Iterator i = sectioncontrolsXML.iterator(); i.hasNext(); ) {
sectioncontrols.add(parserManager.parse((Element) i.next()));
}
if (sectioncontrols.size() == 0) {
sectioncontrols.add(new Control());
}
section.setSectioncontrols(sectioncontrols);
// SELECTION ORDERING
SelectionOrdering selectionOrdering = (SelectionOrdering) parserManager.parse(element.element("selection_ordering"));
if (selectionOrdering != null) {
section.setSelection_ordering(selectionOrdering);
} else {
section.setSelection_ordering(new SelectionOrdering());
}
// SECTIONS
List sectionsXML = element.elements("section");
List<Object> sections = new ArrayList<>();
for (Iterator i = sectionsXML.iterator(); i.hasNext(); ) {
sections.add(parserManager.parse((Element) i.next()));
}
section.setSections(sections);
// ITEMS
List itemsXML = element.elements("item");
List<Object> items = new ArrayList<>();
for (Iterator i = itemsXML.iterator(); i.hasNext(); ) {
items.add(parserManager.parse((Element) i.next()));
}
section.setItems(items);
// OBJECTIVES
Element mattext = (Element) element.selectSingleNode("./objectives/material/mattext");
if (mattext != null)
section.setObjectives(mattext.getTextTrim());
// FEEDBACKS
List feedbacksXML = element.elements("sectionfeedback");
List<QTIObject> feedbacks = new ArrayList<>();
for (Iterator i = feedbacksXML.iterator(); i.hasNext(); ) {
QTIObject tmp = (QTIObject) parserManager.parse((Element) i.next());
feedbacks.add(tmp);
}
section.setSectionfeedbacks(feedbacks);
// OUTCOMES_PROCESSING
// TODO: maybe we should use the OutcomesProcessing object and parser here? Same as on
// assessment level?
QTIObject outcomes_processing = (QTIObject) parserManager.parse(element.element("outcomes_processing"));
section.setOutcomes_processing(outcomes_processing);
return section;
}
use of org.olat.ims.qti.editor.beecom.objects.QTIObject in project openolat by klemens.
the class QTIEditorMainController method doExportQItem.
private void doExportQItem() {
GenericQtiNode selectedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
if (selectedNode instanceof ItemNode) {
ItemNode itemNode = (ItemNode) selectedNode;
QTIObject qtiObject = itemNode.getUnderlyingQTIObject();
if (qtiObject instanceof Item) {
ItemAndMetadata item = new ItemAndMetadata((Item) qtiObject);
VFSContainer editorContainer = qtiPackage.getBaseDir();
qtiQpoolServiceProvider.importBeecomItem(getIdentity(), item, editorContainer, getLocale());
showInfo("export.qpool.successful", "1");
}
} else if (selectedNode instanceof SectionNode) {
SectionNode sectionNode = (SectionNode) selectedNode;
QTIObject qtiObject = sectionNode.getUnderlyingQTIObject();
if (qtiObject instanceof Section) {
int count = doExportSection((Section) qtiObject);
showInfo("export.qpool.successful", Integer.toString(count));
}
} else if (selectedNode instanceof AssessmentNode) {
AssessmentNode assessmentNode = (AssessmentNode) selectedNode;
QTIObject qtiObject = assessmentNode.getUnderlyingQTIObject();
if (qtiObject instanceof Assessment) {
int count = doExportAssessment((Assessment) qtiObject);
showInfo("export.qpool.successful", Integer.toString(count));
}
}
}
use of org.olat.ims.qti.editor.beecom.objects.QTIObject in project openolat by klemens.
the class MaterialFormController method formOK.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
*/
@Override
protected void formOK(UserRequest ureq) {
// trust authors, don't to XSS filtering
String newHtml = richText.getRawValue();
// the text fragment is saved in a cdata, remove cdata from movie plugin
newHtml = newHtml.replace("// <![CDATA[", "").replace("// ]]>", "");
// Use explicit return which create a P tag if you want a line break.
if (newHtml.startsWith("<br />") && newHtml.length() > 6)
newHtml = newHtml.substring(6);
if (newHtml.endsWith("<br />") && newHtml.length() > 6)
newHtml = newHtml.substring(0, newHtml.length() - 6);
// Remove any conditional comments due to strange behavior in test (OLAT-4518)
Filter conditionalCommentFilter = FilterFactory.getConditionalHtmlCommentsFilter();
newHtml = conditionalCommentFilter.filter(newHtml);
//
if (htmlContent.equals(newHtml)) {
// No changes. Cancel editing.
fireEvent(ureq, Event.CANCELLED_EVENT);
} else {
if (isRestrictedEditMode) {
// In restricted edit mode, if the content has changed, write a memento
// (by firing the before change event).
QTIObjectBeforeChangeEvent qobce = new QTIObjectBeforeChangeEvent();
qobce.init(mat.getId(), htmlContent);
fireEvent(ureq, qobce);
}
// Collect the content of all MatElements in a single text element
// (text/html) and save it (for Material objects with multiple elements
// such as images, videos, text, breaks, etc. this can be regarded as
// "lazy migration" to the new rich text style).
Mattext textHtml = new Mattext(newHtml);
// A single text/html element will be left over.
List<QTIObject> elements = new ArrayList<QTIObject>(1);
elements.add(textHtml);
mat.setElements(elements);
fireEvent(ureq, Event.DONE_EVENT);
}
}
use of org.olat.ims.qti.editor.beecom.objects.QTIObject in project openolat by klemens.
the class SectionParser method parse.
public Object parse(Element element) {
// assert element.getName().equalsIgnoreCase("questestinterop");
Section section = new Section();
// attributes
section.setIdent(element.attribute("ident").getValue());
section.setTitle(element.attribute("title").getValue());
// elements
// DURATION
Duration duration = (Duration) parserManager.parse(element.element("duration"));
section.setDuration(duration);
List sectioncontrolsXML = element.elements("sectioncontrol");
List<Object> sectioncontrols = new ArrayList<>();
for (Iterator i = sectioncontrolsXML.iterator(); i.hasNext(); ) {
sectioncontrols.add(parserManager.parse((Element) i.next()));
}
if (sectioncontrols.size() == 0) {
sectioncontrols.add(new Control());
}
section.setSectioncontrols(sectioncontrols);
// SELECTION ORDERING
SelectionOrdering selectionOrdering = (SelectionOrdering) parserManager.parse(element.element("selection_ordering"));
if (selectionOrdering != null) {
section.setSelection_ordering(selectionOrdering);
} else {
section.setSelection_ordering(new SelectionOrdering());
}
// SECTIONS
List sectionsXML = element.elements("section");
List<Object> sections = new ArrayList<>();
for (Iterator i = sectionsXML.iterator(); i.hasNext(); ) {
sections.add(parserManager.parse((Element) i.next()));
}
section.setSections(sections);
// ITEMS
List itemsXML = element.elements("item");
List<Object> items = new ArrayList<>();
for (Iterator i = itemsXML.iterator(); i.hasNext(); ) {
items.add(parserManager.parse((Element) i.next()));
}
section.setItems(items);
// OBJECTIVES
Element mattext = (Element) element.selectSingleNode("./objectives/material/mattext");
if (mattext != null)
section.setObjectives(mattext.getTextTrim());
// FEEDBACKS
List feedbacksXML = element.elements("sectionfeedback");
List<QTIObject> feedbacks = new ArrayList<>();
for (Iterator i = feedbacksXML.iterator(); i.hasNext(); ) {
QTIObject tmp = (QTIObject) parserManager.parse((Element) i.next());
feedbacks.add(tmp);
}
section.setSectionfeedbacks(feedbacks);
// OUTCOMES_PROCESSING
// TODO: maybe we should use the OutcomesProcessing object and parser here? Same as on
// assessment level?
QTIObject outcomes_processing = (QTIObject) parserManager.parse(element.element("outcomes_processing"));
section.setOutcomes_processing(outcomes_processing);
return section;
}
Aggregations