Search in sources :

Example 6 with Reason

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);
}
Also used : Reason(org.olat.modules.lecture.Reason)

Example 7 with Reason

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);
}
Also used : ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Reason(org.olat.modules.lecture.Reason)

Example 8 with Reason

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);
}
Also used : ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Reason(org.olat.modules.lecture.Reason)

Example 9 with Reason

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()));
}
Also used : Reason(org.olat.modules.lecture.Reason)

Example 10 with Reason

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));
}
Also used : Reason(org.olat.modules.lecture.Reason) Test(org.junit.Test)

Aggregations

Reason (org.olat.modules.lecture.Reason)28 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 Date (java.util.Date)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 LectureBlock (org.olat.modules.lecture.LectureBlock)4 Calendar (java.util.Calendar)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 Identity (org.olat.core.id.Identity)2 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)2 LectureBlockWithTeachers (org.olat.modules.lecture.model.LectureBlockWithTeachers)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2