Search in sources :

Example 6 with OpenXMLDocument

use of org.olat.core.util.openxml.OpenXMLDocument in project OpenOLAT by OpenOLAT.

the class QTI21WordExport method exportTest.

private void exportTest(AssessmentTest assessmentTest, String header, ZipOutputStream out, boolean withResponses) {
    try (ShieldOutputStream sout = new ShieldOutputStream(out);
        ZipOutputStream zout = new ZipOutputStream(sout)) {
        zout.setLevel(9);
        OpenXMLDocument document = new OpenXMLDocument();
        document.setMediaContainer(mediaContainer);
        document.setDocumentHeader(header);
        Translator translator = Util.createPackageTranslator(AssessmentTestDisplayController.class, locale, Util.createPackageTranslator(AssessmentTestComposerController.class, locale));
        renderAssessmentTest(assessmentTest, document, translator);
        for (TestPart testPart : assessmentTest.getChildAbstractParts()) {
            List<AssessmentSection> assessmentSections = testPart.getAssessmentSections();
            for (AssessmentSection assessmentSection : assessmentSections) {
                renderAssessmentSection(assessmentSection, document, withResponses, translator);
            }
        }
        OpenXMLDocumentWriter writer = new OpenXMLDocumentWriter();
        writer.createDocument(zout, document);
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : OpenXMLDocumentWriter(org.olat.core.util.openxml.OpenXMLDocumentWriter) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) Translator(org.olat.core.gui.translator.Translator) ZipOutputStream(java.util.zip.ZipOutputStream) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) OpenXMLDocument(org.olat.core.util.openxml.OpenXMLDocument) AssessmentTestComposerController(org.olat.ims.qti21.ui.editor.AssessmentTestComposerController) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)6 ZipOutputStream (java.util.zip.ZipOutputStream)6 Translator (org.olat.core.gui.translator.Translator)6 OpenXMLDocument (org.olat.core.util.openxml.OpenXMLDocument)6 OpenXMLDocumentWriter (org.olat.core.util.openxml.OpenXMLDocumentWriter)6 Item (org.olat.ims.qti.editor.beecom.objects.Item)4 AssessmentTestComposerController (org.olat.ims.qti21.ui.editor.AssessmentTestComposerController)4 File (java.io.File)2 URI (java.net.URI)2 ShieldOutputStream (org.olat.core.util.io.ShieldOutputStream)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 QTIEditorMainController (org.olat.ims.qti.editor.QTIEditorMainController)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 AssessmentHtmlBuilder (org.olat.ims.qti21.model.xml.AssessmentHtmlBuilder)2 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)2 SAXException (org.xml.sax.SAXException)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)2