diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamCreateClientConfigPopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamCreateClientConfigPopup.java index 45230357..28244cd0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamCreateClientConfigPopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamCreateClientConfigPopup.java @@ -14,11 +14,13 @@ import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.eclipse.rap.rwt.RWT; import org.eclipse.rap.rwt.client.service.UrlLauncher; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; -import org.springframework.beans.factory.annotation.Value; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; @@ -57,22 +59,25 @@ public class ExamCreateClientConfigPopup { private final PageService pageService; private final DownloadService downloadService; - private final String downloadFileName; public ExamCreateClientConfigPopup( final PageService pageService, - final DownloadService downloadService, - @Value("${sebserver.gui.seb.exam.config.download.filename}") final String downloadFileName) { + final DownloadService downloadService) { this.pageService = pageService; this.downloadService = downloadService; - this.downloadFileName = downloadFileName; } - public Function exportFunction(final Long examInstitutionId) { + public Function exportFunction( + final Long examInstitutionId, + final String examName) { return action -> { + final DateTime now = DateTime.now(DateTimeZone.UTC); + final String downloadFileName = StringUtils.remove(examName, " ") + "_" + now.getYear() + "-" + + now.getMonthOfYear() + "-" + now.getDayOfMonth() + ".seb"; + final ModalInputDialog> dialog = new ModalInputDialog>( action.pageContext().getParent().getShell(), @@ -88,7 +93,8 @@ public class ExamCreateClientConfigPopup { this.pageService, action.pageContext(), action.getEntityKey(), - formHandle); + formHandle, + downloadFileName); dialog.open( TITLE_KEY, @@ -104,7 +110,8 @@ public class ExamCreateClientConfigPopup { final PageService pageService, final PageContext pageContext, final EntityKey examKey, - final FormHandle formHandle) { + final FormHandle formHandle, + final String downloadFileName) { if (formHandle == null) { return true; @@ -116,7 +123,7 @@ public class ExamCreateClientConfigPopup { modelId, examKey.modelId, SEBClientConfigDownload.class, - this.downloadFileName); + downloadFileName); urlLauncher.openURL(downloadURL); return true; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java index 53aaf559..42ce6ab8 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java @@ -22,7 +22,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; @@ -141,8 +140,7 @@ public class ExamForm implements TemplateComposer { final ExamDeletePopup examDeletePopup, final ExamFormConfigs examFormConfigs, final ExamFormIndicators examFormIndicators, - final ExamCreateClientConfigPopup examCreateClientConfigPopup, - @Value("${sebserver.gui.seb.exam.config.download.filename}") final String downloadFileName) { + final ExamCreateClientConfigPopup examCreateClientConfigPopup) { this.pageService = pageService; this.resourceService = pageService.getResourceService(); @@ -358,6 +356,7 @@ public class ExamForm implements TemplateComposer { final PageActionBuilder actionBuilder = this.pageService.pageActionBuilder(formContext .clearEntityKeys() .removeAttribute(AttributeKeys.IMPORT_FROM_QUIZ_DATA)); + // propagate content actions to action-pane actionBuilder @@ -380,7 +379,9 @@ public class ExamForm implements TemplateComposer { .newAction(ActionDefinition.EXAM_SEB_CLIENT_CONFIG_EXPORT) .withEntityKey(entityKey) - .withExec(this.examCreateClientConfigPopup.exportFunction(exam.institutionId)) + .withExec(this.examCreateClientConfigPopup.exportFunction( + exam.institutionId, + exam.getName())) .publishIf(() -> writeGrant && readonly) .newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBClientConfigDownload.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBClientConfigDownload.java index 6875b70b..55b49146 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBClientConfigDownload.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/download/SEBClientConfigDownload.java @@ -16,7 +16,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; @@ -35,14 +34,11 @@ public class SEBClientConfigDownload extends AbstractDownloadServiceHandler { private static final Logger log = LoggerFactory.getLogger(SEBClientConfigDownload.class); private final RestService restService; - public final String downloadFileName; protected SEBClientConfigDownload( - final RestService restService, - @Value("${sebserver.gui.seb.client.config.download.filename}") final String downloadFileName) { + final RestService restService) { this.restService = restService; - this.downloadFileName = downloadFileName; } @Override