use of org.olat.modules.lecture.Reason in project openolat by klemens.
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);
}
use of org.olat.modules.lecture.Reason in project openolat by klemens.
the class LecturesBlocksEntryExport method addContent.
private void addContent(OpenXMLWorksheet exportSheet) {
for (LectureBlockWithTeachers block : blocks) {
Row row = exportSheet.newRow();
LectureBlock lectureBlock = block.getLectureBlock();
int pos = 0;
row.addCell(pos++, lectureBlock.getTitle());
row.addCell(pos++, lectureBlock.getLocation());
row.addCell(pos++, formatDate(lectureBlock.getStartDate()));
row.addCell(pos++, formatTime(lectureBlock.getStartDate()));
row.addCell(pos++, formatTime(lectureBlock.getEndDate()));
StringBuilder teachers = new StringBuilder();
for (Identity teacher : block.getTeachers()) {
if (teachers.length() > 0)
teachers.append(", ");
teachers.append(userManager.getUserDisplayName(teacher));
}
row.addCell(pos++, teachers.toString());
if (lectureBlock.getRollCallStatus() == null) {
pos++;
} else {
String status = LectureBlockStatusCellRenderer.getStatus(lectureBlock, translator);
if (status != null) {
row.addCell(pos++, status);
} else {
pos++;
}
}
row.addCell(pos++, formatter.formatDate(lectureBlock.getAutoClosedDate()));
row.addCell(pos++, toInt(lectureBlock.getPlannedLecturesNumber()));
row.addCell(pos++, toInt(lectureBlock.getEffectiveLecturesNumber()));
row.addCell(pos++, formatTime(lectureBlock.getEffectiveEndDate()));
Reason reason = lectureBlock.getReasonEffectiveEnd();
if (reason == null) {
pos++;
} else {
row.addCell(pos++, reason.getTitle());
}
row.addCell(pos++, lectureBlock.getComment());
}
}
use of org.olat.modules.lecture.Reason in project openolat by klemens.
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);
}
Aggregations