diff --git a/src/main/java/org/olat/modules/lecture/ui/CancelRollCallConfirmationController.java b/src/main/java/org/olat/modules/lecture/ui/CancelRollCallConfirmationController.java index e03b26ecb54a44d89037a71a12a3c8c2b2971bc7..fe90df50db139f6f758d474bd8a82efef62d0ec3 100644 --- a/src/main/java/org/olat/modules/lecture/ui/CancelRollCallConfirmationController.java +++ b/src/main/java/org/olat/modules/lecture/ui/CancelRollCallConfirmationController.java @@ -99,7 +99,12 @@ public class CancelRollCallConfirmationController extends FormBasicController { } } if(!found) { - effectiveEndReasonEl.select(reasonKeyList.get(0), true); + if(reasonKeyList.isEmpty()) { + effectiveEndReasonEl.setEnabled(false); + effectiveEndReasonEl.setVisible(false); + } else { + effectiveEndReasonEl.select(reasonKeyList.get(0), true); + } } @@ -120,7 +125,7 @@ public class CancelRollCallConfirmationController extends FormBasicController { boolean allOk = true; effectiveEndReasonEl.clearError(); - if(!effectiveEndReasonEl.isOneSelected()) { + if(effectiveEndReasonEl.isEnabled() && !effectiveEndReasonEl.isOneSelected()) { effectiveEndReasonEl.setErrorKey("error.reason.mandatory", null); allOk &= false; } @@ -131,9 +136,11 @@ public class CancelRollCallConfirmationController extends FormBasicController { @Override protected void formOK(UserRequest ureq) { String before = lectureService.toAuditXml(lectureBlock); - Long reasonKey = new Long(effectiveEndReasonEl.getSelectedKey()); - Reason selectedReason = lectureService.getReason(reasonKey); - lectureBlock.setReasonEffectiveEnd(selectedReason); + if(effectiveEndReasonEl.isEnabled()) { + Long reasonKey = Long.valueOf(effectiveEndReasonEl.getSelectedKey()); + Reason selectedReason = lectureService.getReason(reasonKey); + lectureBlock.setReasonEffectiveEnd(selectedReason); + } lectureBlock = lectureService.cancel(lectureBlock); String after = lectureService.toAuditXml(lectureBlock); lectureService.auditLog(LectureBlockAuditLog.Action.cancelLectureBlock, before, after, null, lectureBlock, null, lectureBlock.getEntry(), null, getIdentity());