use of org.olat.modules.lecture.Reason in project openolat by klemens.
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 klemens.
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 klemens.
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 klemens.
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 ReasonDAOTest method deleteReasons.
@Test
public void deleteReasons() {
// create a reason
String title = "Forgotten reason";
String description = "Find a list";
Reason reason = reasonDao.createReason(title, description);
dbInstance.commitAndCloseSession();
// check it exists
List<Reason> reasons = reasonDao.getReasons();
Assert.assertTrue(reasons.contains(reason));
// delete the reason
boolean deleted = reasonDao.delete(reason);
Assert.assertTrue(deleted);
// check it exists
List<Reason> reloadedDasons = reasonDao.getReasons();
Assert.assertFalse(reloadedDasons.contains(reason));
}
Aggregations