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);
}
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);
}
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;
}
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);
}
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());
}
}
Aggregations