Skip to content
Snippets Groups Projects
Commit c7e1da69 authored by fkiefer's avatar fkiefer
Browse files

OO-2456 qti12 resolve empty .zip download in archive tool, format file name

parent 7933a3d6
No related branches found
No related tags found
No related merge requests found
...@@ -94,10 +94,8 @@ public class ArchiveResource implements MediaResource { ...@@ -94,10 +94,8 @@ public class ArchiveResource implements MediaResource {
log.error("", e); log.error("", e);
} }
String label = //courseNode.getType() + "_" + String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName())
StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeSave(new Date()) + ".zip";
+ "_" + Formatter.formatDatetimeSave(new Date(System.currentTimeMillis()))
+ ".zip";
String urlEncodedLabel = StringHelper.urlEncodeUTF8(label); String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
hres.setHeader("Content-Disposition","attachment; filename*=UTF-8''" + urlEncodedLabel); hres.setHeader("Content-Disposition","attachment; filename*=UTF-8''" + urlEncodedLabel);
hres.setHeader("Content-Description", urlEncodedLabel); hres.setHeader("Content-Description", urlEncodedLabel);
......
...@@ -250,7 +250,7 @@ public class IQSELFCourseNode extends AbstractAccessableCourseNode implements Se ...@@ -250,7 +250,7 @@ public class IQSELFCourseNode extends AbstractAccessableCourseNode implements Se
try { try {
QTIExportFormatter qef = new QTIExportFormatterCSVType2(locale, null, "\t", "\"", "\r\n", false); QTIExportFormatter qef = new QTIExportFormatterCSVType2(locale, null, "\t", "\"", "\r\n", false);
return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, ".xls"); return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, locale, ".xls");
} catch (IOException e) { } catch (IOException e) {
log.error("", e); log.error("", e);
return false; return false;
......
...@@ -328,7 +328,7 @@ public class IQSURVCourseNode extends AbstractAccessableCourseNode implements QT ...@@ -328,7 +328,7 @@ public class IQSURVCourseNode extends AbstractAccessableCourseNode implements QT
QTIExportFormatter qef = new QTIExportFormatterCSVType3(locale, null,"\t", "\"", "\r\n", false); QTIExportFormatter qef = new QTIExportFormatterCSVType3(locale, null,"\t", "\"", "\r\n", false);
try { try {
return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, ".xls"); return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, locale, ".xls");
} catch (IOException e) { } catch (IOException e) {
log.error("", e); log.error("", e);
return false; return false;
......
...@@ -669,7 +669,7 @@ public class IQTESTCourseNode extends AbstractAccessableCourseNode implements Pe ...@@ -669,7 +669,7 @@ public class IQTESTCourseNode extends AbstractAccessableCourseNode implements Pe
String shortTitle = getShortTitle(); String shortTitle = getShortTitle();
QTIExportManager qem = QTIExportManager.getInstance(); QTIExportManager qem = QTIExportManager.getInstance();
QTIExportFormatter qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false); QTIExportFormatter qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
return qem.selectAndExportResults(qef, courseResourceableId, shortTitle, getIdent(), re, exportStream, ".xls"); return qem.selectAndExportResults(qef, courseResourceableId, shortTitle, getIdent(), re, exportStream, locale, ".xls");
} }
} catch (IOException e) { } catch (IOException e) {
log.error("", e); log.error("", e);
......
...@@ -33,14 +33,17 @@ import java.text.SimpleDateFormat; ...@@ -33,14 +33,17 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.olat.core.gui.translator.Translator;
import org.olat.core.manager.BasicManager; import org.olat.core.manager.BasicManager;
import org.olat.core.util.ExportUtil; import org.olat.core.util.ExportUtil;
import org.olat.core.util.Formatter; import org.olat.core.util.Formatter;
import org.olat.core.util.Util;
import org.olat.ims.qti.QTIResult; import org.olat.ims.qti.QTIResult;
import org.olat.ims.qti.QTIResultManager; import org.olat.ims.qti.QTIResultManager;
import org.olat.ims.qti.export.helper.QTIItemObject; import org.olat.ims.qti.export.helper.QTIItemObject;
...@@ -106,7 +109,7 @@ public class QTIExportManager extends BasicManager{ ...@@ -106,7 +109,7 @@ public class QTIExportManager extends BasicManager{
} }
public boolean selectAndExportResults(QTIExportFormatter qef, Long courseResId, String shortTitle, public boolean selectAndExportResults(QTIExportFormatter qef, Long courseResId, String shortTitle,
String olatResourceDetail, RepositoryEntry testRe, ZipOutputStream exportStream, String olatResourceDetail, RepositoryEntry testRe, ZipOutputStream exportStream, Locale locale,
String fileNameSuffix) throws IOException { String fileNameSuffix) throws IOException {
boolean resultsFoundAndExported = false; boolean resultsFoundAndExported = false;
QTIResultManager qrm = QTIResultManager.getInstance(); QTIResultManager qrm = QTIResultManager.getInstance();
...@@ -123,6 +126,13 @@ public class QTIExportManager extends BasicManager{ ...@@ -123,6 +126,13 @@ public class QTIExportManager extends BasicManager{
exportStream.closeEntry(); exportStream.closeEntry();
resultsFoundAndExported = true; resultsFoundAndExported = true;
} }
} else {
String targetFileName = getFilename(shortTitle, fileNameSuffix);
exportStream.putNextEntry(new ZipEntry(targetFileName));
Translator translator = Util.createPackageTranslator(QTIExportFormatter.class, locale);
IOUtils.write(translator.translate("archive.noresults.short"), exportStream);
exportStream.closeEntry();
resultsFoundAndExported = true;
} }
return resultsFoundAndExported; return resultsFoundAndExported;
} }
......
...@@ -3,6 +3,7 @@ action.choose=Archivieren ...@@ -3,6 +3,7 @@ action.choose=Archivieren
archive.all.users=Benutzer (Alle Benutzergruppen, z.B. Autoren, Teilnehmer etc) archive.all.users=Benutzer (Alle Benutzergruppen, z.B. Autoren, Teilnehmer etc)
archive.anonymous.users=Anonyme Benutzer (G\u00E4ste) archive.anonymous.users=Anonyme Benutzer (G\u00E4ste)
archive.noresults=F\u00FCr diesen Kursbaustein wurden noch keine Resultate gespeichert. archive.noresults=F\u00FCr diesen Kursbaustein wurden noch keine Resultate gespeichert.
archive.noresults.short=Keine Resultate in diesem Kursbaustein
archive.participants=Teilnehmer (Kurs und eingebundene Gruppen) archive.participants=Teilnehmer (Kurs und eingebundene Gruppen)
archive.results.successfully=<b>Die Resultate wurden in Ihrem pers\u00F6nlichen Ordner gespeichert.</b> archive.results.successfully=<b>Die Resultate wurden in Ihrem pers\u00F6nlichen Ordner gespeichert.</b>
archive.wizard.title=Archivierung von Test und Fragebogen archive.wizard.title=Archivierung von Test und Fragebogen
......
...@@ -3,6 +3,7 @@ action.choose=Archive ...@@ -3,6 +3,7 @@ action.choose=Archive
archive.all.users=User (All user groups, e.g. authors, participants etc) archive.all.users=User (All user groups, e.g. authors, participants etc)
archive.anonymous.users=Anonymous users (Guests) archive.anonymous.users=Anonymous users (Guests)
archive.noresults=No results saved for this course element. archive.noresults=No results saved for this course element.
archive.noresults.short=No results for this course element
archive.participants=Participants (Course and embedded groups) archive.participants=Participants (Course and embedded groups)
archive.results.successfully=<b>The results are archived in your personal folder.</b> archive.results.successfully=<b>The results are archived in your personal folder.</b>
archive.wizard.title=Archive of test and survey archive.wizard.title=Archive of test and survey
......
...@@ -199,7 +199,7 @@ public class QTI21ArchiveFormat { ...@@ -199,7 +199,7 @@ public class QTI21ArchiveFormat {
ICourse course = CourseFactory.loadCourse(courseEntry); ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode courseNode = course.getRunStructure().getNode(subIdent); CourseNode courseNode = course.getRunStructure().getNode(subIdent);
String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName())
+ "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + "_" + Formatter.formatDatetimeSave(new Date())
+ ".xlsx"; + ".xlsx";
if("iqself".equals(courseNode.getType())) { if("iqself".equals(courseNode.getType())) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment