From 22fcd3a3bcd63dcf0eb37728a4dd5950dd1fb321 Mon Sep 17 00:00:00 2001 From: tomas-muller Date: Tue, 28 May 2024 15:52:40 +0200 Subject: [PATCH] Instructional Offering Configuration: New GWT-based Page - allow for classes with zero limit (when configuration limit is also zero) - fixed an error when creating an unlimited configuration (class limit cannot be null) - when class limit is zero, default the number of classes to one --- .../gwt/client/offerings/InstrOfferingConfigPage.java | 6 +++--- .../gwt/client/offerings/InstrOfferingConfigTable.java | 10 +++++++--- .../server/courses/InstrOfferingConfigBackend.java | 8 ++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/JavaSource/org/unitime/timetable/gwt/client/offerings/InstrOfferingConfigPage.java b/JavaSource/org/unitime/timetable/gwt/client/offerings/InstrOfferingConfigPage.java index 87d406883d..297115e8d3 100644 --- a/JavaSource/org/unitime/timetable/gwt/client/offerings/InstrOfferingConfigPage.java +++ b/JavaSource/org/unitime/timetable/gwt/client/offerings/InstrOfferingConfigPage.java @@ -474,7 +474,7 @@ protected void updateCounts() { if (parent != null && parent.getNumberOfClasses() != null && parent.getMaxClassLimit() != null) { if (line.getNumberOfClasses() <= 0 || parent.getNumberOfClasses() <= 0 || (line.getNumberOfClasses() % parent.getNumberOfClasses()) != 0) badNbrClasses = true; // not divisible # children - if (line.getMaxClassLimit() <= 0 || parent.getMaxClassLimit() <= 0) + if (line.getMaxClassLimit() < 0 || parent.getMaxClassLimit() < 0) badLimit = true; // class too small if (line.getNumberOfClasses() * line.getMaxClassLimit() < parent.getNumberOfClasses() * parent.getMaxClassLimit()) badLimit = true; // class too small @@ -485,7 +485,7 @@ else if (line.getMaxClassLimit() > parent.getMaxClassLimit()) } else if (parent == null && iData.getLimit() != null) { if (line.getNumberOfClasses() <= 0) badNbrClasses = true; - if (line.getMaxClassLimit() <= 0) + if (line.getMaxClassLimit() < 0) badLimit = true; if (iData.isCheckLimits()) { if (line.getNumberOfClasses() * line.getMaxClassLimit() < iData.getLimit()) @@ -571,7 +571,7 @@ private boolean validate() { errors.add(error); line.addError(error); } - if (iData.isUnlimited() && (line.getMinClassLimit() == null || line.getMaxClassLimit() == null || line.getMinClassLimit() <= 0 || line.getMaxClassLimit() <= 0)) { + if (!iData.isUnlimited() && (line.getMinClassLimit() == null || line.getMaxClassLimit() == null || line.getMinClassLimit() < 0 || line.getMaxClassLimit() < 0)) { String error = MESSAGES.errorIntegerGtEq(MESSAGES.messageLimitPerClassForIType(lblMax, line.getLabel()), "0"); errors.add(error); line.addError(error); diff --git a/JavaSource/org/unitime/timetable/gwt/client/offerings/InstrOfferingConfigTable.java b/JavaSource/org/unitime/timetable/gwt/client/offerings/InstrOfferingConfigTable.java index 2d584fcf86..710ebdb4f5 100644 --- a/JavaSource/org/unitime/timetable/gwt/client/offerings/InstrOfferingConfigTable.java +++ b/JavaSource/org/unitime/timetable/gwt/client/offerings/InstrOfferingConfigTable.java @@ -597,15 +597,19 @@ protected void updateNumberOfClasses() { SubpartLine parent = iData.getSubpartLine(iLine.getParentId()); if (parent != null && parent.getMaxClassLimit() != null && parent.getNumberOfClasses() != null) { int classesPerParent = (int)Math.ceil(parent.getMaxClassLimit().doubleValue() / iLine.getMaxClassLimit()); - if (iLine.getMaxClassLimit() <= 0) + if (iLine.getMaxClassLimit() < 0) iLine.setNumberOfClasses(null); + else if (iLine.getMaxClassLimit() == 0) + iLine.setNumberOfClasses(1); else iLine.setNumberOfClasses(parent.getNumberOfClasses() * classesPerParent); } else { - if (iLine.getMaxClassLimit() <= 0) + if (iLine.getMaxClassLimit() < 0) iLine.setNumberOfClasses(null); + else if (iLine.getMaxClassLimit() == 0) + iLine.setNumberOfClasses(1); else - iLine.setNumberOfClasses((int)Math.ceil(iData.getLimit().doubleValue() / iLine.getMaxClassLimit())); + iLine.setNumberOfClasses(Math.max(1, (int)Math.ceil(iData.getLimit().doubleValue() / iLine.getMaxClassLimit()))); } nbrClasses.setValue(iLine.getNumberOfClasses()); } diff --git a/JavaSource/org/unitime/timetable/server/courses/InstrOfferingConfigBackend.java b/JavaSource/org/unitime/timetable/server/courses/InstrOfferingConfigBackend.java index 258e84aec0..94b4cf1939 100644 --- a/JavaSource/org/unitime/timetable/server/courses/InstrOfferingConfigBackend.java +++ b/JavaSource/org/unitime/timetable/server/courses/InstrOfferingConfigBackend.java @@ -607,9 +607,9 @@ private void addOrUpdateSubparts(InstrOfferingConfigInterface form, InstrOfferin newClass.setSchedulingSubpart(ss); ss.addToClasses(newClass); newClass.setControllingDept(ss.getControllingDept()); - newClass.setExpectedCapacity(line.getMinClassLimit()); + newClass.setExpectedCapacity(line.getMinClassLimit() == null ? 0 : line.getMinClassLimit()); newClass.setNbrRooms(line.getNumberOfRooms()); - newClass.setMaxExpectedCapacity(line.getMaxClassLimit()); + newClass.setMaxExpectedCapacity(line.getMaxClassLimit() == null ? 0 : line.getMaxClassLimit()); newClass.setRoomRatio(line.getRoomRatio()); newClass.setDisplayInstructor(true); newClass.setEnabledForStudentScheduling(true); @@ -670,8 +670,8 @@ private void addOrUpdateSubparts(InstrOfferingConfigInterface form, InstrOfferin adept.setManagingDept(DepartmentDAO.getInstance().get(managingDeptId, hibSession), context.getUser(), hibSession); else adept.setManagingDept(ioc.getDepartment(), context.getUser(), hibSession); - adept.setExpectedCapacity(line.getMinClassLimit()); - adept.setMaxExpectedCapacity(line.getMaxClassLimit()); + adept.setExpectedCapacity(line.getMinClassLimit() == null ? 0 : line.getMinClassLimit()); + adept.setMaxExpectedCapacity(line.getMaxClassLimit() == null ? 0 : line.getMaxClassLimit()); adept.setNbrRooms(line.getNumberOfRooms()); adept.setRoomRatio(line.getRoomRatio()); adept.setRoomsSplitAttendance(line.getSplitAttendance());