Search in sources :

Example 16 with LectureBlockRow

use of org.olat.modules.lecture.model.LectureBlockRow in project openolat by klemens.

the class AbstractTeacherOverviewController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    String name = entries.get(0).getOLATResourceable().getResourceableTypeName();
    Long id = entries.get(0).getOLATResourceable().getResourceableId();
    if ("LectureBlock".equalsIgnoreCase(name)) {
        boolean started = false;
        if (entries.size() > 1) {
            String action = entries.get(1).getOLATResourceable().getResourceableTypeName();
            if ("Start".equalsIgnoreCase(action)) {
                LectureBlockRow row = currentLecturesBlockCtrl.getRow(id);
                if (row != null && canStartRollCall(row)) {
                    doStartRollCall(ureq, row.getLectureBlock());
                    started = true;
                }
            } else if ("StartWizard".equalsIgnoreCase(action)) {
                LectureBlockRow row = currentLecturesBlockCtrl.getRow(id);
                if (row != null && canStartRollCall(row)) {
                    doStartWizardRollCall(ureq, row.getLectureBlock());
                    started = true;
                }
            }
        }
        if (!started) {
            activateLectureBlockInTable(ureq, entries, state);
        }
    }
}
Also used : LectureBlockRow(org.olat.modules.lecture.model.LectureBlockRow)

Example 17 with LectureBlockRow

use of org.olat.modules.lecture.model.LectureBlockRow in project openolat by klemens.

the class AbstractTeacherOverviewController method loadModel.

protected void loadModel(LecturesBlockSearchParameters searchParams) {
    currentSearchParams = searchParams;
    List<LectureBlockRow> rows = getRows(searchParams);
    // reset
    List<LectureBlockRow> currentBlocks = new ArrayList<>();
    List<LectureBlockRow> pendingBlocks = new ArrayList<>();
    List<LectureBlockRow> nextBlocks = new ArrayList<>();
    List<LectureBlockRow> closedBlocks = new ArrayList<>();
    // only show the start button if
    Date now = new Date();
    for (LectureBlockRow row : rows) {
        LectureBlock block = row.getLectureBlock();
        if (canStartRollCall(row)) {
            startButton.setVisible(true);
            startButton.setUserObject(block);
            startButton.setPrimary(true);
            startWizardButton.setVisible(true);
            startWizardButton.setUserObject(block);
            currentBlocks.add(row);
        } else if (block.getStatus() == LectureBlockStatus.cancelled || block.getRollCallStatus() == LectureRollCallStatus.closed || block.getRollCallStatus() == LectureRollCallStatus.autoclosed) {
            closedBlocks.add(row);
        } else if (block.getStartDate() != null && block.getStartDate().after(now)) {
            nextBlocks.add(row);
        } else {
            pendingBlocks.add(row);
        }
    }
    currentLecturesBlockCtrl.loadModel(currentBlocks);
    mainVC.contextPut("currentBlockSize", currentBlocks.size());
    pendingLecturesBlockCtrl.loadModel(pendingBlocks);
    mainVC.contextPut("pendingBlockSize", pendingBlocks.size());
    nextLecturesBlockCtrl.loadModel(nextBlocks);
    mainVC.contextPut("nextBlockSize", nextBlocks.size());
    closedLecturesBlockCtrl.loadModel(closedBlocks);
    mainVC.contextPut("closedBlockSize", closedBlocks.size());
    mainVC.contextPut("totalBlockSize", getRowCount());
    dirtyTables = false;
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) ArrayList(java.util.ArrayList) LectureBlockRow(org.olat.modules.lecture.model.LectureBlockRow) Date(java.util.Date)

Example 18 with LectureBlockRow

use of org.olat.modules.lecture.model.LectureBlockRow in project openolat by klemens.

the class LectureListRepositoryController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (editLectureCtrl == 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)) {
            LectureBlockRow row = (LectureBlockRow) deleteDialogCtrl.getUserObject();
            doDelete(row);
            loadModel();
            cleanUp();
        }
    } else if (bulkDeleteDialogCtrl == source) {
        if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
            @SuppressWarnings("unchecked") List<LectureBlock> blocks = (List<LectureBlock>) bulkDeleteDialogCtrl.getUserObject();
            doDelete(blocks);
            loadModel();
            cleanUp();
        }
    }
    super.event(ureq, source, event);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) List(java.util.List) ArrayList(java.util.ArrayList) LectureBlockRow(org.olat.modules.lecture.model.LectureBlockRow)

Example 19 with LectureBlockRow

use of org.olat.modules.lecture.model.LectureBlockRow in project openolat by klemens.

the class LectureListRepositoryController method doConfirmBulkDelete.

private void doConfirmBulkDelete(UserRequest ureq) {
    Set<Integer> selections = tableEl.getMultiSelectedIndex();
    List<LectureBlock> blocks = new ArrayList<>();
    for (Integer selection : selections) {
        LectureBlockRow blockRow = tableModel.getObject(selection);
        if (!LectureBlockManagedFlag.isManaged(blockRow.getLectureBlock(), LectureBlockManagedFlag.delete)) {
            blocks.add(blockRow.getLectureBlock());
        }
    }
    if (blocks.isEmpty()) {
        showWarning("error.atleastone.lecture");
    } else {
        StringBuilder titles = new StringBuilder();
        for (LectureBlock block : blocks) {
            if (titles.length() > 0)
                titles.append(", ");
            titles.append(StringHelper.escapeHtml(block.getTitle()));
        }
        String text = translate("confirm.delete.lectures", new String[] { titles.toString() });
        bulkDeleteDialogCtrl = activateYesNoDialog(ureq, translate("delete.lectures.title"), text, bulkDeleteDialogCtrl);
        bulkDeleteDialogCtrl.setUserObject(blocks);
    }
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) ArrayList(java.util.ArrayList) LectureBlockRow(org.olat.modules.lecture.model.LectureBlockRow)

Example 20 with LectureBlockRow

use of org.olat.modules.lecture.model.LectureBlockRow in project openolat by klemens.

the class LectureListRepositoryController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (addLectureButton == source) {
        doAddLectureBlock(ureq);
    } else if (deleteLecturesButton == source) {
        doConfirmBulkDelete(ureq);
    } else if (source == tableEl) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            LectureBlockRow row = tableModel.getObject(se.getIndex());
            if ("edit".equals(cmd)) {
                doEditLectureBlock(ureq, row);
            }
        }
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if (cmd != null && cmd.startsWith("tools-")) {
            LectureBlockRow row = (LectureBlockRow) link.getUserObject();
            doOpenTools(ureq, row, link);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) LectureBlockRow(org.olat.modules.lecture.model.LectureBlockRow)

Aggregations

LectureBlockRow (org.olat.modules.lecture.model.LectureBlockRow)20 ArrayList (java.util.ArrayList)12 LectureBlock (org.olat.modules.lecture.LectureBlock)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)8 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)4 Identity (org.olat.core.id.Identity)4 LectureBlockWithTeachers (org.olat.modules.lecture.model.LectureBlockWithTeachers)4 Date (java.util.Date)2 List (java.util.List)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2