Search in sources :

Example 11 with Section

use of org.olat.ims.qti.editor.beecom.objects.Section 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 12 with Section

use of org.olat.ims.qti.editor.beecom.objects.Section 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 13 with Section

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

the class QTIStatisticResourceResult method buildQTICourseNodeSubTree.

private void buildQTICourseNodeSubTree(QTIDocument qtiDoc, GenericTreeNode rootNode) {
    for (Section section : qtiDoc.getAssessment().getSections()) {
        GenericTreeNode sectionNode = new SectionNode(section, null);
        sectionNode.setUserObject(section);
        rootNode.addChild(sectionNode);
        for (Item item : section.getItems()) {
            GenericTreeNode itemNode = new ItemNode(item);
            itemNode.setIdent(Long.toString(CodeHelper.getForeverUniqueID()));
            if (sectionNode.getDelegate() == null) {
                sectionNode.setDelegate(itemNode);
            }
            itemNode.setUserObject(item);
            sectionNode.addChild(itemNode);
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) Section(org.olat.ims.qti.editor.beecom.objects.Section) SectionNode(org.olat.ims.qti.editor.tree.SectionNode)

Example 14 with Section

use of org.olat.ims.qti.editor.beecom.objects.Section 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 15 with Section

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

the class QTIEditHelper method createSection.

/**
 * Creates an empty section
 * @param trans
 * @return Section
 */
public static Section createSection(Translator trans) {
    Section section = new Section();
    section.setIdent(CodeHelper.getGlobalForeverUniqueID());
    section.setTitle(trans.translate("editor.newsection"));
    return section;
}
Also used : Section(org.olat.ims.qti.editor.beecom.objects.Section)

Aggregations

Section (org.olat.ims.qti.editor.beecom.objects.Section)34 Item (org.olat.ims.qti.editor.beecom.objects.Item)28 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)18 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)10 SectionNode (org.olat.ims.qti.editor.tree.SectionNode)10 VFSItem (org.olat.core.util.vfs.VFSItem)8 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)6 List (java.util.List)6 AssessmentNode (org.olat.ims.qti.editor.tree.AssessmentNode)6 Control (org.olat.ims.qti.editor.beecom.objects.Control)5 Element (org.dom4j.Element)4 Translator (org.olat.core.gui.translator.Translator)4 INode (org.olat.core.util.nodes.INode)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 Response (org.olat.ims.qti.editor.beecom.objects.Response)4 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)4 QTIDocument (org.olat.ims.qti.editor.beecom.objects.QTIDocument)3 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)3 File (java.io.File)2