use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.
the class ReasonAdminController method loadModel.
private void loadModel() {
List<Reason> reasons = lectureService.getAllReasons();
List<ReasonRow> rows = new ArrayList<>(reasons.size());
for (Reason reason : reasons) {
String linkName = "tools-" + counter++;
FormLink toolsLink = uifactory.addFormLink(linkName, "", null, flc, Link.LINK | Link.NONTRANSLATED);
toolsLink.setIconRightCSS("o_icon o_icon_actions o_icon-lg");
toolsLink.setUserObject(reason);
flc.add(linkName, toolsLink);
rows.add(new ReasonRow(reason, toolsLink));
}
dataModel.setObjects(rows);
tableEl.reset(true, true, true);
}
use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.
the class ReasonAdminController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (editReasonCtrl == source) {
if (event == Event.DONE_EVENT) {
loadModel();
}
cmc.deactivate();
cleanUp();
} else if (cmc == source) {
cleanUp();
} else if (toolsCalloutCtrl == source) {
cleanUp();
} else if (toolsCtrl == source) {
if (event == Event.DONE_EVENT) {
if (toolsCalloutCtrl != null) {
toolsCalloutCtrl.deactivate();
cleanUp();
}
}
} else if (deleteDialogCtrl == source) {
if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
Reason row = (Reason) deleteDialogCtrl.getUserObject();
doDelete(row);
loadModel();
}
}
super.event(ureq, source, event);
}
use of org.olat.modules.lecture.Reason in project OpenOLAT by OpenOLAT.
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 ReasonDAOTest method isReasonInUse.
@Test
public void isReasonInUse() {
// create a reason
String title = "3. reason";
String description = "Use it";
Reason reason = reasonDao.createReason(title, description);
dbInstance.commitAndCloseSession();
// add to a lecture block
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
lectureBlock.setStartDate(new Date());
lectureBlock.setEndDate(new Date());
lectureBlock.setTitle("Hello lecturers");
lectureBlock.setReasonEffectiveEnd(reason);
lectureBlock = lectureBlockDao.update(lectureBlock);
dbInstance.commitAndCloseSession();
// check
boolean inUse = reasonDao.isReasonInUse(reason);
Assert.assertTrue(inUse);
}
use of org.olat.modules.lecture.Reason in project openolat by klemens.
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);
}
}
}
Aggregations