Search in sources :

Example 1 with SelectionOrdering

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;
}
Also used : Control(org.olat.ims.qti.editor.beecom.objects.Control) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) SelectionOrdering(org.olat.ims.qti.editor.beecom.objects.SelectionOrdering) Attribute(org.dom4j.Attribute) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) Metadata(org.olat.ims.qti.editor.beecom.objects.Metadata) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with SelectionOrdering

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;
}
Also used : Control(org.olat.ims.qti.editor.beecom.objects.Control) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) SelectionOrdering(org.olat.ims.qti.editor.beecom.objects.SelectionOrdering) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Duration(org.olat.ims.qti.editor.beecom.objects.Duration) List(java.util.List) ArrayList(java.util.ArrayList) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 3 with SelectionOrdering

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;
}
Also used : SelectionOrdering(org.olat.ims.qti.editor.beecom.objects.SelectionOrdering) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) Element(org.dom4j.Element) List(java.util.List)

Example 4 with 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;
}
Also used : Control(org.olat.ims.qti.editor.beecom.objects.Control) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) SelectionOrdering(org.olat.ims.qti.editor.beecom.objects.SelectionOrdering) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Duration(org.olat.ims.qti.editor.beecom.objects.Duration) List(java.util.List) ArrayList(java.util.ArrayList) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 5 with SelectionOrdering

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;
}
Also used : SelectionOrdering(org.olat.ims.qti.editor.beecom.objects.SelectionOrdering) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) Element(org.dom4j.Element) List(java.util.List)

Aggregations

List (java.util.List)6 Element (org.dom4j.Element)6 SelectionOrdering (org.olat.ims.qti.editor.beecom.objects.SelectionOrdering)6 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 Control (org.olat.ims.qti.editor.beecom.objects.Control)4 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)4 Attribute (org.dom4j.Attribute)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2 Duration (org.olat.ims.qti.editor.beecom.objects.Duration)2 Metadata (org.olat.ims.qti.editor.beecom.objects.Metadata)2 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2