Search in sources :

Example 1 with Metadata

use of org.olat.ims.qti.editor.beecom.objects.Metadata in project OpenOLAT by OpenOLAT.

the class QTIEditorPackageImpl method getQTIDocument.

/**
 * @return Reutrns the QTIDocument structure
 */
public QTIDocument getQTIDocument() {
    if (qtiDocument == null) {
        if (hasSerializedQTIDocument()) {
            qtiDocument = loadSerializedQTIDocument();
            resumed = true;
        } else {
            unzipPackage();
            Document doc = loadQTIDocument();
            if (doc != null) {
                ParserManager parser = new ParserManager();
                qtiDocument = (QTIDocument) parser.parse(doc);
                // grab assessment type
                Metadata meta = qtiDocument.getAssessment().getMetadata();
                String assessType = meta.getField(AssessmentInstance.QMD_LABEL_TYPE);
                if (assessType != null) {
                    qtiDocument.setSurvey(assessType.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY));
                }
                resumed = false;
            } else {
                qtiDocument = null;
            }
        }
    }
    return qtiDocument;
}
Also used : ParserManager(org.olat.ims.qti.editor.beecom.parser.ParserManager) Metadata(org.olat.ims.qti.editor.beecom.objects.Metadata) Document(org.dom4j.Document) QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument)

Example 2 with Metadata

use of org.olat.ims.qti.editor.beecom.objects.Metadata in project OpenOLAT by OpenOLAT.

the class QTIEditHelper method createAssessment.

/**
 * Creates an empty assessment
 * @param title
 * @param type
 * @return Assessment
 */
public static Assessment createAssessment(String title, String type) {
    Assessment assessment = new Assessment();
    assessment.setIdent(CodeHelper.getGlobalForeverUniqueID());
    assessment.setTitle(title);
    Metadata meta = new Metadata();
    meta.setField(AssessmentInstance.QMD_LABEL_TYPE, type);
    assessment.setMetadata(meta);
    return assessment;
}
Also used : Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Metadata(org.olat.ims.qti.editor.beecom.objects.Metadata)

Example 3 with Metadata

use of org.olat.ims.qti.editor.beecom.objects.Metadata in project openolat by klemens.

the class QTIEditorPackageImpl method getQTIDocument.

/**
 * @return Reutrns the QTIDocument structure
 */
public QTIDocument getQTIDocument() {
    if (qtiDocument == null) {
        if (hasSerializedQTIDocument()) {
            qtiDocument = loadSerializedQTIDocument();
            resumed = true;
        } else {
            unzipPackage();
            Document doc = loadQTIDocument();
            if (doc != null) {
                ParserManager parser = new ParserManager();
                qtiDocument = (QTIDocument) parser.parse(doc);
                // grab assessment type
                Metadata meta = qtiDocument.getAssessment().getMetadata();
                String assessType = meta.getField(AssessmentInstance.QMD_LABEL_TYPE);
                if (assessType != null) {
                    qtiDocument.setSurvey(assessType.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY));
                }
                resumed = false;
            } else {
                qtiDocument = null;
            }
        }
    }
    return qtiDocument;
}
Also used : ParserManager(org.olat.ims.qti.editor.beecom.parser.ParserManager) Metadata(org.olat.ims.qti.editor.beecom.objects.Metadata) Document(org.dom4j.Document) QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument)

Example 4 with Metadata

use of org.olat.ims.qti.editor.beecom.objects.Metadata in project openolat by klemens.

the class QTIMetadataParser method parse.

/**
 * @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
 */
public Object parse(Element element) {
    // assert element.getName().equalsIgnoreCase("qtimetadata");
    Metadata meta = new Metadata();
    List metadatafields = element.selectNodes("./qtimetadatafield");
    for (Iterator iter = metadatafields.iterator(); iter.hasNext(); ) {
        Element metadatafield = (Element) iter.next();
        String key = metadatafield.elementText("fieldlabel");
        String value = metadatafield.elementText("fieldentry");
        meta.setField(key, value);
    }
    return meta;
}
Also used : Element(org.dom4j.Element) Metadata(org.olat.ims.qti.editor.beecom.objects.Metadata) Iterator(java.util.Iterator) List(java.util.List)

Example 5 with Metadata

use of org.olat.ims.qti.editor.beecom.objects.Metadata 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)

Aggregations

Metadata (org.olat.ims.qti.editor.beecom.objects.Metadata)8 Iterator (java.util.Iterator)4 List (java.util.List)4 Element (org.dom4j.Element)4 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)4 ArrayList (java.util.ArrayList)2 Attribute (org.dom4j.Attribute)2 Document (org.dom4j.Document)2 Control (org.olat.ims.qti.editor.beecom.objects.Control)2 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)2 QTIDocument (org.olat.ims.qti.editor.beecom.objects.QTIDocument)2 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)2 SelectionOrdering (org.olat.ims.qti.editor.beecom.objects.SelectionOrdering)2 ParserManager (org.olat.ims.qti.editor.beecom.parser.ParserManager)2