Search in sources :

Example 46 with Checkbox

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

the class CheckListAssessmentController method doSave.

private void doSave() {
    int numOfCheckbox = checkboxList.getNumOfCheckbox();
    // save all rows
    List<CheckListAssessmentRow> rows = model.getBackedUpRows();
    List<AssessmentBatch> batchElements = new ArrayList<>(rows.size());
    Set<Long> assessedIdentityToUpdate = new HashSet<>();
    for (CheckListAssessmentRow row : rows) {
        Boolean[] checked = row.getChecked();
        Boolean[] editedChecked = new Boolean[numOfCheckbox];
        MultipleSelectionElement[] checkedEls = row.getCheckedEl();
        if (checkedEls != null) {
            for (int i = 0; i < numOfCheckbox; i++) {
                MultipleSelectionElement checkEl = checkedEls[i];
                boolean editedValue = checkEl.isAtLeastSelected(1);
                editedChecked[i] = new Boolean(editedValue);
                boolean currentValue;
                if (checked != null && checked.length > 0 && i < checked.length && checked[i] != null) {
                    currentValue = checked[i].booleanValue();
                } else {
                    currentValue = false;
                }
                if (editedValue != currentValue) {
                    Checkbox checkbox = checkboxList.getList().get(i);
                    String checkboxId = checkbox.getCheckboxId();
                    Float score = editedValue ? checkbox.getPoints() : new Float(0f);
                    batchElements.add(new AssessmentBatch(row.getIdentityKey(), checkboxId, score, editedValue));
                    assessedIdentityToUpdate.add(row.getIdentityKey());
                }
                flc.remove(checkEl);
            }
        }
        row.setCheckedEl(null);
        row.setChecked(editedChecked);
    }
    doDisableEditingMode();
    checkboxManager.check(courseOres, courseNode.getIdent(), batchElements);
    if (assessedIdentityToUpdate.size() > 0) {
        DBFactory.getInstance().commit();
        ICourse course = CourseFactory.loadCourse(courseOres);
        List<Identity> assessedIdentities = securityManager.loadIdentityByKeys(assessedIdentityToUpdate);
        for (Identity assessedIdentity : assessedIdentities) {
            UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            courseNode.updateScoreEvaluation(getIdentity(), assessedUserCourseEnv, assessedIdentity, Role.coach);
        }
    }
    reloadTable();
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) AssessmentBatch(org.olat.course.nodes.cl.model.AssessmentBatch) Checkbox(org.olat.course.nodes.cl.model.Checkbox) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 47 with Checkbox

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

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 48 with Checkbox

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

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 49 with Checkbox

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

the class CheckListExcelExport method writeHeaders.

private void writeHeaders(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
    // second header
    // reset column counter
    int col = 0;
    Row header2Row = exportSheet.newRow();
    String sequentialNumber = translator.translate("column.header.seqnum");
    header2Row.addCell(col++, sequentialNumber, headerStyle);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null) {
            continue;
        }
        String header = translator.translate(userPropertyHandler.i18nFormElementLabelKey());
        header2Row.addCell(col++, header, headerStyle);
    }
    // add other user and session information
    header2Row.addCell(col++, translator.translate("column.header.homepage"), headerStyle);
    // course node points and passed
    if (courseNode.hasScoreConfigured()) {
        header2Row.addCell(col++, translator.translate("column.header.node.points"), headerStyle);
    }
    if (courseNode.hasPassedConfigured()) {
        header2Row.addCell(col++, translator.translate("column.header.node.passed"), headerStyle);
    }
    ModuleConfiguration config = courseNode.getModuleConfiguration();
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (list != null && list.getList() != null) {
        List<Checkbox> checkboxList = list.getList();
        for (Checkbox checkbox : checkboxList) {
            String boxTitle = checkbox.getTitle();
            header2Row.addCell(col++, boxTitle, headerStyle);
            if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
                header2Row.addCell(col++, translator.translate("column.header.points"), headerStyle);
            }
        }
    }
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ModuleConfiguration(org.olat.modules.ModuleConfiguration) Checkbox(org.olat.course.nodes.cl.model.Checkbox) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 50 with Checkbox

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

the class CheckListExcelExport method writeDataRow.

private void writeDataRow(AssessmentData data, AssessmentEntry entry, int num, OpenXMLWorksheet exportSheet) {
    int col = 0;
    Identity assessedIdentity = data.getIdentity();
    User assessedUser = assessedIdentity.getUser();
    Row dataRow = exportSheet.newRow();
    // sequence number
    dataRow.addCell(col++, num, null);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler != null) {
            String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
            dataRow.addCell(col++, property, null);
        }
    }
    // homepage
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(assessedIdentity);
    String homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
    dataRow.addCell(col++, homepage, null);
    // course node points and passed
    if (courseNode.hasScoreConfigured()) {
        if (entry != null && entry.getScore() != null) {
            dataRow.addCell(col++, entry.getScore(), null);
        } else {
            col++;
        }
    }
    if (courseNode.hasPassedConfigured()) {
        if (entry != null && entry.getPassed() != null) {
            dataRow.addCell(col++, entry.getPassed().toString(), null);
        } else {
            col++;
        }
    }
    ModuleConfiguration config = courseNode.getModuleConfiguration();
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (list != null && list.getList() != null && data.getChecks() != null) {
        Map<String, DBCheck> checkMap = data.getChecks().stream().collect(Collectors.toMap(c -> c.getCheckbox().getCheckboxId(), c -> c));
        List<Checkbox> checkboxList = list.getList();
        for (Checkbox checkbox : checkboxList) {
            String boxId = checkbox.getCheckboxId();
            DBCheck check = checkMap.get(boxId);
            if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
                dataRow.addCell(col++, "x", null);
            } else {
                col++;
            }
            if (courseNode.hasScoreConfigured() && checkbox.getPoints() != null) {
                if (check != null && check.getScore() != null) {
                    dataRow.addCell(col++, check.getScore(), null);
                } else {
                    col++;
                }
            }
        }
    }
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) Util(org.olat.core.util.Util) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) CoreSpringFactory(org.olat.core.CoreSpringFactory) HashMap(java.util.HashMap) DBCheck(org.olat.course.nodes.cl.model.DBCheck) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) ModuleConfiguration(org.olat.modules.ModuleConfiguration) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) ContextEntry(org.olat.core.id.context.ContextEntry) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) Locale(java.util.Locale) Map(java.util.Map) AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) ZipEntry(java.util.zip.ZipEntry) OLog(org.olat.core.logging.OLog) ICourse(org.olat.course.ICourse) OutputStream(java.io.OutputStream) Translator(org.olat.core.gui.translator.Translator) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) Checkbox(org.olat.course.nodes.cl.model.Checkbox) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) UserManager(org.olat.user.UserManager) List(java.util.List) User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Collections(java.util.Collections) Tracing(org.olat.core.logging.Tracing) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) DBCheck(org.olat.course.nodes.cl.model.DBCheck) User(org.olat.core.id.User) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ContextEntry(org.olat.core.id.context.ContextEntry) Checkbox(org.olat.course.nodes.cl.model.Checkbox) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

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