diff --git a/app/controllers/SettingsController.java b/app/controllers/SettingsController.java index 211ce728b..04c922d3e 100644 --- a/app/controllers/SettingsController.java +++ b/app/controllers/SettingsController.java @@ -184,13 +184,6 @@ public Result getMaxFilesize() { return ok(Json.toJson(node)); } - @Restrict({ @Group("ADMIN"), @Group("TEACHER") }) - public Result getExamMaxDate() { - ObjectNode node = Json.newObject(); - node.put("maxDate", configReader.getExamMaxDate()); - return ok(Json.toJson(node)); - } - @Restrict({ @Group("ADMIN"), @Group("TEACHER") }) public Result getExamDurations() { ObjectNode node = Json.newObject(); diff --git a/app/impl/ExamUpdaterImpl.java b/app/impl/ExamUpdaterImpl.java index ebcea9a6b..68f2d5941 100644 --- a/app/impl/ExamUpdaterImpl.java +++ b/app/impl/ExamUpdaterImpl.java @@ -65,6 +65,16 @@ public Optional updateTemporalFieldsAndValidate(Exam exam, User user, Ht exam.setDuration(newDuration.orElse(null)); return Optional.empty(); } + if (exam.isUnsupervised() && newEnd.isPresent()) { + Set dates = exam + .getExaminationEventConfigurations() + .stream() + .map(c -> c.getExaminationEvent().getStart()) + .collect(Collectors.toSet()); + if (dates.stream().anyMatch(d -> d.isAfter(newEnd.get()))) { + return Optional.of(forbidden("i18n_error_future_reservations_exist")); + } + } boolean hasFutureReservations = hasFutureReservations(exam); boolean isAdmin = user.hasRole(Role.Name.ADMIN); if (newStart.isPresent()) { diff --git a/app/models/Exam.java b/app/models/Exam.java index 287515409..238399377 100644 --- a/app/models/Exam.java +++ b/app/models/Exam.java @@ -862,6 +862,10 @@ public boolean isPrintout() { return executionType.getType().equals(ExamExecutionType.Type.PRINTOUT.toString()); } + public boolean isUnsupervised() { + return !executionType.getType().equals(Implementation.AQUARIUM.toString()); + } + public boolean hasState(State... states) { return Arrays.asList(states).contains(state); } @@ -895,30 +899,6 @@ public int hashCode() { return new HashCodeBuilder().append(id).build(); } - @Override - public String toString() { - return ( - "Exam{" + - "course=" + - course + - ", id='" + - id + - '\'' + - ", name='" + - name + - '\'' + - ", examType=" + - examType + - ", hash='" + - hash + - '\'' + - ", state='" + - state + - '\'' + - '}' - ); - } - @Override public int compareTo(@Nonnull Exam other) { return created.compareTo(other.created); diff --git a/app/util/config/ConfigReader.java b/app/util/config/ConfigReader.java index b9a3349a6..deaf3cdfc 100644 --- a/app/util/config/ConfigReader.java +++ b/app/util/config/ConfigReader.java @@ -10,7 +10,6 @@ public interface ConfigReader { DateTimeZone getDefaultTimeZone(); String getHostName(); Integer getMaxFileSize(); - String getExamMaxDate(); List getExamDurations(); Integer getExamMaxDuration(); Integer getExamMinDuration(); diff --git a/app/util/config/ConfigReaderImpl.java b/app/util/config/ConfigReaderImpl.java index 80103def0..cfbad9830 100644 --- a/app/util/config/ConfigReaderImpl.java +++ b/app/util/config/ConfigReaderImpl.java @@ -55,13 +55,6 @@ public Integer getMaxFileSize() { return config.getInt("exam.attachment.maxsize"); } - @Override - public String getExamMaxDate() { - DateTime newDate = new DateTime(0); - Period period = Period.parse(config.getString("exam.exam.maxDate")); - return newDate.plus(period).toString(); - } - @Override public List getExamDurations() { String[] durations = config.getString("exam.exam.durations").split(","); diff --git a/conf/routes b/conf/routes index 35fdfe669..8bd0a714e 100644 --- a/conf/routes +++ b/conf/routes @@ -424,7 +424,6 @@ PUT /app/settings/deadline controlle GET /app/settings/reservationWindow controllers.SettingsController.getReservationWindowSize PUT /app/settings/reservationWindow controllers.SettingsController.setReservationWindowSize(request: Request) GET /app/settings/hostname controllers.SettingsController.getHostname -GET /app/settings/maxDate controllers.SettingsController.getExamMaxDate GET /app/settings/durations controllers.SettingsController.getExamDurations GET /app/settings/maxDuration controllers.SettingsController.getExamMaxDuration GET /app/settings/minDuration controllers.SettingsController.getExamMinDuration diff --git a/lefthook.yml b/lefthook.yml index 368a7d988..921018143 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -7,7 +7,7 @@ pre-commit: prettier-java: tags: backend style glob: "**/*.java" - run: prettier --write --plugin=prettier-plugin-java --print-width=120 --tab-width=4 {staged_files} + run: npx prettier --write --plugin=prettier-plugin-java --print-width=120 --tab-width=4 {staged_files} eslint: tags: frontend rules glob: "**/*.ts" diff --git a/ui/src/app/exam/editor/events/examination-event-dialog.component.html b/ui/src/app/exam/editor/events/examination-event-dialog.component.html index 737a4428b..6bf1bb1db 100644 --- a/ui/src/app/exam/editor/events/examination-event-dialog.component.html +++ b/ui/src/app/exam/editor/events/examination-event-dialog.component.html @@ -35,7 +35,7 @@

[hourStep]="1" [minuteStep]="15" [initialTime]="start()" - [examMaxDate]="examMaxDate" + [maxDate]="examMaxDate" (updated)="onStartDateChange($event)" autofocus > @@ -129,10 +129,7 @@