Search in sources :

Example 6 with Assessment

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

the class OLATUpgrade_11_0_0 method checkEssay.

private boolean checkEssay(RepositoryEntry testEntry) {
    if (qtiEssayMap.containsKey(testEntry.getKey())) {
        return qtiEssayMap.get(testEntry.getKey()).booleanValue();
    }
    TestFileResource fr = new TestFileResource();
    fr.overrideResourceableId(testEntry.getOlatResource().getResourceableId());
    TransientIdentity pseudoIdentity = new TransientIdentity();
    pseudoIdentity.setName("transient");
    Translator translator = Util.createPackageTranslator(QTIModule.class, Locale.ENGLISH);
    try {
        QTIEditorPackage qtiPackage = new QTIEditorPackageImpl(pseudoIdentity, fr, null, translator);
        if (qtiPackage.getQTIDocument() != null && qtiPackage.getQTIDocument().getAssessment() != null) {
            Assessment ass = qtiPackage.getQTIDocument().getAssessment();
            // Sections with their Items
            List<Section> sections = ass.getSections();
            for (Section section : sections) {
                List<Item> items = section.getItems();
                for (Item item : items) {
                    String ident = item.getIdent();
                    if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
                        qtiEssayMap.put(testEntry.getKey(), Boolean.TRUE);
                        return true;
                    }
                }
            }
        }
    } catch (OLATRuntimeException e) {
        log.warn("QTI without content in repository entry: " + testEntry.getKey(), e);
    }
    qtiEssayMap.put(testEntry.getKey(), Boolean.FALSE);
    return false;
}
Also used : TransientIdentity(org.olat.admin.user.imp.TransientIdentity) Item(org.olat.ims.qti.editor.beecom.objects.Item) Translator(org.olat.core.gui.translator.Translator) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIEditorPackageImpl(org.olat.ims.qti.editor.QTIEditorPackageImpl) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) TestFileResource(org.olat.ims.qti.fileresource.TestFileResource) QTIEditorPackage(org.olat.ims.qti.editor.QTIEditorPackage) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 7 with Assessment

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

the class IQConfigurationController method needManualCorrectionQTI12.

private boolean needManualCorrectionQTI12(RepositoryEntry re) {
    boolean needManualCorrection = false;
    QTIDocument doc = TestFileResource.getQTIDocument(re.getOlatResource());
    if (doc != null && doc.getAssessment() != null) {
        Assessment ass = doc.getAssessment();
        // Sections with their Items
        List<Section> sections = ass.getSections();
        for (Section section : sections) {
            List<Item> items = section.getItems();
            for (Item item : items) {
                String ident = item.getIdent();
                if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
                    needManualCorrection = true;
                    break;
                }
            }
        }
    }
    return needManualCorrection;
}
Also used : QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) Item(org.olat.ims.qti.editor.beecom.objects.Item) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 8 with Assessment

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

the class QTIWordExport method exportTest.

private void exportTest(String header, OutputStream out, boolean withResponses) {
    ZipOutputStream zout = null;
    try {
        OpenXMLDocument document = new OpenXMLDocument();
        document.setMediaContainer(mediaContainer);
        document.setDocumentHeader(header);
        Translator translator = Util.createPackageTranslator(QTIWordExport.class, locale, Util.createPackageTranslator(QTIEditorMainController.class, locale));
        Assessment assessment = rootNode.getAssessment();
        renderAssessment(assessment, document, translator);
        for (Section section : assessment.getSections()) {
            renderSection(section, document);
            List<Item> items = section.getItems();
            for (Iterator<Item> itemIt = items.iterator(); itemIt.hasNext(); ) {
                Item item = itemIt.next();
                if (item.isAlient()) {
                    renderAlienItem(item, document, translator);
                } else {
                    renderItem(item, document, withResponses, translator);
                }
                if (itemIt.hasNext()) {
                    document.appendPageBreak();
                }
            }
        }
        zout = new ZipOutputStream(out);
        zout.setLevel(9);
        OpenXMLDocumentWriter writer = new OpenXMLDocumentWriter();
        writer.createDocument(zout, document);
    } catch (Exception e) {
        log.error("", e);
    } finally {
        if (zout != null) {
            try {
                zout.finish();
            } catch (IOException e) {
                log.error("", e);
            }
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) OpenXMLDocumentWriter(org.olat.core.util.openxml.OpenXMLDocumentWriter) Translator(org.olat.core.gui.translator.Translator) QTIEditorMainController(org.olat.ims.qti.editor.QTIEditorMainController) ZipOutputStream(java.util.zip.ZipOutputStream) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) OpenXMLDocument(org.olat.core.util.openxml.OpenXMLDocument) IOException(java.io.IOException) Section(org.olat.ims.qti.editor.beecom.objects.Section) IOException(java.io.IOException)

Example 9 with Assessment

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

the class QTIEditHelper method getFeedbacks.

/**
 * @param object
 * @return
 */
private static List<Feedback> getFeedbacks(QTIObject object) {
    List<Feedback> feedbacks = null;
    if (Item.class.isAssignableFrom(object.getClass())) {
        Item item = (Item) object;
        feedbacks = item.getItemfeedbacks();
    } else if (Section.class.isAssignableFrom(object.getClass())) {
        Section section = (Section) object;
        feedbacks = section.getSectionfeedbacks();
    } else if (Assessment.class.isAssignableFrom(object.getClass())) {
        Assessment assessment = (Assessment) object;
        feedbacks = assessment.getAssessfeedbacks();
    }
    return feedbacks;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) Feedback(org.olat.ims.qti.editor.beecom.objects.Feedback) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 10 with Assessment

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

the class IQConfigurationController method needManualCorrectionQTI12.

private boolean needManualCorrectionQTI12(RepositoryEntry re) {
    boolean needManualCorrection = false;
    QTIDocument doc = TestFileResource.getQTIDocument(re.getOlatResource());
    if (doc != null && doc.getAssessment() != null) {
        Assessment ass = doc.getAssessment();
        // Sections with their Items
        List<Section> sections = ass.getSections();
        for (Section section : sections) {
            List<Item> items = section.getItems();
            for (Item item : items) {
                String ident = item.getIdent();
                if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
                    needManualCorrection = true;
                    break;
                }
            }
        }
    }
    return needManualCorrection;
}
Also used : QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) Item(org.olat.ims.qti.editor.beecom.objects.Item) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Aggregations

Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)22 Section (org.olat.ims.qti.editor.beecom.objects.Section)18 Item (org.olat.ims.qti.editor.beecom.objects.Item)16 Control (org.olat.ims.qti.editor.beecom.objects.Control)6 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 List (java.util.List)4 Translator (org.olat.core.gui.translator.Translator)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 Metadata (org.olat.ims.qti.editor.beecom.objects.Metadata)4 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)4 QTIDocument (org.olat.ims.qti.editor.beecom.objects.QTIDocument)4 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)4 File (java.io.File)2 IOException (java.io.IOException)2 ZipOutputStream (java.util.zip.ZipOutputStream)2 Attribute (org.dom4j.Attribute)2 Element (org.dom4j.Element)2 TransientIdentity (org.olat.admin.user.imp.TransientIdentity)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2