Search in sources :

Example 16 with QTIObject

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;
}
Also used : QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) Element(org.dom4j.Element) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject)

Example 17 with QTIObject

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;
}
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 18 with QTIObject

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));
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) AssessmentNode(org.olat.ims.qti.editor.tree.AssessmentNode) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) SectionNode(org.olat.ims.qti.editor.tree.SectionNode) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 19 with QTIObject

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);
    }
}
Also used : Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) Filter(org.olat.core.util.filter.Filter) ArrayList(java.util.ArrayList)

Example 20 with QTIObject

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;
}
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)

Aggregations

QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)22 ArrayList (java.util.ArrayList)12 List (java.util.List)10 Element (org.dom4j.Element)10 Iterator (java.util.Iterator)8 Material (org.olat.ims.qti.editor.beecom.objects.Material)8 Mattext (org.olat.ims.qti.editor.beecom.objects.Mattext)8 Attribute (org.dom4j.Attribute)6 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)6 Control (org.olat.ims.qti.editor.beecom.objects.Control)6 Item (org.olat.ims.qti.editor.beecom.objects.Item)6 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)4 Duration (org.olat.ims.qti.editor.beecom.objects.Duration)4 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)4 Question (org.olat.ims.qti.editor.beecom.objects.Question)4 Section (org.olat.ims.qti.editor.beecom.objects.Section)4 SelectionOrdering (org.olat.ims.qti.editor.beecom.objects.SelectionOrdering)4 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)4 File (java.io.File)2 URL (java.net.URL)2