use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.
the class CloseRollCallConfirmationController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_lecture_confirm_close_form");
if (lectureModule.isStatusPartiallyDoneEnabled()) {
int plannedLectures = lectureBlock.getPlannedLecturesNumber();
String[] effectiveKeys = new String[plannedLectures];
for (int i = plannedLectures; i-- > 0; ) {
effectiveKeys[i] = Integer.toString(i + 1);
}
effectiveLecturesEl = uifactory.addDropdownSingleselect("effective.lectures", formLayout, effectiveKeys, effectiveKeys, null);
int selectedEffectiveLectures = lectureBlock.getPlannedLecturesNumber();
if (lectureBlock.getEffectiveLecturesNumber() > 0) {
selectedEffectiveLectures = lectureBlock.getEffectiveLecturesNumber();
}
String selectedKey = Integer.toString(selectedEffectiveLectures);
for (String effectiveKey : effectiveKeys) {
if (effectiveKey.equals(selectedKey)) {
effectiveLecturesEl.select(effectiveKey, true);
break;
}
}
}
String datePage = velocity_root + "/date_end.html";
FormLayoutContainer dateCont = FormLayoutContainer.createCustomFormLayout("start_end", getTranslator(), datePage);
dateCont.setLabel("lecture.block.effective.end", null);
formLayout.add(dateCont);
effectiveEndHourEl = uifactory.addTextElement("lecture.end.hour", null, 2, "", dateCont);
effectiveEndHourEl.setDomReplacementWrapperRequired(false);
effectiveEndHourEl.setDisplaySize(2);
effectiveEndHourEl.setEnabled(secCallback.canEdit());
effectiveEndMinuteEl = uifactory.addTextElement("lecture.end.minute", null, 2, "", dateCont);
effectiveEndMinuteEl.setDomReplacementWrapperRequired(false);
effectiveEndMinuteEl.setDisplaySize(2);
effectiveEndMinuteEl.setEnabled(secCallback.canEdit());
Calendar cal = Calendar.getInstance();
if (lectureBlock.getEffectiveEndDate() != null) {
cal.setTime(lectureBlock.getEffectiveEndDate());
} else if (lectureBlock.getEndDate() != null) {
cal.setTime(lectureBlock.getEndDate());
}
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
effectiveEndHourEl.setValue(Integer.toString(hour));
String minuteStr = Integer.toString(minute);
if (minuteStr.length() == 1) {
minuteStr = "0" + minuteStr;
}
effectiveEndMinuteEl.setValue(minuteStr);
List<Reason> allReasons = lectureService.getAllReasons();
if (allReasons.size() > 0) {
if (allReasons.size() > 2) {
Collections.sort(allReasons, new ReasonComparator());
}
int numOfReasons = allReasons.size();
List<String> reasonKeys = new ArrayList<String>(numOfReasons + 1);
List<String> reasonValues = new ArrayList<String>(numOfReasons + 1);
reasonKeys.add("-");
reasonValues.add("");
for (int i = numOfReasons; i-- > 0; ) {
Reason reason = allReasons.get(i);
reasonKeys.add(reason.getKey().toString());
reasonValues.add(reason.getTitle());
}
effectiveEndReasonEl = uifactory.addDropdownSingleselect("effective.reason", "lecture.block.effective.reason", formLayout, reasonKeys.toArray(new String[reasonKeys.size()]), reasonValues.toArray(new String[reasonValues.size()]), null);
effectiveEndReasonEl.setEnabled(secCallback.canEdit());
if (lectureBlock.getReasonEffectiveEnd() != null) {
String selectedReasonKey = lectureBlock.getReasonEffectiveEnd().getKey().toString();
for (String reasonKey : reasonKeys) {
if (reasonKey.equals(selectedReasonKey)) {
effectiveEndReasonEl.select(reasonKey, true);
break;
}
}
}
}
String blockComment = lectureBlock.getComment();
blockCommentEl = uifactory.addTextAreaElement("lecture.block.comment", 4, 72, blockComment, formLayout);
blockCommentEl.setEnabled(secCallback.canEdit());
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
quickSaveButton = uifactory.addFormLink("save.temporary", buttonsCont, Link.BUTTON);
uifactory.addFormSubmitButton("close.lecture.blocks", buttonsCont);
}
use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.
the class CloseRollCallConfirmationController method commitLectureBlocks.
private void commitLectureBlocks() {
lectureBlock.setComment(blockCommentEl.getValue());
int effectiveLectures = lectureBlock.getPlannedLecturesNumber();
if (effectiveLecturesEl != null) {
try {
String selectedKey = effectiveLecturesEl.getSelectedKey();
effectiveLectures = Integer.parseInt(selectedKey);
} catch (Exception ex) {
logError("", ex);
}
}
lectureBlock.setEffectiveLecturesNumber(effectiveLectures);
Date effectiveEndDate = getEffectiveEndDate();
if (effectiveEndDate == null) {
lectureBlock.setReasonEffectiveEnd(null);
} else {
lectureBlock.setEffectiveEndDate(effectiveEndDate);
if (effectiveEndReasonEl == null || "-".equals(effectiveEndReasonEl.getSelectedKey())) {
lectureBlock.setReasonEffectiveEnd(null);
} else {
Long reasonKey = new Long(effectiveEndReasonEl.getSelectedKey());
Reason selectedReason = lectureService.getReason(reasonKey);
lectureBlock.setReasonEffectiveEnd(selectedReason);
}
}
}
use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.
the class CancelRollCallConfirmationController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
List<String> reasonKeyList = new ArrayList<>();
List<String> reasonValueList = new ArrayList<>();
List<Reason> allReasons = lectureService.getAllReasons();
Collections.sort(allReasons, new ReasonComparator());
for (Reason reason : allReasons) {
reasonKeyList.add(reason.getKey().toString());
reasonValueList.add(reason.getTitle());
}
effectiveEndReasonEl = uifactory.addDropdownSingleselect("effective.reason", "lecture.block.effective.reason", formLayout, reasonKeyList.toArray(new String[reasonKeyList.size()]), reasonValueList.toArray(new String[reasonValueList.size()]), null);
effectiveEndReasonEl.setEnabled(secCallback.canEdit());
boolean found = false;
if (lectureBlock.getReasonEffectiveEnd() != null) {
String selectedReasonKey = lectureBlock.getReasonEffectiveEnd().getKey().toString();
for (String reasonKey : reasonKeyList) {
if (reasonKey.equals(selectedReasonKey)) {
effectiveEndReasonEl.select(reasonKey, true);
found = true;
break;
}
}
}
if (!found) {
effectiveEndReasonEl.select(reasonKeyList.get(0), true);
}
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
uifactory.addFormSubmitButton("cancel.lecture.blocks", buttonsCont);
}
use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.
the class CancelRollCallConfirmationController method formOK.
@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);
lectureBlock = lectureService.cancel(lectureBlock);
String after = lectureService.toAuditXml(lectureBlock);
lectureService.auditLog(LectureBlockAuditLog.Action.cancelLectureBlock, before, after, null, lectureBlock, null, lectureBlock.getEntry(), null, getIdentity());
fireEvent(ureq, Event.DONE_EVENT);
ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LECTURE_BLOCK_ROLL_CALL_CANCELLED, getClass(), CoreLoggingResourceable.wrap(lectureBlock, OlatResourceableType.lectureBlock, lectureBlock.getTitle()));
}
use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.
the class ReasonAdminController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (addReasonButton == source) {
doAddReason(ureq);
} else if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
ReasonRow row = dataModel.getObject(se.getIndex());
if ("edit".equals(cmd)) {
doEditReason(ureq, row.getReason());
}
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if (cmd != null && cmd.startsWith("tools-")) {
Reason row = (Reason) link.getUserObject();
doOpenTools(ureq, row, link);
}
}
super.formInnerEvent(ureq, source, event);
}
Aggregations