use of org.olat.core.gui.media.DefaultMediaResource in project OpenOLAT by OpenOLAT.
the class QTIArchiver method exportQTI12.
public MediaResource exportQTI12() {
RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
// fields separated by
String sep = "\\t";
// fields embedded by
String emb = "\"";
// carriage return
String car = "\\r\\n";
sep = convert2CtrlChars(sep);
car = convert2CtrlChars(car);
boolean tagLess = true;
QTIExportFormatter formatter = getFormatter(sep, emb, car, tagLess);
formatter.setMapWithExportItemConfigs(qtiItemConfigs);
return new DefaultMediaResource() {
@Override
public String getContentType() {
return "text/csv";
}
@Override
public void prepare(HttpServletResponse hres) {
try {
hres.setCharacterEncoding("UTF-8");
} catch (Exception e) {
log.error("", e);
}
String label = courseNode.getType() + "_" + StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".csv";
String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + urlEncodedLabel);
hres.setHeader("Content-Description", urlEncodedLabel);
try (OutputStream out = hres.getOutputStream()) {
List<QTIResult> qtiResults = qrm.selectResults(courseOres.getResourceableId(), courseNode.getIdent(), testRe.getKey(), null, 5);
qem.exportResults(formatter, qtiResults, qtiItemObjectList, out);
} catch (IOException e) {
log.error("", e);
}
}
};
}
use of org.olat.core.gui.media.DefaultMediaResource in project openolat by klemens.
the class QTIArchiver method exportQTI12.
public MediaResource exportQTI12() {
RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
// fields separated by
String sep = "\\t";
// fields embedded by
String emb = "\"";
// carriage return
String car = "\\r\\n";
sep = convert2CtrlChars(sep);
car = convert2CtrlChars(car);
boolean tagLess = true;
QTIExportFormatter formatter = getFormatter(sep, emb, car, tagLess);
formatter.setMapWithExportItemConfigs(qtiItemConfigs);
return new DefaultMediaResource() {
@Override
public String getContentType() {
return "text/csv";
}
@Override
public void prepare(HttpServletResponse hres) {
try {
hres.setCharacterEncoding("UTF-8");
} catch (Exception e) {
log.error("", e);
}
String label = courseNode.getType() + "_" + StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".csv";
String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + urlEncodedLabel);
hres.setHeader("Content-Description", urlEncodedLabel);
try (OutputStream out = hres.getOutputStream()) {
List<QTIResult> qtiResults = qrm.selectResults(courseOres.getResourceableId(), courseNode.getIdent(), testRe.getKey(), null, 5);
qem.exportResults(formatter, qtiResults, qtiItemObjectList, out);
} catch (IOException e) {
log.error("", e);
}
}
};
}
Aggregations