Search in sources :

Example 76 with QuestionItemShort

use of org.olat.modules.qpool.QuestionItemShort in project openolat by klemens.

the class QTI12And21PoolWordExport method prepare.

@Override
public void prepare(HttpServletResponse hres) {
    try {
        hres.setCharacterEncoding(encoding);
    } catch (Exception e) {
        log.error("", e);
    }
    try (ZipOutputStream zout = new ZipOutputStream(hres.getOutputStream())) {
        String label = "Items_Export";
        String secureLabel = StringHelper.transformDisplayNameToFileSystemName(label);
        List<Long> itemKeys = new ArrayList<>();
        for (QuestionItemShort item : items) {
            itemKeys.add(item.getKey());
        }
        List<QuestionItemFull> fullItems = questionItemDao.loadByIds(itemKeys);
        String file = secureLabel + ".zip";
        hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + StringHelper.urlEncodeUTF8(file));
        hres.setHeader("Content-Description", StringHelper.urlEncodeUTF8(label));
        zout.setLevel(9);
        ZipEntry test = new ZipEntry(secureLabel + ".docx");
        zout.putNextEntry(test);
        exportItems(fullItems, zout, false);
        zout.closeEntry();
        ZipEntry responses = new ZipEntry(secureLabel + "_responses.docx");
        zout.putNextEntry(responses);
        exportItems(fullItems, zout, true);
        zout.closeEntry();
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) ZipOutputStream(java.util.zip.ZipOutputStream) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ZipEntry(java.util.zip.ZipEntry) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Aggregations

QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)76 ArrayList (java.util.ArrayList)52 QuestionItem (org.olat.modules.qpool.QuestionItem)28 Identity (org.olat.core.id.Identity)14 List (java.util.List)12 BusinessGroup (org.olat.group.BusinessGroup)12 Test (org.junit.Test)10 QPoolSPI (org.olat.modules.qpool.QPoolSPI)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 QItemType (org.olat.modules.qpool.model.QItemType)8 HashMap (java.util.HashMap)6 ExportFormatOptions (org.olat.modules.qpool.ExportFormatOptions)6 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)6 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)6 QuestionItemView (org.olat.modules.qpool.QuestionItemView)6 QItemList (org.olat.modules.qpool.model.QItemList)6 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)6 QPoolEvent (org.olat.modules.qpool.ui.events.QPoolEvent)6 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)5 Path (javax.ws.rs.Path)4