Search in sources :

Example 1 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.

the class CheckListAssessmentController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormDescription("coach.desc");
    setFormContextHelp("Assessment#_checklist_manage");
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        if (dueDate != null) {
            layoutCont.contextPut("dueDate", dueDate);
        }
    }
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    if (isAdministrativeUser) {
        options.setDefaultOrderBy(new SortKey(Cols.username.name(), true));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18nKey(), Cols.username.ordinal(), true, Cols.username.name()));
    }
    int i = 0;
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        int colIndex = CheckListAssessmentDataModel.USER_PROPS_OFFSET + i++;
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        if (visible) {
            FlexiColumnModel col;
            if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
                col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, userPropertyHandler.getName(), true, propName, new StaticFlexiCellRenderer(userPropertyHandler.getName(), new TextFlexiCellRenderer()));
            } else {
                col = new DefaultFlexiColumnModel(true, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
            }
            columnsModel.addFlexiColumnModel(col);
            if (options.getDefaultOrderBy() == null) {
                options.setDefaultOrderBy(new SortKey(propName, true));
            }
        }
    }
    int numOfCheckbox = checkboxList.getNumOfCheckbox();
    List<Checkbox> boxList = checkboxList.getList();
    int j = 0;
    for (Checkbox box : boxList) {
        int colIndex = CheckListAssessmentDataModel.CHECKBOX_OFFSET + j++;
        String colName = "checkbox_" + colIndex;
        DefaultFlexiColumnModel column = new DefaultFlexiColumnModel(true, colName, colIndex, true, colName);
        column.setHeaderLabel(StringHelper.escapeHtml(box.getTitle()));
        columnsModel.addFlexiColumnModel(column);
    }
    if (withScore) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.totalPoints.i18nKey(), Cols.totalPoints.ordinal(), true, "points"));
    }
    if (coachCourseEnv.isCourseReadOnly()) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.view.checkbox", translate("table.header.view.checkbox"), "view"));
    } else {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.edit.checkbox", translate("table.header.edit.checkbox"), "edit"));
    }
    model = new CheckListAssessmentDataModel(checkboxList, new ArrayList<>(), columnsModel, getLocale());
    table = uifactory.addTableElement(getWindowControl(), "checkbox-list", model, getTranslator(), formLayout);
    if (coachCourseEnv instanceof UserCourseEnvironmentImpl) {
        UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
        List<BusinessGroup> coachedGroups = env.getCoachedGroups();
        List<FlexiTableFilter> filters = new ArrayList<>(coachedGroups.size() + 1);
        filters.add(new FlexiTableFilter(translate("filter.all"), "all"));
        for (int k = 0; k < coachedGroups.size(); k++) {
            BusinessGroup group = coachedGroups.get(k);
            String groupName = StringHelper.escapeHtml(group.getName());
            filters.add(new FlexiTableFilter(groupName, group.getKey().toString()));
        }
        table.setFilters("participants", filters, false);
    }
    table.setExportEnabled(true);
    table.setCustomizeColumns(true);
    FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
    table.setSortSettings(sortOptions);
    table.setAndLoadPersistedPreferences(ureq, "checklist-assessment");
    pdfExportButton = uifactory.addFormLink("pdf.export", formLayout, Link.BUTTON);
    pdfExportButton.setEnabled(numOfCheckbox > 0);
    checkedPdfExportButton = uifactory.addFormLink("pdf.export.checked", formLayout, Link.BUTTON);
    checkedPdfExportButton.setEnabled(numOfCheckbox > 0);
    editButton = uifactory.addFormLink("edit", formLayout, Link.BUTTON);
    editButton.setEnabled(numOfCheckbox > 0);
    editButton.setVisible(!coachCourseEnv.isCourseReadOnly());
    saveButton = uifactory.addFormSubmitButton("save", formLayout);
    saveButton.getComponent().setSpanAsDomReplaceable(true);
    saveButton.setVisible(false);
    cancelButton = uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    cancelButton.setVisible(false);
    boxAssessmentButton = uifactory.addFormLink("box.assessment", formLayout, Link.BUTTON);
    boxAssessmentButton.setEnabled(numOfCheckbox > 0);
    boxAssessmentButton.setVisible(!coachCourseEnv.isCourseReadOnly());
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) BusinessGroup(org.olat.group.BusinessGroup) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) SortKey(org.olat.core.commons.persistence.SortKey) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) Checkbox(org.olat.course.nodes.cl.model.Checkbox) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 2 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.

the class CheckListBoxListEditController method doUp.

private void doUp(UserRequest ureq, int checkboxIndex) {
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (checkboxIndex > 0 && checkboxIndex < list.getList().size()) {
        Checkbox box = list.getList().remove(checkboxIndex);
        list.getList().add(checkboxIndex - 1, box);
    }
    fireEvent(ureq, Event.DONE_EVENT);
    updateModel();
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) Checkbox(org.olat.course.nodes.cl.model.Checkbox)

Example 3 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.

the class CheckListBoxListEditController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (addLink == source) {
        Checkbox checkbox = new Checkbox();
        checkbox.setCheckboxId(UUID.randomUUID().toString());
        doOpenEdit(ureq, checkbox, true, translate("add.checkbox"));
    } else if (boxTable == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            if ("edit".equals(cmd)) {
                CheckboxConfigRow row = model.getObject(se.getIndex());
                doOpenEdit(ureq, row.getCheckbox(), false, translate("edit.checkbox"));
            } else if ("up".equals(cmd)) {
                doUp(ureq, se.getIndex());
            } else if ("down".equals(cmd)) {
                doDown(ureq, se.getIndex());
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : Checkbox(org.olat.course.nodes.cl.model.Checkbox) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)

Example 4 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.

the class CheckListBoxListEditController method doDown.

private void doDown(UserRequest ureq, int checkboxIndex) {
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (checkboxIndex >= 0 && checkboxIndex < list.getList().size() - 1) {
        Checkbox box = list.getList().remove(checkboxIndex);
        list.getList().add(checkboxIndex + 1, box);
    }
    fireEvent(ureq, Event.DONE_EVENT);
    updateModel();
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) Checkbox(org.olat.course.nodes.cl.model.Checkbox)

Example 5 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.

the class CheckListRunController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean readOnly = isReadOnly();
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("readOnly", Boolean.valueOf(readOnly));
        if (dueDate != null) {
            layoutCont.contextPut("dueDate", dueDate);
            layoutCont.contextPut("in-due-date", isPanelOpen(ureq, "due-date", true));
            if (dueDate.compareTo(new Date()) < 0) {
                layoutCont.contextPut("afterDueDate", Boolean.TRUE);
            }
        }
        layoutCont.contextPut("withScore", new Boolean(withScore));
        if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
            HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode, this.mainForm);
            if (highScoreCtr.isViewHighscore()) {
                Component highScoreComponent = highScoreCtr.getInitialComponent();
                layoutCont.put("highScore", highScoreComponent);
            }
        }
        List<DBCheck> checks = checkboxManager.loadCheck(getIdentity(), courseOres, courseNode.getIdent());
        Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
        for (DBCheck check : checks) {
            uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
        }
        List<Checkbox> list = checkboxList.getList();
        List<CheckboxWrapper> wrappers = new ArrayList<>(list.size());
        for (Checkbox checkbox : list) {
            DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
            CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
            layoutCont.add(wrapper.getCheckboxEl());
            wrappers.add(wrapper);
        }
        layoutCont.contextPut("checkboxList", wrappers);
        if (withScore || withPassed) {
            layoutCont.contextPut("enableScoreInfo", Boolean.TRUE);
            exposeConfigToVC(ureq, layoutCont);
            exposeUserDataToVC(ureq, layoutCont);
        } else {
            layoutCont.contextPut("enableScoreInfo", Boolean.FALSE);
        }
    }
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) Date(java.util.Date) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Component(org.olat.core.gui.components.Component)

Aggregations

Checkbox (org.olat.course.nodes.cl.model.Checkbox)58 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)24 ArrayList (java.util.ArrayList)16 CheckboxManager (org.olat.course.nodes.cl.CheckboxManager)14 ModuleConfiguration (org.olat.modules.ModuleConfiguration)14 File (java.io.File)12 HashMap (java.util.HashMap)12 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)12 Identity (org.olat.core.id.Identity)10 HashSet (java.util.HashSet)8 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)8 ICourse (org.olat.course.ICourse)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6 DBCheck (org.olat.course.nodes.cl.model.DBCheck)6 Date (java.util.Date)4 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)4