use of org.olat.ims.qti.editor.beecom.objects.SelectionOrdering in project OpenOLAT by OpenOLAT.
the class AssessmentParser method parse.
/**
* @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
*/
public Object parse(Element element) {
// assert element.getName().equalsIgnoreCase("assessment");
Assessment assessment = new Assessment();
// attributes
Attribute attr = element.attribute("ident");
if (attr != null)
assessment.setIdent(attr.getValue());
attr = element.attribute("title");
if (attr != null)
assessment.setTitle(attr.getValue());
// elements
// DURATION
QTIObject duration = (QTIObject) parserManager.parse(element.element("duration"));
assessment.setDuration(duration);
// ASSESSMENTCONTROL
List assessmentcontrolsXML = element.elements("assessmentcontrol");
List assessmentcontrols = new ArrayList();
for (Iterator i = assessmentcontrolsXML.iterator(); i.hasNext(); ) {
assessmentcontrols.add(parserManager.parse((Element) i.next()));
assessment.setInheritControls(true);
}
if (assessmentcontrols.size() == 0) {
assessmentcontrols.add(new Control());
assessment.setInheritControls(false);
}
assessment.setAssessmentcontrols(assessmentcontrols);
// OUTCOMES PROCESSING
OutcomesProcessing outcomesProcessing = (OutcomesProcessing) parserManager.parse(element.element("outcomes_processing"));
if (outcomesProcessing != null)
assessment.setOutcomes_processing(outcomesProcessing);
// SELECTION ORDERING
SelectionOrdering selectionOrdering = (SelectionOrdering) parserManager.parse(element.element("selection_ordering"));
if (selectionOrdering != null) {
assessment.setSelection_ordering(selectionOrdering);
} else {
assessment.setSelection_ordering(new SelectionOrdering());
}
// SECTIONS
List sectionsXML = element.elements("section");
List sections = new ArrayList();
for (Iterator i = sectionsXML.iterator(); i.hasNext(); ) {
sections.add(parserManager.parse((Element) i.next()));
}
assessment.setSections(sections);
// ITEMS
List itemsXML = element.elements("item");
List items = new ArrayList();
for (Iterator i = itemsXML.iterator(); i.hasNext(); ) {
items.add(parserManager.parse((Element) i.next()));
}
assessment.setItems(items);
// OBJECTIVES
Element mattext = (Element) element.selectSingleNode("./objectives/material/mattext");
if (mattext != null)
assessment.setObjectives(mattext.getTextTrim());
// METADATA
Metadata metadata = (Metadata) parserManager.parse(element.element("qtimetadata"));
if (metadata != null)
assessment.setMetadata(metadata);
return assessment;
}
use of org.olat.ims.qti.editor.beecom.objects.SelectionOrdering 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.SelectionOrdering in project OpenOLAT by OpenOLAT.
the class SelectionOrderingParser method parse.
/**
* @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
*/
public Object parse(Element element) {
// assert element.getName().equalsIgnoreCase("selection_ordering");
SelectionOrdering selectionOrdering = new SelectionOrdering();
// Set correct selection of items. To select all is the default value (represented
// by a non existing 'selection_number' element. Otherwhise the exact number given
// in the 'selection_number' element is taken')
List el_selections = element.selectNodes("selection");
if (el_selections.size() > 1) {
// error
throw new OLATRuntimeException(SelectionOrderingParser.class, "more then one selection element", new IllegalStateException());
}
if (el_selections.size() != 0) {
Element el_selection = ((Element) el_selections.get(0));
Element selection_number = (Element) el_selection.selectSingleNode("selection_number");
if (selection_number != null) {
selectionOrdering.setSelectionNumber(Integer.parseInt(selection_number.getText()));
}
}
// else use default value
// Set correct order type. Use sequential ordering als default if none defined
Element order = (Element) element.selectSingleNode("order");
if (order != null) {
String order_type = order.attributeValue(SelectionOrdering.ORDER_TYPE);
if (order_type != null && order_type.equals(SelectionOrdering.RANDOM)) {
selectionOrdering.setOrderType(SelectionOrdering.RANDOM);
}
// else use default value
}
return selectionOrdering;
}
use of org.olat.ims.qti.editor.beecom.objects.SelectionOrdering 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;
}
use of org.olat.ims.qti.editor.beecom.objects.SelectionOrdering in project openolat by klemens.
the class SelectionOrderingParser method parse.
/**
* @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
*/
public Object parse(Element element) {
// assert element.getName().equalsIgnoreCase("selection_ordering");
SelectionOrdering selectionOrdering = new SelectionOrdering();
// Set correct selection of items. To select all is the default value (represented
// by a non existing 'selection_number' element. Otherwhise the exact number given
// in the 'selection_number' element is taken')
List el_selections = element.selectNodes("selection");
if (el_selections.size() > 1) {
// error
throw new OLATRuntimeException(SelectionOrderingParser.class, "more then one selection element", new IllegalStateException());
}
if (el_selections.size() != 0) {
Element el_selection = ((Element) el_selections.get(0));
Element selection_number = (Element) el_selection.selectSingleNode("selection_number");
if (selection_number != null) {
selectionOrdering.setSelectionNumber(Integer.parseInt(selection_number.getText()));
}
}
// else use default value
// Set correct order type. Use sequential ordering als default if none defined
Element order = (Element) element.selectSingleNode("order");
if (order != null) {
String order_type = order.attributeValue(SelectionOrdering.ORDER_TYPE);
if (order_type != null && order_type.equals(SelectionOrdering.RANDOM)) {
selectionOrdering.setOrderType(SelectionOrdering.RANDOM);
}
// else use default value
}
return selectionOrdering;
}
Aggregations