Search in sources :

Example 6 with Checkbox

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

the class CheckboxAssessmentController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (checkboxEl == source) {
        int nextCheckboxIndex = checkboxEl.getSelected();
        saveCurrentSelectCheckbox();
        Checkbox box = checkboxList.getList().get(nextCheckboxIndex);
        boolean hasPoints = box.getPoints() != null && box.getPoints().floatValue() > 0f;
        List<CheckboxAssessmentRow> rows = model.getObjects();
        for (CheckboxAssessmentRow row : rows) {
            Boolean[] checkedArr = row.getChecked();
            if (checkedArr[nextCheckboxIndex] != null && checkedArr[nextCheckboxIndex].booleanValue()) {
                row.getCheckedEl().select(onKeys[0], true);
            } else {
                row.getCheckedEl().select(onKeys[0], false);
            }
            Float[] scores = row.getScores();
            if (scores[nextCheckboxIndex] != null && scores[nextCheckboxIndex] != null) {
                row.getPointEl().setValue(AssessmentHelper.getRoundedScore(scores[nextCheckboxIndex]));
            } else {
                row.getPointEl().setValue("");
            }
            row.getPointEl().setVisible(hasPoints);
        }
        currentCheckboxIndex = nextCheckboxIndex;
    } else if (source instanceof MultipleSelectionElement) {
        MultipleSelectionElement checkEl = (MultipleSelectionElement) source;
        if (checkEl.getUserObject() instanceof CheckboxAssessmentRow) {
            CheckboxAssessmentRow row = (CheckboxAssessmentRow) checkEl.getUserObject();
            if (row.getPointEl().isVisible()) {
                boolean checked = checkEl.isAtLeastSelected(1);
                if (checked) {
                    int nextCheckboxIndex = checkboxEl.getSelected();
                    Checkbox box = checkboxList.getList().get(nextCheckboxIndex);
                    String pointVal = AssessmentHelper.getRoundedScore(box.getPoints());
                    row.getPointEl().setValue(pointVal);
                } else {
                    row.getPointEl().setValue("");
                }
            }
        }
    } else if (selectAllBoxButton == source) {
        doSelectAll();
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Checkbox(org.olat.course.nodes.cl.model.Checkbox)

Example 7 with Checkbox

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

the class CheckboxAssessmentController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    saveCurrentSelectCheckbox();
    int numOfCheckbox = checkboxList.getNumOfCheckbox();
    Map<Long, CheckListAssessmentRow> identityToInitialRow = new HashMap<>();
    for (CheckListAssessmentRow initialRow : initialRows) {
        identityToInitialRow.put(initialRow.getIdentityKey(), initialRow);
    }
    Set<Long> assessedIdentityToUpdate = new HashSet<>();
    List<CheckboxAssessmentRow> rows = model.getObjects();
    List<AssessmentBatch> batchElements = new ArrayList<>();
    for (CheckboxAssessmentRow row : rows) {
        CheckListAssessmentRow initialRow = identityToInitialRow.get(row.getIdentityKey());
        Boolean[] checked = initialRow.getChecked();
        Boolean[] editedChecked = row.getChecked();
        Float[] scores = initialRow.getScores();
        Float[] editedScores = row.getScores();
        for (int i = 0; i < numOfCheckbox; i++) {
            Checkbox box = checkboxList.getList().get(i);
            boolean currentValue = getSecureValue(checked, i);
            boolean editedValue = getSecureValue(editedChecked, i);
            Float currentPoint = getSecureValue(scores, i);
            ;
            Float editedPoint;
            if (box.getPoints() != null && box.getPoints().floatValue() > 0f) {
                editedPoint = getSecureValue(editedScores, i);
            } else {
                editedPoint = null;
            }
            if ((editedValue != currentValue) || ((currentPoint == null && editedPoint != null) || (currentPoint != null && editedPoint == null) || (currentPoint != null && !currentPoint.equals(editedPoint)))) {
                Checkbox checkbox = checkboxList.getList().get(i);
                String checkboxId = checkbox.getCheckboxId();
                batchElements.add(new AssessmentBatch(row.getIdentityKey(), checkboxId, editedPoint, editedValue));
                assessedIdentityToUpdate.add(row.getIdentityKey());
            }
        }
    }
    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);
        }
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : HashMap(java.util.HashMap) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) 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 8 with Checkbox

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

the class CheckboxPDFExport method getHeaders.

private String[] getHeaders(CheckboxList checkboxList) {
    int numOfCheckbox = checkboxList.getList().size();
    String[] headers = new String[numOfCheckbox + 2];
    headers[0] = translator.translate("participants");
    int pos = 1;
    for (Checkbox box : checkboxList.getList()) {
        headers[pos++] = box.getTitle();
    }
    headers[numOfCheckbox + 1] = translator.translate("signature");
    return headers;
}
Also used : Checkbox(org.olat.course.nodes.cl.model.Checkbox)

Example 9 with Checkbox

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

the class AssessedIdentityCheckListController method doUpdateCheck.

private void doUpdateCheck(CheckboxWrapper wrapper, boolean check) {
    // nothing to do
    if (wrapper.getPointEl() == null)
        return;
    if (check) {
        if (!StringHelper.containsNonWhitespace(wrapper.getPointEl().getValue())) {
            Checkbox checkbox = wrapper.getCheckbox();
            Float points = checkbox.getPoints();
            if (points != null) {
                String val = AssessmentHelper.getRoundedScore(points);
                wrapper.getPointEl().setValue(val);
            }
        }
    } else if (wrapper.getPointEl() != null) {
        wrapper.getPointEl().setValue("");
    }
    // hide when not yet checked
    wrapper.getPointEl().setVisible(check);
}
Also used : Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox)

Example 10 with Checkbox

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

the class AssessedIdentityCheckListController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        List<DBCheck> checks = checkboxManager.loadCheck(assessedIdentity, courseOres, courseNode.getIdent());
        Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
        for (DBCheck check : checks) {
            uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
        }
        List<Checkbox> list = checkboxList.getList();
        wrappers = new ArrayList<>(list.size());
        for (Checkbox checkbox : list) {
            DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
            boolean readOnly = false;
            CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
            wrappers.add(wrapper);
        }
        layoutCont.contextPut("checkboxList", wrappers);
    }
    FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonCont);
    FormSubmit saveButton = uifactory.addFormSubmitButton("save", "save", buttonCont);
    saveButton.setEnabled(checkboxList.getNumOfCheckbox() > 0);
    saveButton.setVisible(!coachCourseEnv.isCourseReadOnly());
    saveAndCloseLink = uifactory.addFormLink("save.close", buttonCont, Link.BUTTON);
    saveAndCloseLink.setEnabled(checkboxList.getNumOfCheckbox() > 0);
    saveAndCloseLink.setVisible(saveAndClose && !coachCourseEnv.isCourseReadOnly());
    if (cancel) {
        uifactory.addFormCancelButton("cancel", buttonCont, ureq, getWindowControl());
    }
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) HashMap(java.util.HashMap) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

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