Search in sources :

Example 1 with Reason

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

Example 2 with Reason

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

Example 3 with Reason

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());
    }
}
Also used : LectureBlockWithTeachers(org.olat.modules.lecture.model.LectureBlockWithTeachers) LectureBlock(org.olat.modules.lecture.LectureBlock) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) Reason(org.olat.modules.lecture.Reason)

Example 4 with Reason

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);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Reason(org.olat.modules.lecture.Reason) Date(java.util.Date) Test(org.junit.Test)

Example 5 with Reason

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

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