Search in sources :

Example 96 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class AssessedIdentityCheckListController method forgeCheckboxWrapper.

private CheckboxWrapper forgeCheckboxWrapper(Checkbox checkbox, DBCheck check, boolean readOnly, FormItemContainer formLayout) {
    String[] values = new String[] { translate(checkbox.getLabel().i18nKey()) };
    String boxId = "box_" + checkbox.getCheckboxId();
    MultipleSelectionElement boxEl = uifactory.addCheckboxesHorizontal(boxId, null, formLayout, onKeys, values);
    boxEl.setEnabled(!readOnly && !coachCourseEnv.isCourseReadOnly());
    boxEl.setLabel(checkbox.getTitle(), null, false);
    boxEl.showLabel(true);
    boxEl.addActionListener(FormEvent.ONCHANGE);
    TextElement pointEl = null;
    if (withScore && checkbox.getPoints() != null) {
        String pointId = "point_" + checkbox.getCheckboxId();
        String points;
        if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
            points = AssessmentHelper.getRoundedScore(check.getScore());
        } else {
            points = null;
        }
        pointEl = uifactory.addTextElement(pointId, null, 16, points, formLayout);
        pointEl.setDisplaySize(5);
        pointEl.setEnabled(!coachCourseEnv.isCourseReadOnly());
        Float maxScore = checkbox.getPoints();
        if (maxScore != null) {
            String maxValue = AssessmentHelper.getRoundedScore(maxScore);
            pointEl.setExampleKey("checklist.point.example", new String[] { "0", maxValue });
        }
        // hide when not yet checked
        if (check != null) {
            pointEl.setVisible(check.getChecked());
        } else {
            pointEl.setVisible(false);
        }
    }
    CheckboxWrapper wrapper = new CheckboxWrapper(checkbox, check, boxEl, pointEl);
    boxEl.setUserObject(wrapper);
    if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
        boxEl.select(onKeys[0], true);
        wrapper.setDbCheckbox(check.getCheckbox());
    }
    return wrapper;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement)

Example 97 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class AssessedIdentityCheckListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof MultipleSelectionElement) {
        MultipleSelectionElement boxEl = (MultipleSelectionElement) source;
        CheckboxWrapper wrapper = (CheckboxWrapper) boxEl.getUserObject();
        doUpdateCheck(wrapper, boxEl.isAtLeastSelected(1));
    } else if (saveAndCloseLink == source) {
        if (validateFormLogic(ureq)) {
            doSave();
            fireEvent(ureq, Event.DONE_EVENT);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 98 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class EditMembershipController method createSelection.

private MultipleSelectionElement createSelection(boolean selected, boolean enabled, String role) {
    String name = "cb" + UUID.randomUUID().toString().replace("-", "");
    MultipleSelectionElement selection = new MultipleSelectionElementImpl(name, Layout.horizontal);
    selection.setElementCssClass("o_sel_role");
    selection.addActionListener(FormEvent.ONCHANGE);
    selection.setKeysAndValues(keys, values, new String[] { "o_sel_role_".concat(role) }, null);
    flc.add(name, selection);
    selection.select(keys[0], selected);
    selection.setEnabled(enabled);
    return selection;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) MultipleSelectionElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.MultipleSelectionElementImpl)

Example 99 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class TeacherRollCallController method doCheckAllRow.

private void doCheckAllRow(TeacherRollCallRow row) {
    List<Integer> allAbsences = new ArrayList<>(numOfLectures);
    for (int i = 0; i < numOfLectures; i++) {
        allAbsences.add(i);
    }
    LectureBlockRollCall rollCall = lectureService.addRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), null, allAbsences);
    for (MultipleSelectionElement check : row.getChecks()) {
        check.select(onKeys[0], true);
    }
    row.setRollCall(rollCall);
    if (authorizedAbsenceEnabled) {
        if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
            row.getAuthorizedAbsence().select(onKeys[0], true);
        } else {
            row.getAuthorizedAbsence().uncheckAll();
        }
        row.getAuthorizedAbsenceCont().setDirty(true);
    }
    row.getRollCallStatusEl().getComponent().setDirty(true);
    tableEl.reloadData();
    flc.setDirty(true);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) ArrayList(java.util.ArrayList)

Example 100 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class TeacherRollCallController method updateUI.

private void updateUI() {
    quickSaveButton.setVisible(secCallback.canEdit());
    closeLectureBlocksButton.setVisible(secCallback.canEdit());
    if (cancelLectureBlockButton != null) {
        cancelLectureBlockButton.setVisible(secCallback.canEdit());
    }
    reopenButton.setVisible(secCallback.canReopen());
    List<TeacherRollCallRow> rows = tableModel.getObjects();
    if (rows != null) {
        for (TeacherRollCallRow row : rows) {
            MultipleSelectionElement[] checks = row.getChecks();
            if (checks != null) {
                for (MultipleSelectionElement check : checks) {
                    check.setEnabled(secCallback.canEditAbsences());
                    check.getComponent().setDirty(true);
                }
            }
            row.getCommentEl().setEnabled(secCallback.canEdit());
            if (row.getAuthorizedAbsence() != null) {
                row.getAuthorizedAbsence().setEnabled(secCallback.canEdit() && secCallback.canEditAuthorizedAbsences());
            }
        }
    }
    tableEl.reset(false, false, true);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Aggregations

MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)136 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)22 ArrayList (java.util.ArrayList)20 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)16 MultipleSelectionElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.MultipleSelectionElementImpl)16 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)10 FormItem (org.olat.core.gui.components.form.flexible.FormItem)8 Identity (org.olat.core.id.Identity)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)6 ICourse (org.olat.course.ICourse)6 Checkbox (org.olat.course.nodes.cl.model.Checkbox)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)5 VFSItem (org.olat.core.util.vfs.VFSItem)5 Section (org.olat.modules.portfolio.Section)5 File (java.io.File)4 UserShortDescription (org.olat.admin.user.UserShortDescription)4