Skip to content

Commit

Permalink
Instructional Offering Configuration: New GWT-based Page
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
tomas-muller committed May 28, 2024
1 parent 5bc12cc commit 22fcd3a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 22fcd3a

Please sign in to comment.