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