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 a30b123b..2d8a4cf2 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 @@ -44,6 +44,7 @@ import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport; import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey; import ch.ethz.seb.sebserver.gui.service.page.PageContext; import ch.ethz.seb.sebserver.gui.service.page.PageContext.AttributeKeys; +import ch.ethz.seb.sebserver.gui.service.page.PageMessageException; import ch.ethz.seb.sebserver.gui.service.page.PageService; import ch.ethz.seb.sebserver.gui.service.page.PageService.PageActionBuilder; import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer; @@ -98,6 +99,8 @@ public class ExamForm implements TemplateComposer { private static final LocTextKey FORM_LMSSETUP_TEXT_KEY = new LocTextKey("sebserver.exam.form.lmssetup"); + private final static LocTextKey CONFIG_ACTION_NO_CONFIG_MESSAGE = + new LocTextKey("sebserver.exam.configuration.action.noconfig.message"); private final static LocTextKey CONFIG_LIST_TITLE_KEY = new LocTextKey("sebserver.exam.configuration.list.title"); private final static LocTextKey CONFIG_NAME_COLUMN_KEY = @@ -324,10 +327,20 @@ public class ExamForm implements TemplateComposer { EntityType.CONFIGURATION_NODE) : null; + final boolean noConfigsAvailable = this.resourceService + .examConfigurationSelectionResources() + .isEmpty(); + actionBuilder .newAction(ActionDefinition.EXAM_CONFIGURATION_NEW) .withParentEntityKey(entityKey) + .withExec(action -> { + if (noConfigsAvailable) { + throw new PageMessageException(CONFIG_ACTION_NO_CONFIG_MESSAGE); + } + return action; + }) .publishIf(() -> modifyGrant && editable && !configurationTable.hasAnyContent()) .newAction(ActionDefinition.EXAM_CONFIGURATION_EXAM_CONFIG_VIEW_PROP) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSebConfigMapForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSebConfigMapForm.java index 76e646de..f8052101 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSebConfigMapForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamSebConfigMapForm.java @@ -129,6 +129,7 @@ public class ExamSebConfigMapForm implements TemplateComposer { .putStaticValue( Domain.EXAM_CONFIGURATION_MAP.ATTR_EXAM_ID, String.valueOf(examConfigurationMap.examId)) + .addField(FormBuilder.singleSelection( Domain.EXAM_CONFIGURATION_MAP.ATTR_CONFIGURATION_NODE_ID, CONFIG_MAPPING_NAME_TEXT_KEY, diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 507eb2af..79668a8a 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -318,6 +318,7 @@ sebserver.exam.configuration.list.column.description=Description sebserver.exam.configuration.list.column.status=Status sebserver.exam.configuration.list.empty=There is currently no SEB Configuration defined for this Exam. Please add one sebserver.exam.configuration.list.pleaseSelect=Please Select a SEB Configuration first +sebserver.exam.configuration.action.noconfig.message=There is currently no SEB exam configuration to select.
Please create one in SEB Configuration / Exam Configuration sebserver.exam.configuration.action.list.new=Add sebserver.exam.configuration.action.list.modify=Edit