* @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;
}